ExCEP.Cluster.Server (ex_cep v0.1.1)

Copy Markdown

Edge Cluster (Master) TCP/TLS server and Gateway session registry.

Listens on a CEP channel port (9901 for :management or 9902 for :business, or port 0 for OS-assigned ephemeral ports in tests), spawns an ExCEP.Cluster.Session per connected Edge Gateway, and routes Cluster -> Gateway commands by gateway_id.

Summary

Functions

Returns a specification to start this module under a supervisor.

Looks up the active ExCEP.Cluster.Session pid for gateway_id.

Returns the list of currently connected and authenticated gateway_ids.

Returns the bound TCP listening port.

Pulls a file from a connected Gateway using Section 6.2.1 (FileGet + FileDataTrans).

Pushes a binary file to a connected Gateway using Section 6.2.2 (FileSend + FileDataTrans).

Sends a %DataAsdu{} request to gateway_id and awaits its correlated response.

Sends a one-way %DataAsdu{} to the connected gateway_id.

Stops the Cluster server and closes all active sessions.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

get_session(server, gateway_id)

@spec get_session(GenServer.server(), String.t()) ::
  {:ok, pid()} | {:error, :not_connected}

Looks up the active ExCEP.Cluster.Session pid for gateway_id.

list_gateways(server)

@spec list_gateways(GenServer.server()) :: [String.t()]

Returns the list of currently connected and authenticated gateway_ids.

port(server)

@spec port(GenServer.server()) :: :inet.port_number()

Returns the bound TCP listening port.

pull_file(server, gateway_id, remote_path, opts \\ [])

@spec pull_file(GenServer.server(), String.t(), String.t(), keyword()) ::
  {:ok, binary()} | {:error, term()}

Pulls a file from a connected Gateway using Section 6.2.1 (FileGet + FileDataTrans).

push_file(server, gateway_id, remote_path, content, opts \\ [])

@spec push_file(GenServer.server(), String.t(), String.t(), binary(), keyword()) ::
  :ok | {:error, term()}

Pushes a binary file to a connected Gateway using Section 6.2.2 (FileSend + FileDataTrans).

request(server, gateway_id, asdu, opts \\ [])

@spec request(GenServer.server(), String.t(), ExCEP.Codec.DataAsdu.t(), keyword()) ::
  {:ok, ExCEP.Codec.DataAsdu.t()} | {:error, term()}

Sends a %DataAsdu{} request to gateway_id and awaits its correlated response.

send_asdu(server, gateway_id, asdu, opts \\ [])

@spec send_asdu(GenServer.server(), String.t(), ExCEP.Codec.DataAsdu.t(), keyword()) ::
  :ok | {:error, term()}

Sends a one-way %DataAsdu{} to the connected gateway_id.

start_link(opts \\ [])

@spec start_link(keyword()) :: GenServer.on_start()

stop(server)

@spec stop(GenServer.server()) :: :ok

Stops the Cluster server and closes all active sessions.