Socketelx.Config (socketelx v0.2.1)

Copy Markdown View Source

Per-instance configuration.

Resolves explicit options first (passed to Socketelx.start_link/1), falling back to environment variables for anything omitted — the same variables the standalone release reads. This is what lets the exact same code run either as a hex dependency embedded in your own supervision tree (config passed explicitly) or as a standalone release configured purely by env vars, with zero code differences.

Options / environment variables

OptionEnv varDefault
:app_keySOCKETELX_APP_KEY"app-key"
:app_secretSOCKETELX_APP_SECRET"app-secret" (public; a warning is logged, always set your own)
:app_idSOCKETELX_APP_ID"app-id"
:portPORT6001
:webhook_urlSOCKETELX_WEBHOOK_URLnone
:client_messages_enabledSOCKETELX_ENABLE_CLIENT_MESSAGEStrue
:redis_urlSOCKETELX_REDIS_URLnone (single node)
:redis_opts—[] (extra Redix options, e.g. ssl: true)
:webhook_retriesSOCKETELX_WEBHOOK_RETRIES3 (retries after the first attempt; 0 disables)
:webhook_retry_base_ms—1000 (delay doubles on each retry)
:rest_rate_limitSOCKETELX_REST_RATE_LIMITnone (max REST API requests per second, per instance)
:client_event_rate_limitSOCKETELX_CLIENT_EVENT_RATE_LIMITnone (max client events per second, per connection)
:max_connectionsSOCKETELX_MAX_CONNECTIONSnone (max WebSocket connections on this node)
:batch_limitSOCKETELX_BATCH_LIMIT10 (max events per batch_events request)
:metricsSOCKETELX_METRICSfalse (serve Prometheus metrics at GET /metrics)
:metrics_tokenSOCKETELX_METRICS_TOKENnone (if set, /metrics requires Authorization: Bearer <token>)

Setting :redis_url switches the instance to the Redis backend so several nodes can share channels, presence and broadcasts. Without it, the instance runs fully in-memory and needs nothing but this library.

Summary

Types

t()

@type t() :: %Socketelx.Config{
  app_id: term(),
  app_key: term(),
  app_secret: term(),
  backend: term(),
  batch_limit: term(),
  client_event_rate_limit: term(),
  client_messages_enabled: term(),
  max_connections: term(),
  metrics: term(),
  metrics_token: term(),
  node_id: term(),
  port: term(),
  prefix: term(),
  redis_opts: term(),
  redis_url: term(),
  rest_rate_limit: term(),
  webhook_retries: term(),
  webhook_retry_base_ms: term(),
  webhook_url: term()
}