store

package
v0.0.0-...-2ff72f1 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(client *clientv3.Client, id, key string, timeout time.Duration) (engine.Session, error)

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

func (*EtcdEngine) Create

func (e *EtcdEngine) Create(ctx context.Context, id, key string, timeout time.Duration) (engine.Session, error)

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) Release

func (e *EtcdSession) Release(ctx context.Context) (err error)

func (*EtcdSession) Resign

func (e *EtcdSession) Resign(ctx context.Context) error

func (*EtcdSession) SetLeaderChangeFn

func (e *EtcdSession) SetLeaderChangeFn(fn engine.LeaderChangeFn)

func (*EtcdSession) Timeout

func (e *EtcdSession) Timeout() time.Duration

type K8sEngine

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

func (*K8sEngine) Create

func (c *K8sEngine) Create(ctx context.Context, id, key string, timeout time.Duration) (engine.Session, error)

type K8sMutex

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

func NewK8sMutex

func NewK8sMutex(client *clientset.Clientset, id, key, namespace string, timeout time.Duration) *K8sMutex

func (*K8sMutex) ID

func (mu *K8sMutex) ID() string

func (*K8sMutex) IsLocked

func (mu *K8sMutex) IsLocked() bool

func (*K8sMutex) Key

func (mu *K8sMutex) Key() string

func (*K8sMutex) Refresh

func (mu *K8sMutex) Refresh(ctx context.Context, lease time.Duration) error

func (*K8sMutex) Release

func (mu *K8sMutex) Release(ctx context.Context) error

func (*K8sMutex) Timeout

func (mu *K8sMutex) Timeout() time.Duration

func (*K8sMutex) TryLock

func (mu *K8sMutex) TryLock(ctx context.Context) error

type RedisEngine

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

RedisEngine implements engine.SessionClient, it's used to create a new Redis session.

func (*RedisEngine) Create

func (r *RedisEngine) Create(ctx context.Context, id, key string, timeout time.Duration) (engine.Session, error)

Create creates 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

func NewRedisMutex(client *redislock.Client, id, key string, timeout time.Duration) *RedisMutex

NewRedisMutex creates a new RedisMutex instance.

func (*RedisMutex) ID

func (mu *RedisMutex) ID() string

ID returns the id of the Redis mutex.

func (*RedisMutex) IsLocked

func (mu *RedisMutex) IsLocked() bool

IsLocked returns true if the Redis mutex is locked.

func (*RedisMutex) Key

func (mu *RedisMutex) Key() string

Key returns the key of the Redis mutex.

func (*RedisMutex) Refresh

func (mu *RedisMutex) Refresh(ctx context.Context, lease time.Duration) error

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.

func (*RedisMutex) TryLock

func (mu *RedisMutex) TryLock(ctx context.Context) error

TryLock tries to obtain the Redis lock, it will return ErrLeaderElected if the Redis lock is already held.

Jump to

Keyboard shortcuts

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