ipc

package
v1.1.1 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: 14 Imported by: 0

Documentation

Overview

This file contains the IPC method definitions and implementations

This file contains the IPC server implementation. IPC methods are defined in ipc.go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultSocketPath

func DefaultSocketPath() string

DefaultSocketPath returns a default socket path based on the os

func Run

func Run(lsrv LockServer, c *IPCConfig) (func(), error)

Run runs the IPC server with the provided LockServer and IPCConfig.

It sets up the IPC server, listens on the IPC socket, handles server start and shutdown, and performs cleanup operations. Parameters:

  • ctx: the context.Context for managing the lifecycle of the IPC server.
  • lsrv: the LockServer implementation for handling lock operations.
  • c: the IPCConfig containing IPC server configuration.

Returns:

  • cleanup: a function that can be called to clean up the IPC server.
  • error: an error if the IPC server failed to start.

Types

type IPC

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

IPC is the IPC server implementation.

func (*IPC) ListLocks

func (i *IPC) ListLocks(_ ListLocksRequest, locks *ListLocksResponse) error

ListLocks handles the IPC ListLocks request.

Parameters:

  • UnlockRequest
  • pointer to UnlockResponse

Returns an error.

func (*IPC) Unlock

func (i *IPC) Unlock(req UnlockRequest, resp *UnlockResponse) error

Unlock unlocks the specified lock.

Parameters:

  • UnlockRequest
  • pointer to UnlockResponse

Returns an error.

type IPCConfig

type IPCConfig struct {
	IPCSocketFile string `desc:"Path to the IPC socket file. Use an empty string to disable IPC." default:"<platform specific>"`
}

Config is the configuration for the IPC server.

type ListLocksRequest

type ListLocksRequest struct{}

IPC request and response types for the ListLocks method

type ListLocksResponse

type ListLocksResponse []string

type LockServer

type LockServer interface {
	Locks() []cl.Lock
	Unlock(context.Context, string, string) (bool, error)
}

LockServer is an interface for interacting with locks. It must support methods required by IPC commands

type UnlockRequest

type UnlockRequest struct {
	Name string
	Key  string
}

type UnlockResponse

type UnlockResponse bool

IPC request and response types used in the Unlock method

Jump to

Keyboard shortcuts

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