dbleader

package module
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

README

DBLeader

A simple continuous leader election library for Go.

Go Version

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/shivanshvij/dbleader. For more contribution information check out the contribution guide.

License

This project is available as open source under the terms of the Apache License, Version 2.0.

Code of Conduct

Everyone interacting in this project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the CNCF Code of Conduct.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidOptions       = errors.New("invalid options")
	ErrInvalidDBLockOptions = errors.New("invalid dblock options")
	ErrCreatingDBLock       = errors.New("error creating dblock")
	ErrStarting             = errors.New("error starting dbleader")
	ErrAlreadyStopped       = errors.New("dbleader already stopped")
	ErrStopping             = errors.New("error stopping dbleader")
)
View Source
var (
	ErrInvalidName                  = errors.New("invalid name")
	ErrInvalidNamespace             = errors.New("invalid namespace")
	ErrInvalidDBType                = errors.New("invalid database type")
	ErrInvalidDatabaseURL           = errors.New("invalid database URL")
	ErrInvalidLeaseDuration         = errors.New("invalid lease duration")
	ErrInvalidLeaseRefreshFrequency = errors.New("invalid lease refresh frequency")
)

Functions

This section is empty.

Types

type DBLeader

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

func New

func New(options *Options) (*DBLeader, error)

func (*DBLeader) Leader

func (db *DBLeader) Leader() (string, error)

func (*DBLeader) Start

func (db *DBLeader) Start() error

func (*DBLeader) Stop

func (db *DBLeader) Stop() error

func (*DBLeader) Subscribe

func (db *DBLeader) Subscribe() <-chan IsLeaderKind

func (*DBLeader) Unsubscribe

func (db *DBLeader) Unsubscribe(ch <-chan IsLeaderKind)

type DBType added in v0.1.1

type DBType int
const (
	Undefined DBType = iota
	Postgres
	SQLite
)

type IsLeaderKind

type IsLeaderKind bool
const (
	IsLeader    IsLeaderKind = true
	IsNotLeader IsLeaderKind = false
)

type Options

type Options struct {
	Logger                types.Logger
	Name                  string
	Namespace             string
	DBType                DBType
	DatabaseURL           string
	LeaseDuration         time.Duration
	LeaseRefreshFrequency time.Duration
}

func (*Options) Validate

func (o *Options) Validate() error

Directories

Path Synopsis
pkg

Jump to

Keyboard shortcuts

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