negotiate

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CompletedDelegate

type CompletedDelegate[T any] func([]T, error) error

type InputDelegate

type InputDelegate[T any] func() ([]T, error)

type OutputDelegate

type OutputDelegate[T any] func(i T) error

type SyncJob

type SyncJob[T any] struct {
	SyncJobOptions[T]
	// contains filtered or unexported fields
}

func NewSyncJob

func NewSyncJob[T any](options SyncJobOptions[T]) *SyncJob[T]

func NewSyncJobWithMetrics

func NewSyncJobWithMetrics[T any](job *SyncJob[T], r prometheus.Registerer) *SyncJob[T]

NewSyncJobWithMetrics instruments an existing SyncJob with Prometheus histograms and returns the same job instance. It wraps the job's delegates to record durations.

Metrics exported (metric names use the job Name with hyphens/spaces replaced by underscores): - <name>_sync_run_seconds{job, status}: duration per full sync run (from InputDelegate to CompletedDelegate) - <name>_sync_item_seconds{job, status}: duration per processed item T (around OutputDelegate)

func (*SyncJob[T]) Name

func (s *SyncJob[T]) Name() string

func (*SyncJob[T]) Start

func (s *SyncJob[T]) Start() <-chan error

func (*SyncJob[T]) Stop

func (s *SyncJob[T]) Stop()

func (*SyncJob[T]) WithMetrics

func (s *SyncJob[T]) WithMetrics(r prometheus.Registerer) *SyncJob[T]

type SyncJobOptions

type SyncJobOptions[T any] struct {
	NumWorkers          int
	InputDelegate       InputDelegate[T]
	OutputDelegate      threading.Handler[T]
	CompletedDelegate   CompletedDelegate[T]
	ErrorCallback       threading.ErrorCallback[T]
	SyncInterval        time.Duration
	CronSchedule        string
	NextRunDelegate     func() time.Time
	BufferSize          int
	Name                string
	Elector             leaderElection.Elector
	RetryPolicy         threading.RetryPolicy
	MaxRetries          int
	RetryAfterDuration  time.Duration
	OnLeadershipLost    func() // Called when transitioning from leader to non-leader
	FirstRunImmediately bool   // If true, run immediately on startup, otherwise wait for SyncInterval or CronSchedule
}

Jump to

Keyboard shortcuts

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