client

package
v1.1.5 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2023 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const APIRetryCount = 5

APIRetryCount - for some queries (like read events and read state) we want to fail early (10 seconds should be ample time) but retry a number of times - this is to avoid network flakes failing the canary

View Source
const APIShortTimeoutSeconds = 10

Variables

This section is empty.

Functions

This section is empty.

Types

type APIClient

type APIClient struct {
	BaseURI        *url.URL
	DefaultHeaders map[string]string
	Client         *http.Client
}

APIClient is a utility for interacting with a node's API server against v1 APIs.

func NewAPIClient

func NewAPIClient(host string, port uint16, path ...string) *APIClient

NewAPIClient returns a new client for a node's API server against v1 APIs the client will use /api/v1 path by default is no custom path is defined

func (*APIClient) Alive

func (apiClient *APIClient) Alive(ctx context.Context) (bool, error)

Alive calls the node's API server health check.

func (*APIClient) Cancel

func (apiClient *APIClient) Cancel(ctx context.Context, jobID string, reason string) (*model.JobState, error)

Cancel will request that the job with the specified ID is stopped. The JobInfo will be returned if the cancel was submitted. If no match is found, Cancel returns false with a nil error.

func (*APIClient) Debug

func (apiClient *APIClient) Debug(ctx context.Context) (map[string]model.DebugInfo, error)

func (*APIClient) DoPost

func (apiClient *APIClient) DoPost(ctx context.Context, api string, reqData, resData interface{}) error

func (*APIClient) Get

func (apiClient *APIClient) Get(ctx context.Context, jobID string) (*model.JobWithInfo, bool, error)

Get returns job data for a particular job ID. If no match is found, Get returns false with a nil error.

func (*APIClient) GetEvents

func (apiClient *APIClient) GetEvents(
	ctx context.Context,
	jobID string,
	options legacymodels.EventFilterOptions) (events []model.JobHistory, err error)

func (*APIClient) GetJobState

func (apiClient *APIClient) GetJobState(ctx context.Context, jobID string) (model.JobState, error)

func (*APIClient) GetJobStateResolver

func (apiClient *APIClient) GetJobStateResolver() *job.StateResolver

func (*APIClient) GetResults

func (apiClient *APIClient) GetResults(ctx context.Context, jobID string) (results []model.PublishedResult, err error)

func (*APIClient) List

func (apiClient *APIClient) List(
	ctx context.Context,
	idFilter string,
	includeTags []string,
	excludeTags []string,
	maxJobs int,
	returnAll bool,
	sortBy string,
	sortReverse bool,
) (
	[]*model.JobWithInfo, error)

List returns the list of jobs in the node's transport.

func (*APIClient) Logs

func (apiClient *APIClient) Logs(
	ctx context.Context,
	jobID string,
	executionID string,
	withHistory bool,
	follow bool) (*websocket.Conn, error)

Logs will retrieve the address of an endpoint where a client connection can be made to stream the results of an execution back to a TTY

func (*APIClient) Nodes

func (apiClient *APIClient) Nodes(ctx context.Context) ([]models.NodeInfo, error)

func (*APIClient) Submit

func (apiClient *APIClient) Submit(
	ctx context.Context,
	j *model.Job,
) (*model.Job, error)

Submit submits a new job to the node's transport.

func (*APIClient) Version

func (apiClient *APIClient) Version(ctx context.Context) (*models.BuildVersionInfo, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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