Documentation ¶
Index ¶
- func New(client *clientv3.Client, id, key string, timeout time.Duration) (engine.Session, error)
- func NewEtcdStore(client *clientv3.Client) *engine.SessionStore
- func NewK8sStore(c *clientset.Clientset, namespace string) *engine.SessionStore
- func NewRedisStore(c redislock.RedisClient) *engine.SessionStore
- type EtcdEngine
- type EtcdSession
- func (e *EtcdSession) ID() string
- func (e *EtcdSession) IsLeader() bool
- func (e *EtcdSession) Key() string
- func (e *EtcdSession) Release(ctx context.Context) (err error)
- func (e *EtcdSession) Resign(ctx context.Context) error
- func (e *EtcdSession) SetLeaderChangeFn(fn engine.LeaderChangeFn)
- func (e *EtcdSession) Timeout() time.Duration
- type K8sEngine
- type K8sMutex
- func (mu *K8sMutex) ID() string
- func (mu *K8sMutex) IsLocked() bool
- func (mu *K8sMutex) Key() string
- func (mu *K8sMutex) Refresh(ctx context.Context, lease time.Duration) error
- func (mu *K8sMutex) Release(ctx context.Context) error
- func (mu *K8sMutex) Timeout() time.Duration
- func (mu *K8sMutex) TryLock(ctx context.Context) error
- type RedisEngine
- type RedisMutex
- func (mu *RedisMutex) ID() string
- func (mu *RedisMutex) IsLocked() bool
- func (mu *RedisMutex) Key() string
- func (mu *RedisMutex) Refresh(ctx context.Context, lease time.Duration) error
- func (mu *RedisMutex) Release(ctx context.Context) error
- func (mu *RedisMutex) Timeout() time.Duration
- func (mu *RedisMutex) TryLock(ctx context.Context) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewEtcdStore ¶
func NewEtcdStore(client *clientv3.Client) *engine.SessionStore
func NewK8sStore ¶
func NewK8sStore(c *clientset.Clientset, namespace string) *engine.SessionStore
func NewRedisStore ¶
func NewRedisStore(c redislock.RedisClient) *engine.SessionStore
NewRedisStore creates a new Redis session store.
Types ¶
type EtcdEngine ¶
type EtcdEngine struct {
// contains filtered or unexported fields
}
func NewEtcdEngine ¶
func NewEtcdEngine(client *clientv3.Client) *EtcdEngine
type EtcdSession ¶
type EtcdSession struct {
// contains filtered or unexported fields
}
func (*EtcdSession) ID ¶
func (e *EtcdSession) ID() string
func (*EtcdSession) IsLeader ¶
func (e *EtcdSession) IsLeader() bool
func (*EtcdSession) Key ¶
func (e *EtcdSession) Key() string
func (*EtcdSession) SetLeaderChangeFn ¶
func (e *EtcdSession) SetLeaderChangeFn(fn engine.LeaderChangeFn)
func (*EtcdSession) Timeout ¶
func (e *EtcdSession) Timeout() time.Duration
type K8sMutex ¶
type K8sMutex struct {
// contains filtered or unexported fields
}
func NewK8sMutex ¶
type RedisEngine ¶
type RedisEngine struct {
// contains filtered or unexported fields
}
RedisEngine implements engine.SessionClient, it's used to create a new Redis session.
type RedisMutex ¶
type RedisMutex struct {
// contains filtered or unexported fields
}
RedisMutex implements engine.Mutex, it uses redislock to implement distributed mutex.
func NewRedisMutex ¶
NewRedisMutex creates a new RedisMutex instance.
func (*RedisMutex) IsLocked ¶
func (mu *RedisMutex) IsLocked() bool
IsLocked returns true if the Redis mutex is locked.
func (*RedisMutex) Refresh ¶
Refresh refreshes the Redis lock. It will return ErrNotLockHolder if the Redis lock is not held.
func (*RedisMutex) Release ¶
func (mu *RedisMutex) Release(ctx context.Context) error
Release releases the Redis lock. It will return ErrNotLockHolder if the Redis lock is not held.
func (*RedisMutex) Timeout ¶
func (mu *RedisMutex) Timeout() time.Duration
Timeout returns the timeout of the Redis mutex. It's used to set the timeout of the Redis lock.
Click to show internal directories.
Click to hide internal directories.