Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrLockNotClaimed = errors.New("lock not claimed")
ErrLockNotClaimed is an error returned when the desired lock can't be claimed. This happens if the lock is already claimed by another client.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the main client struct. Use NewClient to initialize a new one.
func NewClient ¶
func NewClient(addr string, opts ClientOpts) (*Client, error)
NewClient creates a new capybara client using the given capybara GRPc address and various options such as the token, path to the server's CA certificate or a unique identifier.
func (Client) ClaimLock ¶
func (c Client) ClaimLock(lock string) (*pb.LockResponse, error)
ClaimLock will claim the given lock and return an error if it can't successfully claim said lock.
func (Client) ClaimLockRaw ¶
func (c Client) ClaimLockRaw(lock string) (*pb.LockResponse, error)
ClaimLockRaw claims the given lock and returns the LockResponse. The pb.LockResponse.Acquired field should be checked to confirm the lock has been acquired.
func (Client) ReleaseLock ¶
type ClientOpts ¶
ClientOpts represents the various options that can be passed to NewClient. It allows to customize the behavior of the client.
Token: A token to enforce security between the client and the server. This token will be passed to all subsequent requests made with the client. CertPath: Path to the server's certificate authority certiticate. Given a proper certificate, this option will ensure the connection is encrypted. Who: Unique identifier. If this option isn't provided, a unique ID will be generated on the fly.