Documentation ¶
Index ¶
- Constants
- Variables
- type Conn
- type Lease
- type LockRequest
- type Mutex
- func (m *Mutex) Error(errs []error, err error) error
- func (m *Mutex) Freeze(ctx context.Context, topic string) error
- func (m *Mutex) Keepalive()
- func (m *Mutex) Lock(ctx context.Context) error
- func (m *Mutex) Renew(ctx context.Context) error
- func (m *Mutex) Reset(ctx context.Context, topic string) error
- func (m *Mutex) Unlock(ctx context.Context) error
- type MutexOption
- type Node
- func (n *Node) Freeze(topic string, ok *bool) error
- func (n *Node) NewLock(req LockRequest, t *Lease) error
- func (n *Node) ReleaseLock(req LockRequest, ok *bool) error
- func (n *Node) RenewLock(req LockRequest, t *Lease) error
- func (n *Node) Reset(topic string, ok *bool) error
- func (n *Node) Start() error
- func (n *Node) Stop()
- type NodeOption
Constants ¶
View Source
const ( CreateTableLease = "CREATE TABLE IF NOT EXISTS dlm_lease(" + "`topic` varchar(20) NOT NULL," + "`key` varchar(50) NOT NULL," + "`lessee` varchar(36) NOT NULL," + "`since` int NOT NULL DEFAULT '0'," + "`ttl` int NOT NULL DEFAULT '0'," + "PRIMARY KEY (topic, key));" CreateTableTopic = "CREATE TABLE IF NOT EXISTS dlm_topic(" + "`topic` varchar(20) NOT NULL," + "`ttl` int NOT NULL DEFAULT '0'," + "PRIMARY KEY (topic));" )
Variables ¶
View Source
var ( ErrExpiredLease = errors.New("dlm: lease expires") ErrNoLease = errors.New("dlm: no lease") ErrNotYourLease = errors.New("dlm: not your lease") ErrLeaseExists = errors.New("dlm: lease exists") ErrFrozenTopic = errors.New("dlm: topic is frozen") ErrBadDatabase = errors.New("dlm: bad database operation") )
Functions ¶
This section is empty.
Types ¶
type Lease ¶
type Lease struct { Topic string Key string Lessee string Since int64 TTL sqle.Duration // Only available on mutex ExpiresOn time.Time `json:"-"` }
Lease lock period on the key
type Mutex ¶
func New ¶
func New(id, topic, key string, options ...MutexOption) *Mutex
type MutexOption ¶
type MutexOption func(m *Mutex)
func WithKeepAlive ¶ added in v0.0.4
func WithKeepAlive(d time.Duration) MutexOption
func WithPeers ¶
func WithPeers(peers ...string) MutexOption
func WithTTL ¶
func WithTTL(d time.Duration) MutexOption
func WithTimeout ¶
func WithTimeout(d time.Duration) MutexOption
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
func (*Node) ReleaseLock ¶
func (n *Node) ReleaseLock(req LockRequest, ok *bool) error
type NodeOption ¶
type NodeOption func(n *Node)
func WithLogger ¶
func WithLogger(l *slog.Logger) NodeOption
Click to show internal directories.
Click to hide internal directories.