mongo_leader

package
v0.0.0-...-ba64992 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ElectionResult

type ElectionResult struct {
	MyRole       Role
	LeaderPeerId string
}

type LeaderDocument

type LeaderDocument struct {
	Id          primitive.ObjectID `bson:"_id,omitempty"`
	Key         string             `bson:"key"`
	PeerId      string             `bson:"peerId"`
	HeartbeatAt time.Time          `bson:"heartbeatAt"`
}

type LeaderElection

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

func New

func New() *LeaderElection

func (*LeaderElection) AddNotify

func (l *LeaderElection) AddNotify(fn NotifyFunc)

func (*LeaderElection) Start

func (l *LeaderElection) Start(mongoDatabase *mongo.Database, collectionName string, key string, peerId string) error

func (*LeaderElection) Stop

func (l *LeaderElection) Stop()

type NotifyFunc

type NotifyFunc func(result ElectionResult)

type Role

type Role string
const (
	RoleLeader   Role = "leader"
	RoleFollower Role = "follower"
)

Jump to

Keyboard shortcuts

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