api

package module
v0.0.0-...-0cc57db Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2021 License: MPL-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// JobTypeService indicates a long-running processes
	JobTypeService = "service"

	// JobTypeBatch indicates a short-lived process
	JobTypeBatch = "batch"

	// JobTypeSystem indicates a system process that should run on all clients
	JobTypeSystem = "system"

	// PeriodicSpecCron is used for a cron spec.
	PeriodicSpecCron = "cron"

	// DefaultNamespace is the default namespace.
	DefaultNamespace = "default"

	// GlobalRegion is a sentinel region value dor Job configuration
	// that users may specify to indicate the job should be run on
	// the region of the node that the job was submitted to.
	// For Client configuration, if no region information is given,
	// the client node will default to be part of the GlobalRegion.
	GlobalRegion = "global"

	// RegisterEnforceIndexErrPrefix is the prefix to use in errors caused by
	// enforcing the job modify index during registers.
	RegisterEnforceIndexErrPrefix = "Enforcing job modify index"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Ctx context.Context
	// contains filtered or unexported fields
}

func NewQueryClient

func NewQueryClient(opts *QueryOpts) (*Client, error)

func NewWriteClient

func NewWriteClient(opts *WriteOpts) (*Client, error)

func (*Client) Jobs

func (c *Client) Jobs() *Jobs

func (*Client) SetNamespace

func (c *Client) SetNamespace(namespace string)

func (*Client) SetRegion

func (c *Client) SetRegion(region string)

type Config

type Config struct {
	// Region to use. If not provided, the default agent region is used.
	Region string

	// Namespace to use. If not provided the default namespace is used.
	Namespace string

	QueryOpts *QueryOpts

	WriteOpts *WriteOpts
}

type Jobs

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

Jobs encapsulates and extends the generated JobsApiService with convenience methods.

func (*Jobs) Delete

func (j *Jobs) Delete(jobName string, purge, global bool) (*openapi.JobDeregisterResponse, *WriteMeta, error)

func (*Jobs) Deployment

func (j *Jobs) Deployment(jobName string) (*openapi.Deployment, *QueryMeta, error)

func (*Jobs) Deployments

func (j *Jobs) Deployments(jobName string) (*[]openapi.Deployment, *QueryMeta, error)

func (*Jobs) Dispatch

func (j *Jobs) Dispatch(jobName string, payload string, meta map[string]string) (*openapi.JobDispatchResponse, *WriteMeta, error)

func (*Jobs) EnforceRegister

func (j *Jobs) EnforceRegister(job *openapi.Job, modifyIndex uint64) (*openapi.JobRegisterResponse, *WriteMeta, error)

func (*Jobs) Evaluate

func (j *Jobs) Evaluate(jobName string, forceReschedule bool) (*openapi.JobRegisterResponse, *WriteMeta, error)

func (*Jobs) GetJob

func (j *Jobs) GetJob(jobName string) (*openapi.Job, *QueryMeta, error)

func (*Jobs) GetJobs

func (j *Jobs) GetJobs() ([]openapi.JobListStub, *QueryMeta, error)

func (*Jobs) GetLocation

func (j *Jobs) GetLocation(job *openapi.Job) (*time.Location, error)

func (*Jobs) IsMultiRegion

func (j *Jobs) IsMultiRegion(job *openapi.Job) bool

func (*Jobs) IsParameterized

func (j *Jobs) IsParameterized(job *openapi.Job) bool

func (*Jobs) IsPeriodic

func (j *Jobs) IsPeriodic(job *openapi.Job) bool

func (*Jobs) JobsApi

func (j *Jobs) JobsApi() *openapi.JobsApiService

func (*Jobs) Next

func (j *Jobs) Next(p *openapi.PeriodicConfig, fromTime time.Time) (time.Time, error)

Next returns the closest time instant matching the spec that is after the passed time. If no matching instance exists, the zero value of time.Time is returned. The `time.Location` of the returned value matches that of the passed time.

func (*Jobs) Parse

func (j *Jobs) Parse(hcl string, canonicalize, hclV1 bool) (*openapi.Job, error)

func (*Jobs) PeriodicForce

func (j *Jobs) PeriodicForce(jobName string) (*openapi.PeriodicForceResponse, *WriteMeta, error)

func (*Jobs) Plan

func (j *Jobs) Plan(job *openapi.Job, diff bool) (*openapi.JobPlanResponse, *WriteMeta, error)

func (*Jobs) PlanOpts

func (j *Jobs) PlanOpts(job *openapi.Job, opts *PlanOpts) (*openapi.JobPlanResponse, *WriteMeta, error)

func (*Jobs) Post

func (*Jobs) Register

func (j *Jobs) Register(job *openapi.Job, registerOpts *RegisterOpts) (*openapi.JobRegisterResponse, *WriteMeta, error)

func (*Jobs) Revert

func (j *Jobs) Revert(jobName string, versionNumber, enforcePriorVersion int32, consulToken, vaultToken string) (*openapi.JobRegisterResponse, *WriteMeta, error)

func (*Jobs) Scale

func (j *Jobs) Scale(jobName string, count int64, msg string, target map[string]string) (*openapi.JobRegisterResponse, *WriteMeta, error)

func (*Jobs) ScaleStatus

func (j *Jobs) ScaleStatus(jobName string) (*openapi.JobScaleStatusResponse, *QueryMeta, error)

func (*Jobs) Stability

func (j *Jobs) Stability(jobName string, versionNumber int32, stable bool) (*openapi.JobStabilityResponse, *WriteMeta, error)

func (*Jobs) Summary

func (j *Jobs) Summary(jobName string) (*openapi.JobSummary, *QueryMeta, error)

func (*Jobs) Versions

func (j *Jobs) Versions(jobName string, withDiffs bool) (*openapi.JobVersionsResponse, *QueryMeta, error)

type PlanOpts

type PlanOpts struct {
	Diff           bool
	PolicyOverride bool
}

type QueryMeta

type QueryMeta struct {
	// LastIndex can be used as a Index to perform
	// a blocking query
	LastIndex uint64

	// LastContact is the time of last contact from the leader for the
	// server servicing the request
	LastContact time.Duration

	// KnownLeader indicates if there is a known leader
	KnownLeader bool

	// RequestTime is how long did the request took
	RequestTime time.Duration
}

QueryMeta is used to return metadata about a query

type QueryOpts

type QueryOpts struct {
	// Providing a datacenter overwrites the region provided
	// by the Config
	Region string

	// Namespace is the target namespace for the query.
	Namespace string

	// AllowStale allows any Nomad server (non-leader) to service
	// a read. This allows for lower latency and higher throughput
	AllowStale bool

	// WaitIndex is used to enable a blocking query. Waits
	// until the timeout or the next index is reached
	WaitIndex uint64

	// WaitTime is used to bound the duration of a wait.
	// Defaults to that of the Config, but can be overridden.
	WaitTime time.Duration

	// If set, used as prefix for resource list searches
	Prefix string

	// Set HTTP parameters on the query.
	Params map[string]string

	// AuthToken is the secret ID of an ACL token
	AuthToken string

	// PerPage is the number of entries to be returned in queries that support
	// paginated lists.
	PerPage int32

	// NextToken is the token used indicate where to start paging for queries
	// that support paginated lists.
	NextToken string
	// contains filtered or unexported fields
}

QueryOpts are used to parametrize a query

type RegisterOpts

type RegisterOpts struct {
	EnforceIndex   bool
	ModifyIndex    uint64
	PolicyOverride bool
	PreserveCounts bool
}

type WriteMeta

type WriteMeta struct {
	// LastIndex can be used as a Index to perform
	// a blocking query
	LastIndex uint64

	// RequestTime is how long did the request took
	RequestTime time.Duration
}

WriteMeta is used to return metadata about a write operation

type WriteOpts

type WriteOpts struct {
	// Providing a datacenter overwrites the region provided
	// by the Config
	Region string

	// Namespace is the target namespace for the operation.
	Namespace string

	// AuthToken is the secret ID of an ACL token
	AuthToken string

	// IdempotencyToken can be used to ensure the operation is idempotent.
	IdempotencyToken string
	// contains filtered or unexported fields
}

WriteOpts are used to parametrize a write operation

Jump to

Keyboard shortcuts

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