clusterlock

package
v0.10.3 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2019 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 added in v0.9.19

func ConflictError(name string) error

func ExistsError added in v0.9.19

func ExistsError(name string) error

func NotFoundError added in v0.9.19

func NotFoundError(name string) error

Types

type ClusterLock added in v0.9.19

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 added in v0.9.19

func CLFromConfigMap(cm *v1.ConfigMap) *ClusterLock

func CLFromKVPair added in v0.9.19

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

func (*ClusterLock) Clear added in v0.9.19

func (l *ClusterLock) Clear()

func (ClusterLock) ConfigMap added in v0.9.19

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

func (*ClusterLock) Empty added in v0.9.19

func (l *ClusterLock) Empty() bool

func (ClusterLock) KVPair added in v0.9.19

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

func (*ClusterLock) Set added in v0.9.19

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

type ClusterLockClient added in v0.9.19

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

type ConsulClusterLockClient added in v0.9.19

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

func (*ConsulClusterLockClient) Create added in v0.9.19

func (*ConsulClusterLockClient) Delete added in v0.9.19

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

func (*ConsulClusterLockClient) Get added in v0.9.19

func (*ConsulClusterLockClient) Update added in v0.9.19

type KubeClusterLockClient added in v0.9.19

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

func (*KubeClusterLockClient) Create added in v0.9.19

func (*KubeClusterLockClient) Delete added in v0.9.19

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

func (*KubeClusterLockClient) Get added in v0.9.19

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

func (*KubeClusterLockClient) Update added in v0.9.19

type Options

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

type TestClusterLocker

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

func NewClusterLocker added in v0.9.19

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

func NewConsulClusterLocker added in v0.9.19

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

func NewKubeClusterLocker added in v0.9.19

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