client

package
v0.0.0-...-8937d30 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package client implements FleetLock client.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client holds the params related to the host in order to interact with the FleetLock server URL.

func New

func New(baseServerURL, group, id string, c HTTPClient) (*Client, error)

New builds a FleetLock client.

func (*Client) RecursiveLock

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

RecursiveLock tries to reserve (lock) a slot for rebooting.

func (*Client) UnlockIfHeld

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

UnlockIfHeld tries to release (unlock) a slot that it was previously holding.

type Error

type Error struct {
	// Kind is the error type identifier.
	Kind string `json:"kind"`
	// Value is a human-friendly error description.
	Value string `json:"value"`
}

Error is the type returned by FleetLock in case StatusCode is different from 200.

func (*Error) String

func (e *Error) String() string

String returns a high-level error formatted for human readability.

type HTTPClient

type HTTPClient interface {
	// Do send a `body` payload to the URL.
	Do(*http.Request) (*http.Response, error)
}

HTTPClient interface holds the required Post method to send FleetLock requests.

type Params

type Params struct {
	// ID is the client identifier. (e.g node name or UUID)
	ID string `json:"id"`
	// Group is the reboot-group of the client.
	Group string `json:"group"`
}

Params is the object holding the ID and the group for each client.

type Payload

type Payload struct {
	// ClientParams holds the parameters specific to the
	// FleetLock client.
	//
	//nolint:tagliatelle // FleetLock protocol requires exactly 'client_params' field.
	ClientParams *Params `json:"client_params"`
}

Payload is the content to send to the FleetLock server.

Jump to

Keyboard shortcuts

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