raxx v0.17.6 Raxx.Context
Raxx.Context
is a mechanism for simple sharing of state/information between
Raxx.Middleware
s and Raxx.Server
s.
It is designed to be flexible and to enable different middlewares to operate on it without conflicts. Each separate functionality using the context can be in a different “section”, containing arbitrary data.
Context is implicitly shared using the process dictionary and persists for the
duration of a single request/response cycle. If you want to pass the context
to a different process, you need to take its snapshot, pass it explicitly and
“restore” it in the other process. See Raxx.Context.get_snapshot/0
and
Raxx.Context.restore_snapshot/1
for details.
Link to this section Summary
Functions
Deletes the section from the context
Creates a snapshot of the current process’ context
Restores a previously created context snapshot
Retrieves the value of the context section
Sets the value of a context section
Link to this section Types
An opaque type for the context snapshot data.
Link to this section Functions
Deletes the section from the context.
Returns the previous value of the section or nil
if one was
not set.
Creates a snapshot of the current process’ context.
The returned context data can be passed between processes and restored
using Raxx.Context.restore_snapshot/1
Restores a previously created context snapshot.
It will restore the implicit state of the context for the current
process to what it was when the snapshot was created using
Raxx.Context.get_snapshot/0
. The current context values won’t
be persisted in any way.
retrieve(section_name(), default :: term()) :: term()
Retrieves the value of the context section.
If the section wasn’t set yet, it will return nil
.
Sets the value of a context section.
Returns the previous value of the section or nil
if one was
not set.