Helios v0.2.2 Helios.Context View Source
Represent execution context for single message/command sent to helios endpoint.
Link to this section Summary
Functions
Assigns a value to a key in the context
Emits given event or events. If events is equal to nil, then it will ignore call
Halts the Context pipeline by preventing further plugs downstream from being
invoked. See the docs for Helios.Context.Builder
for more information on halting a
command context pipeline
Assigns multiple values to keys in the context
Assigns multiple private keys and values in the context
Assigns a new private key and value in the context
Link to this section Types
status() :: :init | :executing | :executed | :commiting | :success | :failed
t() :: %Helios.Context{ adapter: {module(), term()}, assigns: assigns(), before_send: list(), correlation_id: correlation_id(), events: events(), halted: halted(), handler: term(), method: atom(), owner: owner(), params: params(), path_info: [binary()], path_params: params(), peer: peer(), private: private(), request_id: request_id(), response: response(), retry: integer(), state: :unset | :set | :sent, status: status() }
Link to this section Functions
assign(Helios.Context.t(), atom(), any()) :: Helios.Context.t()
Assigns a value to a key in the context.
Examples
iex> ctx.assigns[:hello]
nil
iex> ctx = assign(ctx, :hello, :world)
iex> ctx.assigns[:hello]
:world
emit(ctx :: Helios.Context.t(), Helios.Context.events()) :: Helios.Context.t()
Emits given event or events. If events is equal to nil, then it will ignore call.
error(Helios.Context.t(), any()) :: Helios.Context.t()
Halts the Context pipeline by preventing further plugs downstream from being
invoked. See the docs for Helios.Context.Builder
for more information on halting a
command context pipeline.
merge_assigns(Helios.Context.t(), Keyword.t()) :: Helios.Context.t()
Assigns multiple values to keys in the context.
Equivalent to multiple calls to assign/3
.
Examples
iex> ctx.assigns[:hello]
nil
iex> ctx = merge_assigns(ctx, hello: :world)
iex> ctx.assigns[:hello]
:world
merge_private(Helios.Context.t(), Keyword.t()) :: Helios.Context.t()
Assigns multiple private keys and values in the context.
Equivalent to multiple put_private/3
calls.
Examples
iex> ctx.private[:plug_hello]
nil
iex> ctx = merge_private(ctx, plug_hello: :world)
iex> ctx.private[:plug_hello]
:world
ok(Helios.Context.t(), any()) :: Helios.Context.t()
put_private(Helios.Context.t(), atom(), term()) :: Helios.Context.t()
Assigns a new private key and value in the context.
This storage is meant to be used by libraries and frameworks to avoid writing
to the user storage (the :assigns
field). It is recommended for
libraries/frameworks to prefix the keys with the library name.
For example, if some plug needs to store a :hello
key, it
should do so as :plug_hello
:
iex> ctx.private[:plug_hello]
nil
iex> ctx = put_private(ctx, :plug_hello, :world)
iex> ctx.private[:plug_hello]
:world