fuel v0.1.0 Fuel.Ctx View Source
Provides functions for interacting with a ctx
.
The ctx
is based on the golang context.Context
and provides many of the same functional features.
Using a ctx
provides a common thread of data that can be used all through your application.
It can be used in plug, grpc, graphql or just within your application to facilitate testing.
You can include things like
- implementation of behaviours
- Authentication information
- ids - request, trace etc
- deadlines
- arbitrary values
Link to this section Summary
Functions
Fetch a new deadline
Fetches a ctx from a kw list or map or returns a new one
puts a ctx into a kwlist or map
true if the deadline has not yet exceeded. false
True when the time is earlier than the deadline. False if the deadline has elapsed
Fetches an implementation from the given context.
Fetches the implementation for the given behavioru from the given context.
Get a value at a key. Missing values will raise a KeyError
Get a value at a key. Missing values will return the default
Fetch a new deadline
Set a value at a key in the context. Any valid term may be used as a key
Provide a new ctx with a deadline set to elapse after the given time period
Set a deadline on an existing ctx
Store the implementation of a behaviour in a context
provides a new ctx with the given value
Store a value on
Provide a new ctx with the given values
Link to this section Types
Link to this section Functions
Fetch a new deadline
Fetches a ctx from a kw list or map or returns a new one
puts a ctx into a kwlist or map
true if the deadline has not yet exceeded. false
True when the time is earlier than the deadline. False if the deadline has elapsed
Fetches an implementation from the given context.
If no implementation has been explicitly provided, use the behaviour module as the implementation
Fetches the implementation for the given behavioru from the given context.
If no implementation has been explicitly provided, fall back to the deafult implementation provided
Get a value at a key. Missing values will raise a KeyError
Get a value at a key. Missing values will return the default
Fetch a new deadline
Set a value at a key in the context. Any valid term may be used as a key
Provide a new ctx with a deadline set to elapse after the given time period
Set a deadline on an existing ctx
Store the implementation of a behaviour in a context
This is useful for changing out behaviours in things like tests where you want to use Mox.
@see fetch_impl/2
, fetch_impl/3
provides a new ctx with the given value
Store a value on
Provide a new ctx with the given values