Documentation
¶
Overview ¶
Package agent provides a daemon capable of running remote operations on behalf of a user.
Index ¶
Constants ¶
const ( DefaultDataDir = "~/.otf-agent" DefaultID = "agent-001" )
const (
DefaultConcurrency = 5
)
const (
// SpoolerCapacity is the max number of queued runs the spooler can store
SpoolerCapacity = 100
)
Variables ¶
var ( // QueuedStatuses are the list of run statuses that indicate it is in a // queued state QueuedStatuses = []tfe.RunStatus{tfe.RunPlanQueued, tfe.RunApplyQueued} )
Functions ¶
This section is empty.
Types ¶
type Agent ¶
type Agent struct {
// ID uniquely identifies the agent.
ID string
logr.Logger
// DataDir stores artefacts relating to runs, i.e. downloaded plugins,
// modules (?), configuration versions, state, etc.
DataDir string
// ServerAddr is the address (<host>:<port>) of the OTF server to connect
// to.
ServerAddr string
ConfigurationVersionService otf.ConfigurationVersionService
StateVersionService otf.StateVersionService
Spooler
*Supervisor
}
Agent runs remote operations
func NewAgent ¶
func NewAgent(logger logr.Logger, cvs otf.ConfigurationVersionService, svs otf.StateVersionService, rs otf.RunService, es otf.EventService) (*Agent, error)
NewAgent is the constructor for an Agent
type Cancelable ¶
type Cancelable interface {
Cancel(force bool)
}
type Executor ¶
type Executor struct {
logr.Logger
RunService otf.RunService
ConfigurationVersionService otf.ConfigurationVersionService
StateVersionService otf.StateVersionService
}
type ExecutorEnvironment ¶
type ExecutorEnvironment struct {
// contains filtered or unexported fields
}
type MockJobGetter ¶
type MockJobGetter struct {
// contains filtered or unexported fields
}
func NewMockJobGetter ¶
func NewMockJobGetter(job ...otf.Job) *MockJobGetter
func (*MockJobGetter) GetJob ¶
func (s *MockJobGetter) GetJob() <-chan otf.Job
type MockSpooler ¶
type MockSpooler struct {
Spooler
// contains filtered or unexported fields
}
func NewMockSpooler ¶
func NewMockSpooler(opt ...MockSpoolerOption) *MockSpooler
func (*MockSpooler) GetCancelation ¶
func (s *MockSpooler) GetCancelation() <-chan otf.Job
func (*MockSpooler) GetJob ¶
func (s *MockSpooler) GetJob() <-chan otf.Job
type MockSpoolerOption ¶
type MockSpoolerOption func(*MockSpooler)
func WithCanceledJobs ¶
func WithCanceledJobs(job ...otf.Job) MockSpoolerOption
func WithMockJobs ¶
func WithMockJobs(job ...otf.Job) MockSpoolerOption
type Spooler ¶
type Spooler interface {
// Start the daemon
Start(context.Context)
// GetJob receives spooled job
GetJob() <-chan otf.Job
// GetCancelation receives cancelation request for a job
GetCancelation() <-chan otf.Job
}
Spooler is a daemon from which jobs can be retrieved
type SpoolerDaemon ¶
type SpoolerDaemon struct {
// EventService allows subscribing to stream of events
otf.EventService
// Logger for logging various events
logr.Logger
// contains filtered or unexported fields
}
SpoolerDaemon implements Spooler, receiving runs with either a queued plan or apply, and converting them into spooled jobs.
func NewSpooler ¶
func NewSpooler(rl RunLister, es otf.EventService, logger logr.Logger) (*SpoolerDaemon, error)
NewSpooler is a constructor for a Spooler pre-populated with queued runs
func (*SpoolerDaemon) GetCancelation ¶
func (s *SpoolerDaemon) GetCancelation() <-chan otf.Job
GetCancelation returns a channel of cancelation requests
func (*SpoolerDaemon) GetJob ¶
func (s *SpoolerDaemon) GetJob() <-chan otf.Job
GetJob returns a channel of queued jobs
func (*SpoolerDaemon) Start ¶
func (s *SpoolerDaemon) Start(ctx context.Context)
Start starts the spooler
type Supervisor ¶
type Supervisor struct {
logr.Logger
RunService otf.RunService
ConfigurationVersionService otf.ConfigurationVersionService
StateVersionService otf.StateVersionService
Spooler
*Terminator
// contains filtered or unexported fields
}
Supervisor supervises concurrently running workers.
func NewSupervisor ¶
func NewSupervisor(spooler Spooler, cvs otf.ConfigurationVersionService, svs otf.StateVersionService, rs otf.RunService, logger logr.Logger, concurrency int) *Supervisor
NewSupervisor is the constructor for Supervisor
func (*Supervisor) Start ¶
func (s *Supervisor) Start(ctx context.Context)
Start starts the supervisor's workers.
type Terminator ¶
type Terminator struct {
// contains filtered or unexported fields
}
Terminator handles canceling items using their ID
func NewTerminator ¶
func NewTerminator() *Terminator
func (*Terminator) Cancel ¶
func (t *Terminator) Cancel(id string, force bool)
func (*Terminator) CheckIn ¶
func (t *Terminator) CheckIn(id string, job Cancelable)
func (*Terminator) CheckOut ¶
func (t *Terminator) CheckOut(id string)