cluster

package
v0.0.26 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Heartbeat

func Heartbeat(ctx context.Context, store kv.Store, node Node, ttl time.Duration, nowFunc func() time.Time) error

func Release

func Release(ctx context.Context, store kv.Store, name, owner string) error

Types

type Config

type Config struct {
	Store kv.Store
	Node  Node
	TTL   time.Duration
	Now   func() time.Time
}

type Coordinator

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

func New

func New(cfg Config) (*Coordinator, error)

func (*Coordinator) Heartbeat

func (c *Coordinator) Heartbeat(ctx context.Context) error

func (*Coordinator) Node

func (c *Coordinator) Node() Node

func (*Coordinator) Nodes

func (c *Coordinator) Nodes(ctx context.Context) ([]Node, error)

func (*Coordinator) ReleaseLeadership

func (c *Coordinator) ReleaseLeadership(ctx context.Context, name string) error

func (*Coordinator) RenewLeadership

func (c *Coordinator) RenewLeadership(ctx context.Context, name string) (Lease, bool, error)

func (*Coordinator) TryLead

func (c *Coordinator) TryLead(ctx context.Context, name string) (Lease, bool, error)

type Lease

type Lease struct {
	Name      string    `json:"name"`
	Owner     string    `json:"owner"`
	ExpiresAt time.Time `json:"expires_at"`
	Token     string    `json:"token,omitempty"`
}

func Renew

func Renew(ctx context.Context, store kv.Store, name, owner string, ttl time.Duration, nowFunc func() time.Time) (Lease, bool, error)

func TryAcquire

func TryAcquire(ctx context.Context, store kv.Store, name, owner string, ttl time.Duration, nowFunc func() time.Time) (Lease, bool, error)

type Node

type Node struct {
	ID        string            `json:"id"`
	Address   string            `json:"address,omitempty"`
	Version   string            `json:"version,omitempty"`
	Metadata  map[string]string `json:"metadata,omitempty"`
	StartedAt time.Time         `json:"started_at"`
	LastSeen  time.Time         `json:"last_seen"`
	Draining  bool              `json:"draining"`
}

Node describes one fh process participating in a cluster. The package is

func Nodes

func Nodes(ctx context.Context, store kv.Store, now time.Time) ([]Node, error)

Jump to

Keyboard shortcuts

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