Documentation ¶
Index ¶
Constants ¶
View Source
const (
SemaphorePrefix = keyPrefix + "/" + semaphoreBranch
)
Variables ¶
View Source
var ( ErrExist = errors.New("holder exists") ErrNotExist = errors.New("holder does not exist") )
Functions ¶
This section is empty.
Types ¶
type EtcdLockClient ¶
type EtcdLockClient struct {
// contains filtered or unexported fields
}
EtcdLockClient is a wrapper around the etcd client that provides simple primitives to operate on the internal semaphore and holders structs through etcd.
func NewEtcdLockClient ¶
func NewEtcdLockClient(keyapi KeysAPI, group string) (*EtcdLockClient, error)
NewEtcdLockClient creates a new EtcdLockClient. The group parameter defines the etcd key path in which the client will manipulate the semaphore. If the group is the empty string, the default semaphore will be used.
func (*EtcdLockClient) Get ¶
func (c *EtcdLockClient) Get() (*Semaphore, error)
Get fetches the Semaphore from etcd.
func (*EtcdLockClient) Init ¶
func (c *EtcdLockClient) Init() error
Init sets an initial copy of the semaphore if it doesn't exist yet.
func (*EtcdLockClient) Set ¶
func (c *EtcdLockClient) Set(sem *Semaphore) error
Set sets a Semaphore in etcd.
type KeysAPI ¶ added in v0.4.0
type KeysAPI interface { Get(ctx context.Context, key string, opts *client.GetOptions) (*client.Response, error) Set(ctx context.Context, key, value string, opts *client.SetOptions) (*client.Response, error) Create(ctx context.Context, key, value string) (*client.Response, error) }
KeysAPI is the minimum etcd client.KeysAPI interface EtcdLockClient needs to do its job.
type Lock ¶
type Lock struct {
// contains filtered or unexported fields
}
func New ¶
func New(id string, client LockClient) (lock *Lock)
type LockClient ¶
Click to show internal directories.
Click to hide internal directories.