agala v3.0.0 Agala.Conn
The Agala connection.
This module defines a Agala.Conn struct. This struct contains
both request and response data.
Request fields
These fields contain request information:
request- request data structure. It’s internal structure depends on provider type.
Link to this section Summary
Functions
Assigns a value to a key in the connection
Examples
iex> conn.assigns[:hello]
nil
iex> conn = assign(conn, :hello, :world)
iex> conn.assigns[:hello]
:world
Starts a task to assign a value to a key in the connection.
await_assign/2 can be used to wait for the async task to complete and
retrieve the resulting value.
Behind the scenes, it uses Task.async/1.
Examples
iex> conn.assigns[:hello]
nil
iex> conn = async_assign(conn, :hello, fn -> :world end)
iex> conn.assigns[:hello]
%Task{...}
Awaits the completion of an async assign.
Returns a connection with the value resulting from the async assignment placed
under key in the :assigns field.
Behind the scenes, it uses Task.await/2.
Examples
iex> conn.assigns[:hello]
nil
iex> conn = async_assign(conn, :hello, fn -> :world end)
iex> conn = await_assign(conn, :hello) # blocks until `conn.assigns[:hello]` is available
iex> conn.assigns[:hello]
:world
Halts the Agala.Chain pipeline by preventing further chains downstream from being
invoked. See the docs for Agala.Chain.Builder for more information on halting a
Chain pipeline
Assigns a new private key and value in the connection.
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> conn.private[:plug_hello]
nil
iex> conn = put_private(conn, :plug_hello, :world)
iex> conn.private[:plug_hello]
:world
Specifies the name for the bot, which will send the response back to side APIs
Specifies the lambda function that will be called after the result of
provider’s respponse to the bot’s response will appear.
The lambda shuld have only one parameter - Agala.Conn.t for current connection.
It’ll have request with request to bot, response with response from bot, and
fallback with response sending results
Link to this section Types
Link to this section Functions
Assigns a value to a key in the connection
Examples
iex> conn.assigns[:hello]
nil
iex> conn = assign(conn, :hello, :world)
iex> conn.assigns[:hello]
:world
Starts a task to assign a value to a key in the connection.
await_assign/2 can be used to wait for the async task to complete and
retrieve the resulting value.
Behind the scenes, it uses Task.async/1.
Examples
iex> conn.assigns[:hello]
nil
iex> conn = async_assign(conn, :hello, fn -> :world end)
iex> conn.assigns[:hello]
%Task{...}
Awaits the completion of an async assign.
Returns a connection with the value resulting from the async assignment placed
under key in the :assigns field.
Behind the scenes, it uses Task.await/2.
Examples
iex> conn.assigns[:hello]
nil
iex> conn = async_assign(conn, :hello, fn -> :world end)
iex> conn = await_assign(conn, :hello) # blocks until `conn.assigns[:hello]` is available
iex> conn.assigns[:hello]
:world
Halts the Agala.Chain pipeline by preventing further chains downstream from being
invoked. See the docs for Agala.Chain.Builder for more information on halting a
Chain pipeline.
Assigns a new private key and value in the connection.
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> conn.private[:plug_hello]
nil
iex> conn = put_private(conn, :plug_hello, :world)
iex> conn.private[:plug_hello]
:world
Specifies the name for the bot, which will send the response back to side APIs.
Specifies the lambda function that will be called after the result of
provider’s respponse to the bot’s response will appear.
The lambda shuld have only one parameter - Agala.Conn.t for current connection.
It’ll have request with request to bot, response with response from bot, and
fallback with response sending results.