ddb

package
v0.15.1 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LeaderElectionTypeDdb    = "ddb"
	LeaderElectionTypeStatic = "static"
)

Variables

This section is empty.

Functions

func GetLeaderElectionConfigKey

func GetLeaderElectionConfigKey(name string) string

func GetLeaderElectionConfigKeyType

func GetLeaderElectionConfigKeyType(name string) string

func NewDdbLockProvider

func NewDdbLockProvider(ctx context.Context, config cfg.Config, logger log.Logger, settings conc.DistributedLockSettings) (conc.DistributedLockProvider, error)

func NewDdbLockProviderWithInterfaces

func NewDdbLockProviderWithInterfaces(
	logger log.Logger,
	repo ddb.Repository,
	backOff backoff.BackOff,
	clock clock.Clock,
	uuidSource uuid.Uuid,
	settings conc.DistributedLockSettings,
) conc.DistributedLockProvider

Types

type DdbLeaderElection

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

func NewDdbLeaderElectionWithInterfaces

func NewDdbLeaderElectionWithInterfaces(logger log.Logger, clock clock.Clock, repository ddb.Repository, settings *DdbLeaderElectionSettings) (*DdbLeaderElection, error)

func (*DdbLeaderElection) IsLeader

func (e *DdbLeaderElection) IsLeader(ctx context.Context, memberId string) (bool, error)

func (*DdbLeaderElection) Resign

func (e *DdbLeaderElection) Resign(ctx context.Context, memberId string) error

type DdbLeaderElectionItem

type DdbLeaderElectionItem struct {
	GroupId      string `json:"groupId" ddb:"key=hash"`
	MemberId     string `json:"memberId"`
	LeadingUntil int64  `json:"leadingUntil" ddb:"ttl=enabled"`
}

type DdbLeaderElectionSettings

type DdbLeaderElectionSettings struct {
	Naming        TableNamingSettings `cfg:"naming"`
	ClientName    string              `cfg:"client_name" default:"default"`
	GroupId       string              `cfg:"group_id" default:"{app_name}"`
	LeaseDuration time.Duration       `cfg:"lease_duration" default:"1m"`
}

type DdbLockItem

type DdbLockItem struct {
	// unique name of the locked resource
	Resource string `json:"resource" ddb:"key=hash"`
	// token to ensure we are releasing a lock we own
	Token string `json:"token"`
	// ttl until the lock should be released automatically
	Ttl int64 `json:"ttl" ddb:"ttl=enabled"`
}

type LeaderElection

type LeaderElection interface {
	IsLeader(ctx context.Context, memberId string) (bool, error)
	Resign(ctx context.Context, memberId string) error
}

func NewDdbLeaderElection

func NewDdbLeaderElection(ctx context.Context, config cfg.Config, logger log.Logger, name string) (LeaderElection, error)

func NewDdbLeaderElectionWithSettings

func NewDdbLeaderElectionWithSettings(ctx context.Context, config cfg.Config, logger log.Logger, settings *DdbLeaderElectionSettings) (LeaderElection, error)

func NewLeaderElection

func NewLeaderElection(ctx context.Context, config cfg.Config, logger log.Logger, name string) (LeaderElection, error)

func NewStaticLeaderElection

func NewStaticLeaderElection(_ context.Context, config cfg.Config, _ log.Logger, name string) (LeaderElection, error)

type LeaderElectionFactory

type LeaderElectionFactory func(ctx context.Context, config cfg.Config, logger log.Logger, name string) (LeaderElection, error)

type StaticLeaderElection

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

func NewStaticLeaderElectionWithSettings

func NewStaticLeaderElectionWithSettings(settings *StaticLeaderElectionSettings) (*StaticLeaderElection, error)

func (StaticLeaderElection) IsLeader

func (StaticLeaderElection) Resign

type StaticLeaderElectionSettings

type StaticLeaderElectionSettings struct {
	Result bool `cfg:"result"`
}

type TableNamingSettings

type TableNamingSettings struct {
	Pattern string `cfg:"pattern,nodecode" default:"{project}-{env}-{family}-leader-elections"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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