Documentation
¶
Overview ¶
Package memstore is an in-process implementation of leaderelection.Store.
It is the reference the acceptance suite validates itself against, and it is useful in an application's own tests: an election backed by memstore exercises the real leaderelection.Elector -- promotion, renewal, watchdog, fencing -- without a database.
It elects a leader among goroutines in one process only. Processes do not share it, so it is not a substitute for the postgres or mysql stores.
Index ¶
- type Option
- type Store
- func (s *Store) Acquire(ctx context.Context, name, identity string, ttl time.Duration, payload []byte) (leaderelection.Lease, error)
- func (s *Store) Inspect(ctx context.Context, name string) (leaderelection.Lease, error)
- func (s *Store) Release(ctx context.Context, name, identity string, fence int64) error
- func (s *Store) Renew(ctx context.Context, name, identity string, fence int64, ttl time.Duration, ...) (leaderelection.Lease, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store keeps leases in memory. The zero value is not usable; call New.
Being in-process, Store is its own clock authority, which is precisely the role the database plays for the real stores: every timestamp it reports, including Lease.Now, comes from the same source.
func (*Store) Acquire ¶
func (s *Store) Acquire(ctx context.Context, name, identity string, ttl time.Duration, payload []byte) (leaderelection.Lease, error)
Acquire implements leaderelection.Store.
func (*Store) Inspect ¶
Inspect implements leaderelection.Store.
func (*Store) Release ¶
Release implements leaderelection.Store.