capybara

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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) Close

func (c Client) Close() error

Close will close the internal grpc connection.

func (Client) ReleaseLock

func (c Client) ReleaseLock(lock string) error

func (Client) WhoAmI

func (c Client) WhoAmI() string

WhoAmI returns the unique identifier associated with the client. It can reflect the one that was provided when initializing the client or the one generated if no unique identifier was provided.

type ClientOpts

type ClientOpts struct {
	Token    string
	CertPath string
	Who      string
}

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.

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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