View Source Rambla (Rambla v1.2.6)

Interface for the message publishing through Rambla.

Rambla maintains connection pools with Finitomata.Pool for each service.

The typical config for Rambla service follows the pattern introduced by AMQP library:

service: [
  connections: [
    connection_name: [key_1: value_1, ]
  ],
  channels: [
    channel_name: [
      connection: connection_name,
      options: [key_1: value_1, ]
    ]
  ]
]

Additional option, one might pass to the channel config, would be explicit handlers for failures and success calls (by default the former prints the warning and retries until the maximum count of retries reached, and then calls on_fatal/2 callback, and the latter logs a debug message.)

  channels: [
    chan_1: [
      connection: :conn_1,
      options: [
        callbacks: [
          on_success: fn result -> IO.inspect(result, label: "on_success") && :ok end]
        ]]]]

To start pools, simply embed Rambla into the supervision tree, it’d start a supervisor with children for all the configured services.

The configuration of the service implies all the Rambla’s code for it will be compiled, but the dependency itself must be added to the deps section of the Mix.Project file.

The excerpt from the Rambla.MixProject itself follows

  # optional backends
  {:amqp, "~> 3.0", optional: true},
  {:redix, "~> 1.0", optional: true},
  {:pillar, "~> 0.39", optional: true},
  {:gen_smtp, "~> 0.4 or ~> 1.0", optional: true},
  {:telemetria, "~> 0.4 or ~> 1.0", optional: true},

  # s3
  {:ex_aws, "~> 2.1", optional: true},
  {:ex_aws_s3, "~> 2.0", optional: true},
  {:ex_aws_sts, "~> 2.0", optional: true},
  {:hackney, "~> 1.9", optional: true},
  {:sweet_xml, "~> 0.6", optional: true},
  {:configparser_ex, "~> 4.0", optional: true},

Channel names are used across connections to publish messages. Rambla.publish(:channel_1, message) would publish the message to all channels named channel_1.

Summary

Functions

Returns a map %{‹service› => [‹channels›]}

Returns a specification to start this module under a supervisor.

pools() deprecated

Returns the currently active pools

Publishes the message to the target channels. The message structure depends on the destination. For RabbitMQ is might be whatever, for Smtp it expects to have to:, subject: and body: fields.

Publishes the message to the destination synchronously, avoiding the pool.

Publishes the message to the destination synchronously, avoiding the pool. Unlike publish_synch/2, allows to specify additional options per request.

raw(target, f) deprecated

Executes any arbitrary function in the context of one of workers in the respective connection pool for the target.

Returns a list of all the configured services (connections)

Starts the supervisor with all the configured services

start_pools() deprecated

Starts the pools configured in the config.exs / releases.exs file.

start_pools(opts) deprecated

Starts the pools as specified by options (map() or keyword())

Functions

Returns a map %{‹service› => [‹channels›]}

Returns a specification to start this module under a supervisor.

See Supervisor.

This function is deprecated. Use configuration instead.

Returns the currently active pools

Link to this function

publish(target, message, pid \\ nil)

View Source

Publishes the message to the target channels. The message structure depends on the destination. For RabbitMQ is might be whatever, for Smtp it expects to have to:, subject: and body: fields.

Link to this function

publish_synch(target, message)

View Source
This function is deprecated. Use configuration instead with `[count: 1]` option.

Publishes the message to the destination synchronously, avoiding the pool.

Link to this function

publish_synch(target, message, opts)

View Source
This function is deprecated. Use configuration instead with `[count: 1]` option.

Publishes the message to the destination synchronously, avoiding the pool. Unlike publish_synch/2, allows to specify additional options per request.

This function is deprecated. Use `publish(channels, FUNCTION, pid)` instead.

Executes any arbitrary function in the context of one of workers in the respective connection pool for the target.

The function would receive a pid of the connection process.

Returns a list of all the configured services (connections)

Starts the supervisor with all the configured services

This function is deprecated. Use configuration instead.

Starts the pools configured in the config.exs / releases.exs file.

This call is equivalent to start_pools(Application.get_env(:rambla, :pools)).

This function is deprecated. Use configuration instead.

Starts the pools as specified by options (map() or keyword())