servicehelpers

package
v1.1.15 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2022 License: Unlicense Imports: 9 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Awaiter

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

Awaiter allows for the encapsulation of the data necessary to handle user-generated cancellations

func CancelOnInterrupt

func CancelOnInterrupt(ctx context.Context) (context.Context, *Awaiter)

CancelOnInterrupt ensures that the context cancels when the user-intercept signal is received from the standard input

func (*Awaiter) Stop

func (a *Awaiter) Stop()

Stop informs the OS that we no longer want to monitor the signal channel

type KettleContext

type KettleContext struct {
	Name        string
	Environment string
	Instance    *kettle2.Kettle
	Logger      *utils.Logger
	// contains filtered or unexported fields
}

KettleContext contains data that should be made available to the master function when it is instantiated from Kettle

func NewKettleContext

func NewKettleContext(serviceName string, environment string, expirationSeconds int,
	logger *utils.Logger) (*KettleContext, error)

NewKettleContext creates a new Kettle context that can be used to run a master function across multiple services

func (*KettleContext) Run

func (kCtx *KettleContext) Run(ctx context.Context, slave KettleFunction,
	keyers ...*Keyer) error

Run begins a master-slave operation where the master is automatically run by Kettle and the slave is operated manually

type KettleFunction

type KettleFunction func(context.Context) error

MasterFunction defines the type of function that will act as the master when Kettle elects this instance of a service as the master

type Keyer

type Keyer struct {
	Suffix    string
	Frequency time.Duration
	Operation KettleFunction
}

Keyer contains the data necessary to ensure that a given Kettle operation with the suffix runs at the desired frequency

func NewKeyer

func NewKeyer(suffix string, freq time.Duration, operation KettleFunction) *Keyer

NewKeyer creates a new Keyer from the suffix, frequency and kettle function

Jump to

Keyboard shortcuts

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