# `Spectre.Instance.Owner.Lease`
[🔗](https://github.com/elchemista/spectre/blob/0.4.0/lib/spectre/instance/owner/lease.ex#L1)

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.

# `t`

```elixir
@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()
}
```

# `current?`

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

Returns whether the lease has not expired at `now`.

# `new`

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

Builds and validates a lease.

# `new!`

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

Builds a lease or raises with its stable reason.

---

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