agentapi

package
v3.76.1 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package agentapi provides an API for interacting with the agent.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultSocketPath

func DefaultSocketPath(base string) string

DefaultSocketPath constructs the default path for the Agent API socket.

func LeaderPath

func LeaderPath(base string) string

LeaderPath returns the path to the socket pointing to the leader agent.

Types

type Client

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

Client is a client for the agent API socket.

func NewClient

func NewClient(ctx context.Context, path string) (*Client, error)

NewClient creates a new Client using the socket at a given path. The context is used for an internal check that the socket can be dialled.

func (*Client) LockCompareAndSwap

func (c *Client) LockCompareAndSwap(ctx context.Context, key, old, new string) (string, bool, error)

LockCompareAndSwap atomically compares-and-swaps the old value for the new value, or performs no modification. It returns the most up-to-date value for the key, and reports whether the new value was written.

func (*Client) LockGet

func (c *Client) LockGet(ctx context.Context, key string) (string, error)

LockGet gets the current value of the lock key.

func (*Client) Ping

func (c *Client) Ping(ctx context.Context) error

Ping pings the server. It returns a non-nil error if the ping fails, or the response timestamp is more than 100 milliseconds different to time.Now.

type LockCASRequest

type LockCASRequest struct {
	Old string `json:"old"`
	New string `json:"new"`
}

LockCASRequest is the request body for the PATCH /lock/{key} endpoint.

type LockCASResponse

type LockCASResponse struct {
	Value   string `json:"value"`
	Swapped bool   `json:"swapped"`
}

LockCASResponse is the response body for the PATCH /lock/{key} endpoint.

type PingResponse

type PingResponse struct {
	Now time.Time `json:"now"`
}

PingResponse is the response body for the ping endpoint.

type Server

type Server struct {
	*socket.Server
	// contains filtered or unexported fields
}

Server hosts the Unix domain socket used for implementing the Agent API.

func NewServer

func NewServer(socketPath string, log logger.Logger) (*Server, error)

NewServer creates a new Agent API server that, when started, listens on the socketPath.

type ValueResponse

type ValueResponse struct {
	Value string `json:"value"`
}

ValueResponse is the response body for endpoints that return a single value.

Jump to

Keyboard shortcuts

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