Sambex.ConnectionSupervisor (sambex v0.2.0)

View Source

Supervisor for managing SMB connections.

This supervisor manages connection processes and the registry for named connections. It ensures connections are properly supervised and can be restarted if they crash.

Examples

# Start the supervisor (usually done in application.ex)
{:ok, _pid} = Sambex.ConnectionSupervisor.start_link()

# Start a supervised connection
{:ok, conn} = Sambex.ConnectionSupervisor.start_connection(
  url: "smb://server/share",
  username: "user", 
  password: "pass",
  name: :my_share
)

Summary

Functions

Returns a specification to start this module under a supervisor.

List all active connections.

Start a new supervised connection.

Start the connection supervisor.

Stop a supervised connection.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

list_connections()

List all active connections.

Returns a list of {name_or_pid, pid} tuples for all active connections.

Examples

connections = Sambex.ConnectionSupervisor.list_connections()
# => [{:my_share, #PID<0.123.0>}, {#PID<0.124.0>, #PID<0.124.0>}]

start_connection(opts)

Start a new supervised connection.

Options

  • :url - SMB URL (required)
  • :username - Username for authentication (required)
  • :password - Password for authentication (required)
  • :name - Optional name for the connection

Examples

{:ok, conn} = Sambex.ConnectionSupervisor.start_connection(
  url: "smb://server/share",
  username: "user",
  password: "pass"
)

{:ok, _pid} = Sambex.ConnectionSupervisor.start_connection(
  url: "smb://server/docs", 
  username: "user",
  password: "pass",
  name: :docs
)

start_link(opts \\ [])

Start the connection supervisor.

stop_connection(conn_or_name)

Stop a supervised connection.

Parameters

  • conn_or_name - Connection PID or registered name

Examples

:ok = Sambex.ConnectionSupervisor.stop_connection(conn)
:ok = Sambex.ConnectionSupervisor.stop_connection(:my_share)