poller

package
v0.0.0-...-7fb09d6 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2024 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Poll

func Poll(ctx context.Context, opts Options) error

Poll invokes a function repeatedly at a specified interval. The operation is stopped when the provided context is canceled.

Types

type Options

type Options struct {
	Logger *zap.Logger

	// Function invoked to poll (required).
	Poll func(context.Context)

	// Determines the amount of time to sleep before the next poll (required).
	NextDelay func() time.Duration

	// Minimum amount of time to wait between polls. Defaults to 1s.
	MinDelay time.Duration

	// Maximum amount of time to wait between polls.
	MaxDelay time.Duration

	// Amount of random distortion to apply to the calculated delay. Must be in
	// the range [0..+1.0] (0% to 100%).
	Jitter float64

	// Optional channel receiving a message when a new poll is requested.
	Notify <-chan struct{}
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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