Documentation
¶
Index ¶
- func NewRedisLock(name string, opts ...RedisLockOption) *rlock
- func NewRedisPool(host string, opts ...RedisPoolOption) *redis.Pool
- type K8sLock
- type K8sLockOption
- func WithK8sClient(c *kubernetes.Clientset) K8sLockOption
- func WithLeaseDuration(v time.Duration) K8sLockOption
- func WithNamespace(v string) K8sLockOption
- func WithNewLeaderCallback(v func(string)) K8sLockOption
- func WithRenewDeadline(v time.Duration) K8sLockOption
- func WithRetryPeriod(v time.Duration) K8sLockOption
- func WithStartCallback(v func(context.Context)) K8sLockOption
- type Locker
- type RedisLockOption
- type RedisPoolOption
- type SpindleLock
- type SpindleLockOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewRedisLock ¶
func NewRedisLock(name string, opts ...RedisLockOption) *rlock
NewRedisLock creates an object that can be used to acquire/release a lock using Redis. This is built on top of redsync with the addition of context and implementing the Locker interface.
func NewRedisPool ¶
func NewRedisPool(host string, opts ...RedisPoolOption) *redis.Pool
RedisPool returns a connection pool for Redis.
Types ¶
type K8sLock ¶
type K8sLock struct {
// contains filtered or unexported fields
}
func NewK8sLock ¶
func NewK8sLock(id, name string, opts ...K8sLockOption) *K8sLock
NewK8sLock returns an object that can be used to acquire/release a lock using k8s' LeaseLock resource object. id is the locker's unique identity displayed as the HOLDER when you do kubectl get lease. name is the LeaseLock resource name. When not set, it will use the default namespace.
type K8sLockOption ¶
type K8sLockOption interface {
Apply(*K8sLock)
}
func WithK8sClient ¶
func WithK8sClient(c *kubernetes.Clientset) K8sLockOption
WithK8sClient provides an option to set a k8s client object.
func WithLeaseDuration ¶
func WithLeaseDuration(v time.Duration) K8sLockOption
WithLeaseDuration provides an option to set the lease duration.
func WithNamespace ¶
func WithNamespace(v string) K8sLockOption
WithNamespace provides an option to set the namespace value.
func WithNewLeaderCallback ¶
func WithNewLeaderCallback(v func(string)) K8sLockOption
WithNewLeaderCallback provides an option to set a callback when new lock is acquired.
func WithRenewDeadline ¶
func WithRenewDeadline(v time.Duration) K8sLockOption
WithRenewDeadline provides an option to set the renew deadline.
func WithRetryPeriod ¶
func WithRetryPeriod(v time.Duration) K8sLockOption
WithRetryPeriod provides an option to set the renew deadline.
func WithStartCallback ¶
func WithStartCallback(v func(context.Context)) K8sLockOption
WithStartCallback provides an option to set a callback after we acquired the new lock.
type RedisLockOption ¶
type RedisLockOption interface {
Apply(*rlock)
}
func WithExtendAfter ¶
func WithExtendAfter(v time.Duration) RedisLockOption
WithExtendAfter provides an option to set the duration before extending the lock.
func WithHost ¶
func WithHost(v string) RedisLockOption
WithHost provides an option to set a single Redis host for the lock.
func WithHosts ¶
func WithHosts(v []string) RedisLockOption
WithHosts provides an option to set a list of Redis hosts for the lock.
func WithPools ¶
func WithPools(v []*redis.Pool) RedisLockOption
WithPools provides an option to set a list of Redis pools for the lock.
func WithRedsyncOptions ¶ added in v0.2.0
func WithRedsyncOptions(v []redsync.Option) RedisLockOption
WithRedsyncOptions provides an option to set additional options to the underlying redsync Mutex.
type RedisPoolOption ¶
type RedisPoolOption interface {
Apply(*rpool)
}
func WithPassword ¶
func WithPassword(v string) RedisPoolOption
WithPassword provides an option to set a password to a Redis pool.
func WithTimeout ¶
func WithTimeout(v time.Duration) RedisPoolOption
WithTimeout provides an option to set a timeout to a Redis pool.
type SpindleLock ¶ added in v0.5.0
type SpindleLock struct {
// contains filtered or unexported fields
}
func NewSpindleLock ¶ added in v0.5.0
func NewSpindleLock(opts *SpindleLockOptions) *SpindleLock
func (*SpindleLock) Unlock ¶ added in v0.5.0
func (l *SpindleLock) Unlock() error