roulette v1.0.4 Roulette.Config

Here is a minimum configuration example, You must setup servers list. Put your load-balancers’ hostname into it.

config :my_app, MyApp.PubSub,
  servers: [
    "gnatsd-cluster1.example.org",
    "gnatsd-cluster2.example.org"
  ]

Or else, you can use keyword list for each host.

config :my_app, MyApp.PubSub,
  servers: [
    [host: "gnatsd-cluster1.example.org", port: 4222],
    [host: "gnatsd-cluster2.example.org", port: 4222]
  ]

If there is no port setting, 4222 is set by defaut.

keydefaultdescription
role:bothYou can choose :subscriber, :publisher, or :both
serversrequiredservers list used as hash-ring
pool_size5number of connections for each gnatsd-cluster
ping_interval5_000sends PING message to gnatsd with this interval (milliseconds)
max_ping_failure2if PONG doesn’t return while this number of PING sends, Roulette disconnects the connection.
max_retry10When it fails to send PUBLISH or SUBSCRIBE messages, it automatically retries until count of failure reaches to this number
max_backoff5_000max duration(milliseconds) used to calculate backoff period
base_backoff10base number used to calculate backoff period
show_debug_logfalseif this is true, Roulette dumps many debug logs.
subscription_restart:temporaryYou can choose :temporary or :permanent

role

  • :both (default) - setup both Publisher and Subscriber connections
  • :subscriber - setup Subscriber connections only
  • :publisher - setup Publisher connections only

subscription_restart

:temporary

subscription-process sends EXIT message to consumer process when gnatsd-connection is disconnected.

:permanent

subscription-process try to keep subscription. when gnatsd-connection is disconnected, retry to sends SUBSCRIBE message through other connections.

Link to this section Summary

Link to this section Types

Link to this type config_key()
config_key() ::
  :servers |
  :role |
  :ping_interval |
  :max_ping_failure |
  :show_debug_log |
  :pool_size |
  :max_retry |
  :max_backoff |
  :base_backoff |
  :subscription_restart |
  :nats
Link to this type host()
host() :: %{host: String.t(), port: pos_integer()}
Link to this type nats_config()
nats_config() :: %{:host => String.t(), :port => pos_integer(), optional(:connection_timeout) => pos_integer(), optional(:tls) => boolean(), optional(:ssl_opts) => keyword(), optional(:tcp_opts) => keyword()}

Link to this section Functions

Link to this function get(module, key)
get(module(), config_key()) :: term()
Link to this function get_host_and_port(target)
get_host_and_port(binary() | Keyword.t()) :: {binary(), pos_integer()}
Link to this function load(module, opts)
load(module(), any()) :: Keyword.t()
Link to this function merge_nats_config(module, host)
merge_nats_config(module(), host()) :: nats_config()
Link to this function store(module, val)
store(module(), Keyword.t()) :: :ok