pony_express v0.5.1 PonyExpress.Daemon View Source

GenServer which listens on a TCP port waiting for inbound PonyExpress subscriptions.

These connections are then forwarded to PonyExpress.Server servers which then handle Phoenix.PubSub transactions between server and client nodes. Only one PubSub server may be bound to any given port. If you need to forward multiple PubSub servers, you will need to listen on multiple ports.

Usage

Typically, you will want to start the daemon supervised in the application supervision tree as follows:


Supervisor.start_link(
  [{PonyExpress.Daemon,
    pubsub_server: <pubsub_server>,
    server_supervisor: <supervisor for servers>
    tls_opts: [
      cacertfile: <ca_certfile>
      certfile: <certfile>
      keyfile: <keyfile>
  }])

the following parameters are required:

  • :pubsub_server - the atom describing the Phoenix PubSub server.
  • :tls_opts - cerificate authority pem file, server certificate, and server key.

the following parameters might be useful:

  • :port - port to listen on. Defaults to 0, which will pick "any available port"
  • :server_supervisor - one of the following:
    • nil (default), your servers will be unsupervised do not release with this setting
    • :<atom>, a DynamicSupervisor named <atom>
    • {module, term}, an dynamic supervisor behaviour module with the following that will be called in the following fashion: module.start_child(term, {PonyExpress.Server, opts}). See DynamicSupervisor.start_child/2
  • :transport - specify an alternative transport module besides TLS. See Transport.

Link to this section Summary

Functions

Returns a specification to start this module under a supervisor.

retrieve the TCP port that the pony express server is bound to.

Link to this section Types

Link to this section Functions

Returns a specification to start this module under a supervisor.

See Supervisor.

retrieve the TCP port that the pony express server is bound to.

Useful for tests - when we want to assign it a port of 0 so that it gets "any free port" of the system.