Documentation ¶
Index ¶
- Constants
- Variables
- type ConnectionOptions
- type LockType
- type LocktopusClient
- func (c *LocktopusClient) Acquire() (err error)
- func (c *LocktopusClient) AddLockResource(lockType LockType, resources ...string)
- func (c *LocktopusClient) Close() error
- func (c *LocktopusClient) IsAcquired() bool
- func (c *LocktopusClient) Lock() (err error)
- func (c *LocktopusClient) LockID() string
- func (c *LocktopusClient) Release() (err error)
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 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.
Click to show internal directories.
Click to hide internal directories.