# `Portals.SocketDir`
[🔗](https://github.com/Ziinc/portals/blob/v0.1.0/lib/portals/socket_dir.ex#L1)

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.

# `allocate`

```elixir
@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`

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

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

# `runtime_root`

```elixir
@spec runtime_root() :: binary()
```

---

*Consult [api-reference.md](api-reference.md) for complete listing*
