consul

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultKeyPrefix = "widelock/"

Variables

This section is empty.

Functions

func New

func New(client *api.Client, opts ...widelock.OptionSet) (widelock.MutexSet, error)

func WithDeleteKey

func WithDeleteKey() widelock.OptionSet

WithDeleteKey create a Set option to specify behavior to delete key of unlocked locker and all keys in Set after closed. This would slightly increase load of unlock, but if the locker would be used only once in most cases, enable this is helpful to reduce memory usage of Consul server.

func WithDuration

func WithDuration(d time.Duration) widelock.Option

WithDuration set duration for sustaining the lock. It start from lock really obtained.

func WithExpiry

func WithExpiry(e time.Time) widelock.Option

WithExpiry set expiry for lock. It would be covered by duration if set.

func WithKeyPrefix

func WithKeyPrefix(prefix string) widelock.OptionSet

WithKeyPrefix create a Set option to set the prefix of key of Consul. Default is `widelock:`

func WithLostNotify

func WithLostNotify(ch chan<- struct{}) widelock.Option

Types

type Set

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

func (*Set) Cleanup

func (s *Set) Cleanup() error

Cleanup cleanup all the locks with the same prefix in Set, no matter it is held or not, even by another Set. This may useful when you want to remove all the associate keys in Consul.

func (*Set) Close

func (s *Set) Close() error

func (*Set) NewMutex

func (s *Set) NewMutex(name string, opts ...widelock.Option) widelock.Mutex

Jump to

Keyboard shortcuts

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