View Source Rambla.Handlers.Httpc (Rambla v1.2.6)
Default handler for HTTP connections. For this handler to work properly, one must configure it with
config :rambla, :httpc,
connections: [
httpbin: "https://httpbin.org/post",
remote_conn: [scheme: "https", host: "httpbin.org", query: "post"]
],
channels: [
chan_1: [connection: :httpbin, options: [headers: [{"accept", "application/json"}]]]
]
# Then you can access the connection/channel via `Rambla.Handlers.Amqp` as
Rambla.Handlers.Httpc.publish(:chan_1, %{message: %{foo: 42}, serializer: Jason})
The publish/2
function receives options which might be used to amend anything,
including but not limited to URI
, which would be updated as shown below
uri =
uri
|> then(&if(uri_path, do: URI.append_path(&1, uri_path), else: &1))
|> then(&if(uri_query, do: URI.append_query(&1, uri_query), else: &1))
|> then(&if(uri_merge, do: URI.merge(&1, uri_merge), else: &1))
Summary
Functions
The list of child_spec
returned
to be embedded into a supervision tree.
An interface to publish messages using the FSM pool.
The entry point: this would start a supervisor with all the pools and stuff
Functions
The list of child_spec
returned
to be embedded into a supervision tree.
Known options:
connection_options
— akeyword()
or a function of arity one, which is to receive channel names and return connection options as a listcount
— the number of workers in the poolchild_opts
— the options to be passed to the worker’s spec (you won’t need those)
Example
Rambla.Handlers.Redis.children_specs(
connection_options: [exchange: "amq.direct"], count: 3)
An interface to publish messages using the FSM pool.
The id
is the specific to an implementation,
for Amqp
it’d be the channel name, for instance.
The second parameter would be a payload, or, if the backend supports it,
the function of arity one, which would receive back the connection pid
.
Example
Rambla.Handlers.Amqp.publish :channel_name, %{foo: :bar}
@spec start_link([ Supervisor.option() | Supervisor.init_option() | {:connection_options, keyword() | (term() -> keyword())} | {:count, non_neg_integer()} ]) :: Supervisor.on_start()
The entry point: this would start a supervisor with all the pools and stuff