locksrv

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

This file contains LockSrv methods for handling client connects and disconnects. It is specified as a grpc.StatsHandler and implements the grpc.stats.Handler interface. This is the only way to hook into client connect and disconnect events in a gRPC server in go.

This file contains the gRPC exposed, protocol buffer defined services for the ldlm lock server. The ldlm lock server is essentially a gRPC wrapper around a single lock.Manager which manages a group of locks.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrLockWaitTimeout = errors.New("timeout waiting to acquire lock")
	ErrEmptyName       = errors.New("lock name cannot be empty")
)

Functions

This section is empty.

Types

type LockSrv

type LockSrv struct {
	pb.UnsafeLDLMServer
	// contains filtered or unexported fields
}

RPC and connection handler struct

func New

func New(c *LockSrvConfig) (*LockSrv, func())

New creates a new lock server

func (*LockSrv) HandleConn

func (l *LockSrv) HandleConn(ctx context.Context, s stats.ConnStats)

HandleConn handles connection and disconnection of clients

func (*LockSrv) HandleRPC

func (l *LockSrv) HandleRPC(ctx context.Context, s stats.RPCStats)

func (*LockSrv) Lock

func (l *LockSrv) Lock(ctx context.Context, r *pb.LockRequest) (*pb.LockResponse, error)

Lock blocks until the lock is obtained or is canceled / timed out by context

func (*LockSrv) Locks

func (l *LockSrv) Locks() []cl.ClientLock

Locks returns a list of client locks.

func (*LockSrv) RefreshLock

func (l *LockSrv) RefreshLock(ctx context.Context, r *pb.RefreshLockRequest) (*pb.LockResponse, error)

RefreshLock refreshes a lock timer

func (*LockSrv) TagConn

func (l *LockSrv) TagConn(ctx context.Context, info *stats.ConnTagInfo) context.Context

TagConn tags each new connection with a unique session key that is used when the client associated with this connection locks any lock.

func (*LockSrv) TagRPC

func (l *LockSrv) TagRPC(ctx context.Context, info *stats.RPCTagInfo) context.Context

Unimplemented methods, but needed to satisfy grpc.stats.Handler interface

func (*LockSrv) TryLock

func (l *LockSrv) TryLock(ctx context.Context, r *pb.TryLockRequest) (*pb.LockResponse, error)

TryLock attempts to acquire the lock and immediately fails or succeeds

func (*LockSrv) Unlock

func (l *LockSrv) Unlock(ctx context.Context, r *pb.UnlockRequest) (*pb.UnlockResponse, error)

Unlock removes the lock held by the client

type LockSrvConfig

type LockSrvConfig struct {
	LockGcInterval      time.Duration `desc:"Interval at which to garbage collect unused locks." default:"30m" short:"g"`
	LockGcMinIdle       time.Duration `` /* 133-byte string literal not displayed */
	DefaultLockTimeout  time.Duration `desc:"Lock timeout to use when loading locks from state file on startup" default:"10m" short:"d"`
	NoClearOnDisconnect bool          `desc:"Do not clear locks on client disconnect" default:"false" short:"n"`
	ipc.IPCConfig
	lockmap.LockMapConfig
}

Directories

Path Synopsis
This file contains the IPC method definitions and implementations
This file contains the IPC method definitions and implementations
This file contains LockMap struct definition and methods.
This file contains LockMap struct definition and methods.
clientlock
This file contains the ClientLock struct definition and methods.
This file contains the ClientLock struct definition and methods.
readwriter
This file contains the readWriter struct, its methods, and some helper functions related to serialization.
This file contains the readWriter struct, its methods, and some helper functions related to serialization.

Jump to

Keyboard shortcuts

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