store

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2022 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type InMemoryStore

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

InMemoryStore is an implementation of Store that is backed by a golang map. For testing purposes only.

func NewInMemoryStore

func NewInMemoryStore() *InMemoryStore

NewInMemoryStore returns a new InMemoryStore instance.

func (*InMemoryStore) Get

func (s *InMemoryStore) Get(ctx context.Context, key string) (string, error)

Get returns the value of the argument key.

func (*InMemoryStore) Set

func (s *InMemoryStore) Set(ctx context.Context, key string, value string) error

Set sets the argument key to the argument value.

type KubeLocker

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

KubeLocker is an Locker that uses Kubernetes's leader election functionality for locking.

func NewKubeLocker

func NewKubeLocker(
	kubeConfigPath string,
	id string,
	namespace string,
) (*KubeLocker, error)

NewKubeLocker returns a Locker that is backed by a lock in Kubernetes.

func (*KubeLocker) Acquire

func (k *KubeLocker) Acquire(ctx context.Context, name string) error

Acquire acquires a lock with the argument name.

func (*KubeLocker) Release

func (k *KubeLocker) Release(name string) error

Release releases the lock with the argument name.

type KubeStore

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

KubeStore is an implementation of Store that is backed by a Kubernetes configMap.

func NewKubeStore

func NewKubeStore(
	kubeConfigPath string,
	name string,
	namespace string,
) (*KubeStore, error)

NewKubeStore returns a new KubeStore instance.

func (*KubeStore) Get

func (k *KubeStore) Get(ctx context.Context, key string) (string, error)

Get returns the value of the argument key.

func (*KubeStore) Set

func (k *KubeStore) Set(ctx context.Context, key string, value string) error

Set sets the argument key to the argument value. The key/value pair is stored in a ConfigMap.

type LocalLocker

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

LocalLocker is an implementation of Locker that keeps track of locks in memory. For testing purposes only.

func NewLocalLocker

func NewLocalLocker() *LocalLocker

NewLocalLocker returns a new LocalLocker instance, which is backed by a golang lock.

func (*LocalLocker) Acquire

func (l *LocalLocker) Acquire(ctx context.Context, name string) error

Acquire acquires the lock with the argument name.

func (*LocalLocker) Release

func (l *LocalLocker) Release(name string) error

Release releases the lock with the argument name.

type Locker

type Locker interface {
	// Acquire acquires the lock with the provided name.
	Acquire(ctx context.Context, name string) error

	// Release releases the lock with the provided name.
	Release(name string) error
}

Locker is an interface for structs that can acquire and release locks.

type Store

type Store interface {
	// Get gets the value of the argument key.
	Get(ctx context.Context, key string) (string, error)

	// Set sets the provided key/value pair.
	Set(ctx context.Context, key string, value string) error
}

Store is an interface for structs that can get and set key/value pairs.

Directories

Path Synopsis
Package leaderelection implements leader election of a set of endpoints.
Package leaderelection implements leader election of a set of endpoints.

Jump to

Keyboard shortcuts

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