owner

package
v0.36.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 19, 2026 License: Apache-2.0 Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package owner manages lease-based ownership of the local runtime's resident state. On Join, one instance becomes the owner — it holds the lease and renews it in the background — while others become followers that know who the owner is and, when advertised, where to reach it.

The owner self-fences: if it cannot renew before the lease expires, Lost() fires and the caller MUST stop touching owned state, because another instance may have taken over.

Index

Constants

View Source
const BackendMetaKey = "backend"

BackendMetaKey is the lease metadata key used to advertise the inference backend the owner serves (mirrored by runtime/internal/modeldprobe).

View Source
const EndpointMetaKey = "endpoint"

EndpointMetaKey is the lease metadata key used to advertise the owner's transport endpoint.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// LeasePath is the lease file; one owner per path (per user + data root).
	LeasePath string
	// TTL is the lease duration.
	TTL time.Duration
	// RenewInterval is how often the owner renews; defaults to TTL/3.
	RenewInterval time.Duration
	// Endpoint, if set, is advertised to followers via the lease record so they
	// can reach the owner transport. Empty means no endpoint is advertised.
	Endpoint string
	// Backend, if set, is the inference backend this owner serves ("llama" /
	// "openvino" / "none"), advertised via the lease so the runtime can tell which
	// mode the daemon is in without a network round-trip.
	Backend string
	// Meta carries additional holder metadata for specialized leases. Endpoint
	// and Backend, when set above, override same-named entries here.
	Meta map[string]string
}

Config controls a Join.

type Owner

type Owner struct {
	// contains filtered or unexported fields
}

Owner is the result of a Join: either this instance (RoleOwner) with a running renew loop, or a handle describing the current owner (RoleFollower).

func Join

func Join(ctx context.Context, cfg Config) (*Owner, error)

Join attempts to acquire ownership of the lease at cfg.LeasePath. If the lease is free it returns an Owner in RoleOwner and starts renewing in the background; if a live owner already holds it, it returns RoleFollower with the current holder. ctx bounds the renew loop's lifetime; cancelling it stops renewal. Call Release to relinquish the lease before the TTL expires.

func (*Owner) Backend added in v0.32.2

func (o *Owner) Backend() string

Backend returns the inference backend the owner serves, or "" if none.

func (*Owner) Endpoint

func (o *Owner) Endpoint() string

Endpoint returns the owner's advertised endpoint, or "" if none.

func (*Owner) Holder

func (o *Owner) Holder() liblease.Record

Holder returns the current owner's lease record.

func (*Owner) InstanceID

func (o *Owner) InstanceID() string

InstanceID is this owner's id, or the current owner's id for a follower.

func (*Owner) IsOwner

func (o *Owner) IsOwner() bool

IsOwner reports whether this instance holds the lease.

func (*Owner) Lost

func (o *Owner) Lost() <-chan struct{}

Lost is closed when the owner can no longer renew the lease (taken over or an I/O failure). The caller must stop touching owned state when it fires. It never fires for a follower.

func (*Owner) LostErr

func (o *Owner) LostErr() error

LostErr returns why ownership was lost, after Lost fires.

func (*Owner) Release

func (o *Owner) Release() error

Release stops renewing and relinquishes the lease so a successor can take over immediately rather than waiting out the TTL. Safe to call multiple times; a no-op for a follower.

func (*Owner) Role

func (o *Owner) Role() Role

Role reports whether this instance is the owner or a follower.

type Role

type Role int

Role is whether this instance owns the lease.

const (
	// RoleFollower means another instance currently owns the lease.
	RoleFollower Role = iota
	// RoleOwner means this instance holds and renews the lease.
	RoleOwner
)

func (Role) String

func (r Role) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL