cron

package
v0.4.4 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2025 License: MIT Imports: 18 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(opts Options) (api.Interface, error)

New creates a new cron instance.

Types

type Options

type Options struct {
	// Log is the logger to use for logging.
	Log logr.Logger

	// Client is the etcd client to use for storing cron entries.
	Client *clientv3.Client

	// Namespace is the etcd namespace to use for storing cron entries.
	Namespace string

	// ID is the unique ID which is associated with this replica. Duplicate IDs
	// will cause only one random replica to be active, with the rest being
	// dormant.
	ID string

	// TriggerFn is the function to call when a cron job is triggered.
	TriggerFn api.TriggerFunction

	// CounterGarbageCollectionInterval is the interval at which to run the
	// garbage collection for counters is run. Counters are also garbage
	// collected on shutdown. Counters are batch deleted, so a larger value
	// increases the counter bucket and reduces the number of database
	// operations.
	// This value rarely needs to be set and is mostly used for testing. A small
	// interval value will increase database operations and thus degrade cron
	// performance.
	// Defaults to 180 seconds.
	CounterGarbageCollectionInterval *time.Duration

	// ReplicaData is custom data associated with the replica, for example,
	// host + port for the active replica. This data will be written to the
	// leadership keyspace, with the latest cluster values being returned from
	// `WatchLeadership`. Useful for consumer coordination.
	ReplicaData *anypb.Any

	// WatchLeadership is an optional channel that will be written with all
	// leader replica data every time there is leadership quorum. Useful for
	// consumer coordination. Failing to read from this channel will cause the
	// replica to fail to start the cron engine.
	WatchLeadership chan<- []*anypb.Any
}

Options are the options for creating a new cron instance.

Jump to

Keyboard shortcuts

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