Documentation ¶
Overview ¶
Package natslock provides locking and leader election using NATS JetStream KV store
Index ¶
Constants ¶
View Source
const DefaultKeyName = "leader"
DefaultKeyName is the key name used for the lock
Variables ¶
View Source
var ErrBadParameter = errors.New("bad parameters in request")
ErrBadParameter is returned when bad parameters are passed to a request
Functions ¶
Types ¶
type Locker ¶
Locker is a distributed lock backed by a JetStream key-value store
func (*Locker) AcquireLead ¶
AcquireLead attempts to acquire the leader lock returns true if successful. If the lock is already held by another id, it will return false.
func (*Locker) ReleaseLead ¶
ReleaseLead releases the leader lock if it's held by this id
Click to show internal directories.
Click to hide internal directories.