Versions in this module Expand all Collapse all v1 v1.0.0 Nov 13, 2026 Changes in this version + var ErrFull = errors.New("ghost: entry limit") + var ErrStaleEpoch = errors.New("ghost: stale owner epoch") + var ErrTimeout = errors.New("ghost: request timeout") + var ErrUnavailable = errors.New("ghost: owner unavailable") + func Keys[Key ~uint64](keys []Key) []uint64 + func NodeID(name string) uint64 + type Batch struct + type Cluster struct + func StartClusterService(service *Service, cfg ClusterConfig) (*Cluster, error) + func (c *Cluster) Close() error + func (c *Cluster) GetBroadcasts(int, int) [][]byte + func (c *Cluster) LocalState(bool) []byte + func (c *Cluster) MergeRemoteState([]byte, bool) + func (c *Cluster) NodeMeta(int) []byte + func (c *Cluster) NotifyJoin(*memberlist.Node) + func (c *Cluster) NotifyLeave(*memberlist.Node) + func (c *Cluster) NotifyMsg([]byte) + func (c *Cluster) NotifyUpdate(*memberlist.Node) + func (c *Cluster) String() string + type ClusterConfig struct + AdvertiseAddr string + AdvertisePort int + BindAddr string + BindPort int + NodeName string + Seeds []string + type Config struct + Bind string + Buckets uint32 + MaxBatch int + MaxInFlight int + MaxOutbound int + MaxReplay int + Namespaces map[Namespace]NamespaceConfig + NodeID uint64 + RPCTimeout time.Duration + SweepEvery time.Duration + SweepLimit int + type FailurePolicy uint8 + const FailClosed + const LocalFallback + type Ghost struct + func New() *Ghost + func NewStore(maxEntries int, ttl time.Duration) *Ghost + func (g *Ghost) Add(key uint64, delta float64) + func (g *Ghost) Apply(ops []Operation) error + func (g *Ghost) Get(key uint64) float64 + func (g *Ghost) Len() int + func (g *Ghost) Load(_ Namespace, keys []uint64, dst []float64) error + func (g *Ghost) Sweep(now time.Time, maxPerShard int) int + type Namespace uint8 + const DefaultNamespace + type NamespaceConfig struct + Failure FailurePolicy + MaxEntries int + TTL time.Duration + type Operation struct + Delta float64 + Key uint64 + type Reservation struct + Epoch uint64 + Fallback bool + Namespace Namespace + NodeID uint64 + OpID uint64 + type Service struct + func NewService(cfg Config) *Service + func (s *Service) AcceptPolicy(ns Namespace, primary, backup uint64, epoch uint64, bucket uint32) bool + func (s *Service) Add(key uint64, delta float64) + func (s *Service) Addr() string + func (s *Service) Bucket(key uint64) uint32 + func (s *Service) Close() error + func (s *Service) Enabled() bool + func (s *Service) Get(key uint64) float64 + func (s *Service) Load(ns Namespace, keys []uint64, dst []float64) error + func (s *Service) LoadBatch(ns Namespace, keys []uint64, dst []float64, scratch *Batch) error + func (s *Service) Reserve(ns Namespace, ops []Operation) ([]Reservation, error) + func (s *Service) ReserveBatch(ns Namespace, ops []Operation, receipts []Reservation, scratch *Batch) error + func (s *Service) ReserveInto(ns Namespace, ops []Operation, receipts []Reservation) error + func (s *Service) SetPeers(peers map[uint64]string) + func (s *Service) SetPolicy(ns Namespace, primary, backup uint64, epoch uint64, bucket uint32) + func (s *Service) Settle(reservations []Reservation) error + func (s *Service) StartCluster(nodes map[uint64]string) error + func (s *Service) Stats() Stats + func (s *Service) Sweep(now time.Time, maxPerShard int) int + func (s *Service) Topology(ns Namespace) []TopologyBucket + func (s *Service) TransferBucket(ns Namespace, bucket uint32, target uint64, epoch uint64) error + type Stats struct + Entries int + FallbackEntries int + LoadErrors uint64 + NamespaceEntries map[Namespace]int + RPCTimeouts uint64 + ReplDropped uint64 + ReserveErrors uint64 + Swept uint64 + Transfers uint64 + type TopologyBucket struct + Backup uint64 + Epoch uint64 + Primary uint64