ExIEC61850.IEC61850.Client.ReconnectWorker (ex_iec61850 v0.1.0)

Copy Markdown View Source

Supervisor-friendly auto-reconnecting IEC 61850 client worker with exponential backoff.

Manages an underlying IedConnection, automatically reconnects on initial failure or passive disconnect, and invokes :on_connected after every successful (re)connection so callers can re-enable BRCB/URCB subscriptions.

Example

{:ok, worker} =
  ExIEC61850.IEC61850.Client.ReconnectWorker.start_link(
    host: "127.0.0.1",
    port: 102,
    initial_backoff_ms: 500,
    max_backoff_ms: 10_000,
    on_connected: fn conn -> IedConnection.get_logical_device_list(conn) end
  )

Summary

Functions

Returns a specification to start this module under a supervisor.

Returns true if the worker is currently connected to the IED server.

Returns the underlying IedConnection pid.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

connected?(worker)

@spec connected?(GenServer.server()) :: boolean()

Returns true if the worker is currently connected to the IED server.

get_connection(worker)

@spec get_connection(GenServer.server()) :: pid()

Returns the underlying IedConnection pid.

start_link(opts)

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