server

package
v1.1.0 Latest Latest
Warning

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

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

Documentation

Overview

This file contains the ldlm lock server. It exposes functions, not ports. For networking see the net package.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEmptyName                    = errors.New("lock name cannot be empty")
	ErrLockWaitTimeout              = errors.New("timeout waiting to acquire lock")
	ErrLockDoesNotExistOrInvalidKey = errors.New("lock does not exist or invalid key")
	ErrSessionDoesNotExist          = errors.New("session does not exist")
	ErrInvalidLockTimeout           = errors.New("lock timeout must be greater than 0")
	ErrInvalidWaitTimeout           = errors.New("wait timeout must be greater than 0")
)

Functions

This section is empty.

Types

type Lock added in v1.1.0

type Lock struct {
	Name   string
	Key    string
	Locked bool
}

Type returned by server's locking functions

type LockServer added in v1.1.0

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

Lock server

func New added in v1.1.0

func New(c *LockServerConfig) (*LockServer, func(), error)

New creates a new lock server.

It initializes a lock manager, session manager, and lock timer manager. It loads locks from the session manager and tries to lock all loaded locks. It starts the IPC server and returns the lock server instance and a closer function.

Parameters:

  • c: a pointer to a LockServerConfig struct containing configuration options for the lock server.

Returns:

  • a pointer to a LockServer struct representing the lock server.
  • a function that closes the lock server.
  • an error if there was an issue creating the lock server.

func (*LockServer) CreateSession added in v1.1.0

func (l *LockServer) CreateSession(ctx context.Context, sessionInfo map[string]any) (string, context.Context)

CreateSession creates a new session

func (*LockServer) DestroySession added in v1.1.0

func (l *LockServer) DestroySession(ctx context.Context) (sessionId string)

DestroySession destroys the session

func (*LockServer) Lock added in v1.1.0

func (l *LockServer) Lock(ctx context.Context, name string, size *int32, lockTimeoutSeconds *int32, waitTimeoutSeconds *int32) (*Lock, error)

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

func (*LockServer) Locks added in v1.1.0

func (l *LockServer) Locks() []cl.Lock

Locks returns a list of client locks.

func (*LockServer) RefreshLock added in v1.1.0

func (l *LockServer) RefreshLock(ctx context.Context, name string, key string, lockTimeoutSeconds int32) (*Lock, error)

RefreshLock refreshes a lock timer

func (*LockServer) SessionId added in v1.1.0

func (l *LockServer) SessionId(ctx context.Context) (string, bool)

SessionId returns the session ID from the context.

func (*LockServer) TryLock added in v1.1.0

func (l *LockServer) TryLock(ctx context.Context, name string, size *int32, lockTimeoutSeconds *int32) (*Lock, error)

TryLock attempts to acquire the lock and immediately fails or succeeds

func (*LockServer) Unlock added in v1.1.0

func (l *LockServer) Unlock(ctx context.Context, name string, key string) (bool, error)

Unlock surprisingly, unlocks a lock...

type LockServerConfig added in v1.1.0

type LockServerConfig struct {
	Shards              uint32        `desc:"Number of lock shards to use" default:"16"`
	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
	session.SessionConfig
}

Directories

Path Synopsis
This file contains a Lock struct definition which represents a lock held by a lock server client.
This file contains a Lock struct definition which represents a lock held by a lock server client.
This file contains the IPC method definitions and implementations
This file contains the IPC method definitions and implementations
This file contains sessionManager struct definition and methods.
This file contains sessionManager struct definition and methods.
store
This file contains the store struct, its methods, and some helper functions related to serialization.
This file contains the store 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