kettle

package module
v2.4.4 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2023 License: MIT Imports: 10 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRedisPool

func NewRedisPool() (*redis.Pool, error)

Types

type DistLocker

type DistLocker interface {
	Lock() error
	Unlock() (bool, error)
}

DistLocker abstracts a distributed locker.

type Kettle

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

Kettle provides functions that abstract the master election of a group of workers at a given interval time.

func New

func New(opts ...KettleOption) (*Kettle, error)

New returns an instance of Kettle.

func (Kettle) IsMaster

func (k Kettle) IsMaster() bool

IsMaster returns master status.

func (Kettle) IsVerbose

func (k Kettle) IsVerbose() bool

IsVerbose returns the verbosity setting.

func (Kettle) Name

func (k Kettle) Name() string

Name returns the instance's name.

func (Kettle) NodeName added in v2.4.1

func (k Kettle) NodeName() string

Name returns the node's unique name.

func (Kettle) Pool

func (k Kettle) Pool() *redis.Pool

Pool returns the configured Redis connection pool.

func (*Kettle) Start

func (k *Kettle) Start(ctx context.Context, in *StartInput, done ...chan error) error

Start starts Kettle's main function. The ctx parameter is mainly used for termination with an optional done channel for us to notify when we are done, if any.

type KettleOption

type KettleOption interface {
	Apply(*Kettle)
}

KettleOption configures Kettle.

func WithDistLocker

func WithDistLocker(v DistLocker) KettleOption

WithDistLocker configures a Kettle instance's DistLocker.

func WithLogger added in v2.2.0

func WithLogger(v *log.Logger) KettleOption

WithLogger sets the logger option.

func WithName

func WithName(v string) KettleOption

WithName configures Kettle instance's name.

func WithNodeName added in v2.3.0

func WithNodeName(v string) KettleOption

WithName configures Kettle instance's name.

func WithTickTime

func WithTickTime(v int64) KettleOption

WithTickTime configures a Kettle instance's tick timer in seconds.

func WithVerbose

func WithVerbose(v bool) KettleOption

WithVerbose configures a Kettle instance's log verbosity.

type StartInput

type StartInput struct {
	Master    func(ctx interface{}) error // function to call every time we are master
	MasterCtx interface{}                 // callback function parameter
}

StartInput configures the Start function.

Jump to

Keyboard shortcuts

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