clusterlock

package
v0.0.0-...-c4d1043 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2021 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// default namespace to install
	LockDefaultNamespace = "default"
	// name of kubernetes service holding the lock
	LockResourceName = "test-lock"
	// name of the annotation containing the lock
	LockAnnotationKey = "test.lock"
	// name of the annotation containing the timeout
	LockTimeoutAnnotationKey = "test.lock.timeout"

	// Default timeout for lock to be held
	DefaultLockTimeout = time.Second * 30
	DefaultTimeFormat  = time.RFC3339Nano

	// heartbeat settings
	DefaultHeartbeatTime = time.Second * 10
)

Variables

View Source
var (
	IsEmptyLockReleaseError = func(e error) bool {
		return e == emptyLockReleaseError
	}

	IsNotLockOwnerError = func(e error) bool {
		return e == notLockOwnerError
	}

	IsLockIsUseError = func(e error) bool {
		return e == lockInUseError
	}
)

Functions

func ConflictError

func ConflictError(name string) error

func ExistsError

func ExistsError(name string) error

func NotFoundError

func NotFoundError(name string) error

Types

type ClusterLock

type ClusterLock struct {
	Name    string
	OwnerID string
	Timeout string

	// either a kube resource version or consul modify index
	ResourceVersion string
}

a ClusterLock is only ever composed of either a kubernetes configmap, or a consul key

func CLFromConfigMap

func CLFromConfigMap(cm *v1.ConfigMap) *ClusterLock

func CLFromKVPair

func CLFromKVPair(keyPrefix string, kvp *api.KVPair) *ClusterLock

func (*ClusterLock) Clear

func (l *ClusterLock) Clear()

func (ClusterLock) ConfigMap

func (l ClusterLock) ConfigMap(namespace string) *v1.ConfigMap

func (*ClusterLock) Empty

func (l *ClusterLock) Empty() bool

func (ClusterLock) KVPair

func (l ClusterLock) KVPair(keyPrefix string) *api.KVPair

func (*ClusterLock) Set

func (l *ClusterLock) Set(ownerId, timeout string)

type ClusterLockClient

type ClusterLockClient interface {
	Create(cl *ClusterLock) (*ClusterLock, error)
	Update(cl *ClusterLock) (*ClusterLock, error)
	Get(name string) (*ClusterLock, error)
	Delete(name string) error
}

type ConsulClusterLockClient

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

func (*ConsulClusterLockClient) Create

func (*ConsulClusterLockClient) Delete

func (c *ConsulClusterLockClient) Delete(name string) error

func (*ConsulClusterLockClient) Get

func (*ConsulClusterLockClient) Update

type KubeClusterLockClient

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

func (*KubeClusterLockClient) Create

func (*KubeClusterLockClient) Delete

func (c *KubeClusterLockClient) Delete(name string) error

func (*KubeClusterLockClient) Get

func (c *KubeClusterLockClient) Get(name string) (*ClusterLock, error)

func (*KubeClusterLockClient) Update

type Options

type Options struct {
	Namespace string
	IdPrefix  string
	Context   context.Context
}

type TestClusterLocker

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

func NewClusterLocker

func NewClusterLocker(ctx context.Context, idPrefix string, client ClusterLockClient) (*TestClusterLocker, error)

func NewConsulClusterLocker

func NewConsulClusterLocker(ctx context.Context, idPrefix string, consul *api.Client) (*TestClusterLocker, error)

func NewKubeClusterLocker

func NewKubeClusterLocker(clientset kubernetes.Interface, options Options) (*TestClusterLocker, error)

func NewTestClusterLocker deprecated

func NewTestClusterLocker(clientset kubernetes.Interface, options Options) (*TestClusterLocker, error)

Deprecated: use NewKubeClusterLocker

func (*TestClusterLocker) AcquireLock

func (t *TestClusterLocker) AcquireLock(opts ...retry.Option) error

func (*TestClusterLocker) ReleaseLock

func (t *TestClusterLocker) ReleaseLock() error

Jump to

Keyboard shortcuts

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