api

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrCheckIDMandatory is returned when the API is asked to update the state
	// of the check but no checkID is provided.
	ErrCheckIDMandatory = errors.New("a check must inform always a check id when updating its state")

	// ErrStatusMandatory is returned when the API is asked to update the state
	// of the check but no status is provided.
	ErrStatusMandatory = errors.New("a check must inform always a stauts when updating its state")
)

Functions

This section is empty.

Types

type API

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

API defines the methods of the API that the agent exposes to the outside.

func New

func New(log log.Logger, supdater CheckStateUpdater, astats AgentStats) *API

New returns an API filled with the provided check state updater and the agent stats service.

func (*API) CheckUpdate

func (a *API) CheckUpdate(c CheckState) error

CheckUpdate attends the request sent by a check in order to update its state.

func (*API) Stats

func (a *API) Stats() (Stats, error)

Stats exposed some stats about the agent to the outside world.

type AgentStats

type AgentStats interface {
	ChecksRunning() int
	LastMessageReceived() *time.Time
}

AgentStats defined the methods needed by the API to gather the information about agent stats that it exposed to the outside world.

type CheckState

type CheckState struct {
	ID       string
	Report   *report.Report `json:"report,omitempty"`
	Progress *float32       `json:"progress,omitempty"`
	Status   *string        `json:"status,omitempty"`
}

CheckState holds the values related to the state of a check. The values defined here the one written to the check states queue.

type CheckStateUpdater

type CheckStateUpdater interface {
	UpdateState(stateupdater.CheckState) error
	UploadCheckData(checkID, kind string, startedAt time.Time, content []byte) (string, error)
}

CheckStateUpdater defines the method needed by the API in order to send check updates messages to the corresponding queue.

type Stats

type Stats struct {
	// Timestamp of the last queue message received.
	LastMessageReceived *time.Time `json:"last_message_received,omitempty"`
	ChecksRunning       int        `json:"checks_running"`
}

Stats defines the general information that the API provides about the agent.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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