pony_express v0.2.1 PonyExpress.Client View Source

GenServer which initiates a TLS connection to a remote Phoenix.PubSub server and forwards the subscription across the TLS connection to a local PubSub server.

Note that PubSub messages are forwarded in one direction only, from server to client. A future version may feature pushing messages to the remote server, but this may require considerations like request throttling. In this case the security model is that the Client trusts the Server to not spam it.

Note: A client may be bound to a single remote server, and a single topic on a single PubSub server bound to that TCP port by the remote's PonyExpress.Daemon server.

If you need to subscribe to multiple topics, you will need to establish multiple PonyExpress.Client connections.

Usage

Typically, you will want to start the client supervised in the application supervision tree as follows (or equivalent):

DynamicSupervisor.start_child({
  SomeSupervisor,
  server: <server IP>,
  topic: "<pubsub topic>",
  pubsub_server: <pubsub>,
  tls_opts: [
    cacertfile: <ca_certfile>
    certfile: <certfile>
    keyfile: <keyfile>
  ]})
)

the following parameters are required:

  • :pubsub_server - the atom describing the Phoenix PubSub server.
  • :topic - a string which describes the topic remotely subscribed to.
  • :tls_opts - cerificate authority pem file, client certificate, and client key.

Link to this section Summary

Functions

Returns a specification to start this module under a supervisor.

Link to this section Functions

Returns a specification to start this module under a supervisor.

See Supervisor.