leader

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Leader

type Leader interface {
	Start()
	Stop() error
	IsLeading() bool
}

func NewLeader

func NewLeader(opts Opts) (leader Leader, onPromote <-chan time.Time, onDemote <-chan time.Time, onError <-chan error)

type Opts

type Opts struct {
	Redis    RedisCompatible
	TTL      time.Duration
	Wait     time.Duration
	JitterMS int
	Key      string
}

type RedisCompatible

type RedisCompatible interface {
	Get(ctx context.Context, key string) *redis.StringCmd
	EvalSha(ctx context.Context, sha string, keys []string, args ...any) *redis.Cmd
	ScriptLoad(ctx context.Context, script string) *redis.StringCmd
}

Jump to

Keyboard shortcuts

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