# `Hyper.Node.Layer.Server`
[🔗](https://github.com/harmont-dev/hyper/blob/main/lib/hyper/node/layer/server.ex#L1)

GenServer responsible for managing a single mounted layer.

Reference-counted via process monitors: each holder `acquire/1`s the layer and
the server monitors it, so a holder that crashes is released automatically (no
leaked count). When the last holder goes away the server waits a short idle
grace period and then stops, unmounting the block device in `terminate/2`. The
grace period keeps bursty acquire/release cycles from thrashing the mount.

# `acquire`

```elixir
@spec acquire(GenServer.server()) :: :ok
```

Take a reference on `server` on behalf of the calling process. The layer stays
mounted until every holder releases (or dies). Idempotent per process.

# `blk_path`

```elixir
@spec blk_path(GenServer.server()) :: Path.t()
```

Get the block device path of the layer managed by `server`.

# `child_spec`

Returns a specification to start this module under a supervisor.

See `Supervisor`.

# `for_layer`

```elixir
@spec for_layer(Hyper.Layer.id()) :: {:ok, pid()} | {:error, term()}
```

Get the server mounting `layer_id`, starting it under the layer supervisor if needed.

# `release`

```elixir
@spec release(GenServer.server()) :: :ok
```

Drop the calling process's reference on `server`.

# `start_link`

```elixir
@spec start_link(Hyper.Node.Layer.Server.Opts.t()) :: GenServer.on_start()
```

Create a new layer, mounting it as a block device.

---

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