Spectre.Instance.Owner.Lease (Spectre v0.3.0)

Copy Markdown View Source

Portable lease issued by an Instance ownership adapter.

The fencing token is monotonic in the adapter's ownership domain. A local Registry lease is suitable only for a single-owner deployment; distributed hosts must provide a lease backed by their own linearizable authority.

Summary

Functions

Returns whether the lease has not expired at now.

Builds and validates a lease.

Builds a lease or raises with its stable reason.

Types

t()

@type t() :: %Spectre.Instance.Owner.Lease{
  expires_at: non_neg_integer() | nil,
  fencing_token: pos_integer(),
  issued_at: non_neg_integer(),
  metadata: map(),
  owner_id: String.t(),
  schema_version: pos_integer()
}

Functions

current?(lease, now)

@spec current?(t(), non_neg_integer()) :: boolean()

Returns whether the lease has not expired at now.

new(attrs)

@spec new(map() | keyword()) :: {:ok, t()} | {:error, term()}

Builds and validates a lease.

new!(attrs)

@spec new!(map() | keyword()) :: t()

Builds a lease or raises with its stable reason.