client

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LockTypeRead  = ml.LockTypeRead
	LockTypeWrite = ml.LockTypeWrite
)

Variables

View Source
var ErrReleasedBeforeAcquired = errors.New("cannot release lock before it has been locked")
View Source
var ErrUnexpectedResponse = errors.New("unexpected response")

Functions

This section is empty.

Types

type ConnectionOptions

type ConnectionOptions struct {
	Url                 string // if provided, other options are ignored
	Host                string
	Port                int
	Namespace           string
	Secure              bool
	ForceCloseTimeoutMs *int // if provided, server will keep the lock for this time after client disconnects without releasing it
}

type LockType

type LockType = ml.LockType

type LocktopusClient

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

LocktopusClient is a client for Locktopus server. Use MakeLocktopusClient to instantiate one and connect.

func MakeClient

func MakeClient(options ConnectionOptions) (*LocktopusClient, error)

MakeClient establishes a connection to the Locktopus server and returns LocktopusClient.

func (*LocktopusClient) Acquire

func (c *LocktopusClient) Acquire() (err error)

Acquire is used to wait until the lock is acquired. If IsAcquired() returns true after calling Lock(), calling Acquire() is no-op.

func (*LocktopusClient) AddLockResource

func (c *LocktopusClient) AddLockResource(lockType LockType, resources ...string)

AddLockResource adds resources to be used and flushed within next Lock() call.

func (*LocktopusClient) Close

func (c *LocktopusClient) Close() error

func (*LocktopusClient) IsAcquired

func (c *LocktopusClient) IsAcquired() bool

IsAcquired returns true if last Lock() has been acquired, so there is no need to call Acquire()

func (*LocktopusClient) Lock

func (c *LocktopusClient) Lock() (err error)

Lock locks added resources. Use IsAcquired() to check if lock has been acquired.

func (*LocktopusClient) LockID

func (c *LocktopusClient) LockID() string

func (*LocktopusClient) Release

func (c *LocktopusClient) Release() (err error)

Release releases the lock. After that you may call AddLockResource() and Lock() again.

Jump to

Keyboard shortcuts

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