services

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2024 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExponentialBackoff

func ExponentialBackoff(d time.Duration) time.Duration

ExponentialBackoff transforms a time.Duration to the next time.Duration using exponential backoff.

func Start

func Start(name string, config *Config)

Types

type Args

type Args struct {
	Logger *slog.Logger
}

type Config

type Config struct {
	// Service is an instance of the service.
	Service Service

	// StartDelay is the delay before starting the service.
	StartDelay time.Duration

	// RunInterval is the interval between runs.
	RunInterval time.Duration

	// RunIntervalFunc is a function that returns the interval between runs. It takes precedence
	// over RunInterval.
	RunIntervalFunc func() time.Duration

	// Enabled is a function that returns whether or not the service is currently enabled.
	Enabled func() bool

	// InitialRestartInterval is the initial restart interval.
	InitialRestartInterval time.Duration

	// NextRestartInterval is a function that receives the last restart interval and returns the
	// next one.
	NextRestartInterval func(time.Duration) time.Duration

	// Quiet indicates whether service start and finish should be logged.
	Quiet bool
}

type Service

type Service interface {
	// Init initialises the service and returns an error if init failed. If an error is returned
	// then the service will not run.
	Init(args *Args) error

	// Run runs the service and returns an error for an unrecoverable failure.
	Run() error
}

Directories

Path Synopsis
Package notifier batches up and sends out pending notifications.
Package notifier batches up and sends out pending notifications.
Package watcher watches for devices whose state has changed.
Package watcher watches for devices whose state has changed.

Jump to

Keyboard shortcuts

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