Portals.SocketDir (portals v0.1.0)

Copy Markdown View Source

Private per-worker runtime directory and Unix-domain socket path management (FR-1). Every worker gets its own 0700 directory beneath a shared Portals runtime root; stale sockets are removed deterministically before a new listener binds to the same path.

Summary

Functions

Create a fresh private 0700 directory for one worker and return the Unix-domain socket path inside it. Any pre-existing socket file at that path (from an unclean previous shutdown) is removed first.

Deterministically remove a worker's runtime directory and any socket file inside it.

Functions

allocate(worker_id)

@spec allocate(binary()) ::
  {:ok, dir :: binary(), socket_path :: binary()} | {:error, term()}

Create a fresh private 0700 directory for one worker and return the Unix-domain socket path inside it. Any pre-existing socket file at that path (from an unclean previous shutdown) is removed first.

cleanup(dir)

@spec cleanup(binary()) :: :ok

Deterministically remove a worker's runtime directory and any socket file inside it.

runtime_root()

@spec runtime_root() :: binary()