worker

package
v0.1.0-beta.1 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2026 License: Apache-2.0 Imports: 38 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Evictor

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

Evictor claims cache eviction tasks and removes remotely durable objects according to the configured policy.

func NewEvictor

func NewEvictor(
	repos *repository.Repositories,
	c cache.Cache,
	cacheGate *cacheaccess.Gate,
	cacheAccessTracker *cacheaccess.Tracker,
	sm *state.Machine,
	concurrency int,
	pollInterval time.Duration,
	logger *slog.Logger,
	opts ...EvictorOption,
) *Evictor

NewEvictor creates a new cache evictor worker.

func (*Evictor) Healthy

func (e *Evictor) Healthy() bool

Healthy returns true if the worker has ticked recently.

func (*Evictor) Name

func (e *Evictor) Name() string

func (*Evictor) Run

func (e *Evictor) Run(ctx context.Context) error

type EvictorOption

type EvictorOption func(*Evictor)

EvictorOption configures cache eviction behavior.

func WithCacheEvictionPolicy

func WithCacheEvictionPolicy(
	policy cache.EvictionPolicy,
	maxCacheBytes int64,
	highWatermarkPercent int,
	lowWatermarkPercent int,
	maxRetries int,
) EvictorOption

WithCacheEvictionPolicy configures the eviction strategy and LRU capacity thresholds. The thresholds are ignored outside LRU mode.

type Manager

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

Manager coordinates the lifecycle of all background workers.

func NewManager

func NewManager(repos *repository.Repositories, logger *slog.Logger, evictionPolicy cache.EvictionPolicy, workers ...Worker) *Manager

NewManager creates a new worker manager.

func (*Manager) Start

func (m *Manager) Start(ctx context.Context)

Start launches all registered workers and blocks until ctx is cancelled.

func (*Manager) WithProviderReplacementRecovery

func (m *Manager) WithProviderReplacementRecovery(maxRetries int, retryInterval time.Duration) *Manager

WithProviderReplacementRecovery configures provider replacement startup recovery.

func (*Manager) WithTaskMaxRetries

func (m *Manager) WithTaskMaxRetries(uploadMaxRetries, evictMaxRetries int) *Manager

WithTaskMaxRetries configures max retries for tasks recreated during startup reconciliation.

func (*Manager) WorkerHealth

func (m *Manager) WorkerHealth() map[string]bool

WorkerHealth returns a map of worker name → healthy status.

type ProviderReplacementWorker

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

ProviderReplacementWorker processes provider replacement items.

func NewProviderReplacementWorker

func NewProviderReplacementWorker(
	repos *repository.Repositories,
	uploadSupport *Uploader,
	concurrency int,
	pollInterval time.Duration,
	logger *slog.Logger,
) *ProviderReplacementWorker

func (*ProviderReplacementWorker) Healthy

func (w *ProviderReplacementWorker) Healthy() bool

func (*ProviderReplacementWorker) Name

func (*ProviderReplacementWorker) Run

type ReplacementTransferExecutor

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

ReplacementTransferExecutor processes one claimed replacement item.

func NewReplacementTransferExecutor

func NewReplacementTransferExecutor(
	repos *repository.Repositories,
	uploadSupport *Uploader,
	registry *replacementTargetContextRegistry,
	logger *slog.Logger,
) *ReplacementTransferExecutor

func (*ReplacementTransferExecutor) Execute

type StorageCleanupOption

type StorageCleanupOption func(*StorageCleanupWorker)

StorageCleanupOption configures optional cleanup dependencies.

func WithServiceTermination

func WithServiceTermination(terminator synapse.ServiceTerminator, epochs synapse.ChainEpochReader) StorageCleanupOption

WithServiceTermination enables provider replacement retirement. Without it the worker still removes pieces but refuses to end any service.

type StorageCleanupWorker

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

func NewStorageCleanupWorker

func NewStorageCleanupWorker(repos *repository.Repositories, storageClient synapse.StorageClient, concurrency int, pollInterval time.Duration, logger *slog.Logger, opts ...StorageCleanupOption) *StorageCleanupWorker

func (*StorageCleanupWorker) Healthy

func (w *StorageCleanupWorker) Healthy() bool

func (*StorageCleanupWorker) Name

func (w *StorageCleanupWorker) Name() string

func (*StorageCleanupWorker) Run

type Uploader

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

Uploader claims upload tasks, persists upload provenance, and accepts complete uploads for object versions.

func NewUploader

func NewUploader(repos *repository.Repositories, c cache.Cache, sc synapse.StorageClient, wallet synapse.WalletQuerier, sm *state.Machine, evictionPolicy cache.EvictionPolicy, targetCopies int, concurrency int, pollInterval time.Duration, logger *slog.Logger, opts ...UploaderOption) *Uploader

NewUploader creates a new upload worker.

func (*Uploader) Healthy

func (u *Uploader) Healthy() bool

Healthy returns true if the worker has ticked recently.

func (*Uploader) Name

func (u *Uploader) Name() string

func (*Uploader) Run

func (u *Uploader) Run(ctx context.Context) error

type UploaderOption

type UploaderOption func(*Uploader)

UploaderOption configures uploader behavior.

func WithEventPublisher

func WithEventPublisher(publisher admin.EventPublisher) UploaderOption

func WithEvictMaxRetries

func WithEvictMaxRetries(maxRetries int) UploaderOption

WithEvictMaxRetries configures max retries for cache eviction tasks created after upload.

func WithPDPStatusChecker

func WithPDPStatusChecker(checker *synapse.PDPStatusChecker) UploaderOption

WithPDPStatusChecker configures the client used to resume submitted commits.

func WithProviderReplacementMaxRetries

func WithProviderReplacementMaxRetries(maxRetries int) UploaderOption

WithProviderReplacementMaxRetries sets the provider replacement retry limit.

type WalletOperationRunner

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

func NewWalletOperationRunner

func NewWalletOperationRunner(
	repos *repository.Repositories,
	operator synapse.WalletOperator,
	receipts WalletReceiptChecker,
	pollInterval time.Duration,
	logger *slog.Logger,
	opts ...WalletOperationRunnerOption,
) *WalletOperationRunner

func (*WalletOperationRunner) Healthy

func (r *WalletOperationRunner) Healthy() bool

func (*WalletOperationRunner) Name

func (r *WalletOperationRunner) Name() string

func (*WalletOperationRunner) Run

type WalletOperationRunnerOption

type WalletOperationRunnerOption func(*WalletOperationRunner)

func WithWalletOperationEventPublisher

func WithWalletOperationEventPublisher(publisher admin.EventPublisher) WalletOperationRunnerOption

func WithWalletOperationTimeouts

func WithWalletOperationTimeouts(broadcast, receipt time.Duration) WalletOperationRunnerOption

type WalletReceiptChecker

type WalletReceiptChecker interface {
	TransactionReceipt(ctx context.Context, txHash common.Hash) (*ethtypes.Receipt, error)
}

type Worker

type Worker interface {
	// Name returns a human-readable identifier.
	Name() string
	// Run starts the worker loop; it should block until ctx is cancelled.
	Run(ctx context.Context) error
	// Healthy returns true if the worker has ticked recently.
	Healthy() bool
}

Worker defines a background processing unit.

Jump to

Keyboard shortcuts

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