Hyper.Node.Img.Server (Hyper v0.1.0)

Copy Markdown View Source

GenServer representing a single active image on this node.

On start it resolves the image's layer chain, acquires each Layer.Server (keeping the loop devices mounted), and assembles them into a single read-only block device by stacking dm-snapshot targets (base at the bottom, each delta's exception store layered on top). blk_path/1 returns that composed device.

Reference-counted via process monitors, like Layer.Server: holders acquire/1 it; when the last leaves it idle-reaps, removing its dm chain in terminate/2 and releasing its layers (which then unmount once nothing else holds them).

Summary

Functions

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

The composed read-only block device path for the image managed by server.

Returns a specification to start this module under a supervisor.

The ordered layer ids that compose the image managed by server.

Drop the calling process's reference on server.

Start an image server for opts, registered by image id.

Functions

acquire(server)

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

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

blk_path(server)

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

The composed read-only block device path for the image managed by server.

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

layers(server)

@spec layers(GenServer.server()) :: [Hyper.Layer.id()]

The ordered layer ids that compose the image managed by server.

release(server)

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

Drop the calling process's reference on server.

start_link(opts)

Start an image server for opts, registered by image id.