Documentation ¶
Index ¶
Constants ¶
View Source
const ( // DefaultRetryCount is the max retry times for lock acquire DefaultRetryCount = 10 // DefaultRetryDelay is upper wait time in millisecond for lock acquire retry DefaultRetryDelay = 200 // ClockDriftFactor is clock drift factor, more information refers to doc ClockDriftFactor = 0.01 // UnlockScript is redis lua script to release a lock UnlockScript = `` /* 155-byte string literal not displayed */ )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ActiveChecker ¶
type ActiveChecker interface { // Start access to slice of Redis hosts, trying to set lock during provided period using Redlock algorithm Start(RedLocker, time.Duration) (bool, error) IsActive() bool SetActive() SetPassive() // Keepalive for active instance updates lock's expiration Keepalive() error GetValue() string }
ActiveChecker trying to lock active mode on Start(), then Keepalive() lock while active
func NewActiveCheck ¶
func NewActiveCheck(lockKey string) ActiveChecker
NewActiveCheck instantiates ActiveChecker
type AddressListFlags ¶
type AddressListFlags []string
func (*AddressListFlags) Set ¶
func (alf *AddressListFlags) Set(s string) error
func (*AddressListFlags) String ¶
func (alf *AddressListFlags) String() string
type RedClient ¶
type RedClient struct {
// contains filtered or unexported fields
}
RedClient holds client to redis
type RedLock ¶
type RedLock struct {
// contains filtered or unexported fields
}
RedLock holds the redis lock
func (*RedLock) ExpireLock ¶
ExpireLock changes distributed lock expiration
func (*RedLock) SetRetryCount ¶
SetRetryCount sets acquire lock retry count
func (*RedLock) SetRetryDelay ¶
SetRetryDelay sets acquire lock retry max internal in millisecond
type RedLocker ¶
type RedLocker interface { // Lock acquires lock for specified resource and period in ms, returns assigned value Lock(resource string, period int64) (string, error) // ExpireLock changes expiration for resource with value to new period in ms, returns remained period ExpireLock(resource, value string, period int64) (int64, error) // SetRetryCount updates acquire lock attempts count SetRetryCount(int) // SetRetryDelay updates retry delays in milliseconds between acquire lock attempts SetRetryDelay(int) }
RedLocker interface to implement Reddlock
Click to show internal directories.
Click to hide internal directories.