workers

package
v1.4.4 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2025 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package workers exposes backend interfaces used by worker groups.

Package workers provides common backend interfaces that worker services use to perform their jobs against the storage/map/LRU layers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Enabled  bool
	Interval time.Duration
}

type EvictionBackend

type EvictionBackend interface {
	Len() int64
	Mem() int64
	ShouldEvict() (bytes int64, should bool)
	EvictN(n int) (freedBytes, items int64)
}

type EvictorWorker

type EvictorWorker interface {
	// SampleVictims returns up to SxK candidate keys/ids for eviction
	// (already pre-filtered by shard sampling). Implementation must be allocation‑lean.
	SampleVictims(S, K int) []uint64
	// Remove removes a single key. Must revalidate under shard lock internally.
	// Returns freed bytes and whether an item was actually removed.
	Remove(key uint64) (freedBytes int64, removed bool)
}

EvictorWorker exposes victim sampling and removal operations.

type LoggerWorker

type LoggerWorker interface {
	Metrics() service.Metrics
	Logs() <-chan service.ServiceLog
}

type MetricsWorker

type MetricsWorker interface {
	SnapshotMetrics() map[string]float64
}

MetricsWorker exposes a cheap metrics snapshot API.

type RefreshBackend

type RefreshBackend interface {
	ScanOutdated() ([64]*model.Entry, bool)
	Refresh(entry *model.Entry) error
}

type RefresherWorker

type RefresherWorker interface {
	// ScanOutdated returns 64 keys that are due for refresh.
	ScanOutdated() ([64]*model.Entry, bool)
	// Refresh fetches the value for a key and atomically swaps it in.
	Refresh(entry *model.Entry) error
}

RefresherWorker exposes scan/refresh operations.

Directories

Path Synopsis
Package evictor provides a scalable worker Group implementing service.Service and service.Scalable.
Package evictor provides a scalable worker Group implementing service.Service and service.Scalable.
Package logger provides a scalable worker Group implementing service.Service and service.Scalable.
Package logger provides a scalable worker Group implementing service.Service and service.Scalable.
Package meter provides a scalable worker Group implementing service.Service and service.Scalable.
Package meter provides a scalable worker Group implementing service.Service and service.Scalable.
Package refresher provides a scalable worker Group implementing service.Service and service.Scalable.
Package refresher provides a scalable worker Group implementing service.Service and service.Scalable.

Jump to

Keyboard shortcuts

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