Documentation ¶
Index ¶
- Variables
- func EventDebugArgs(event *pb.Operation_Event) []any
- func EventTypeString(event *pb.Operation_Event) string
- func NewEventFromResponse(res *pb.Operation_Response) (*pb.Operation_Event, error)
- func NewReferenceFromRequest(op *pb.Operation_Request) (*pb.Ref_Operation, error)
- func NewResponseFromRequest(op *pb.Operation_Request) (*pb.Operation_Response, error)
- func ReferenceDebugArgs(ref *pb.Ref_Operation) []any
- func RequestDebugArgs(req *pb.Operation_Request) []any
- func RequestTypeString(op *pb.Operation_Request) string
- func ResponseDebugArgs(res *pb.Operation_Response) []any
- func ResponseTypeString(op *pb.Operation_Response) string
- type EventSender
- type LocalOperator
- func (o *LocalOperator) Dispatch(req *pb.Operation_Request) (*pb.Ref_Operation, []*pb.Diagnostic)
- func (o *LocalOperator) Response(op *pb.Ref_Operation) (*pb.Operation_Response, error)
- func (o *LocalOperator) Start(ctx context.Context) error
- func (o *LocalOperator) State() state.State
- func (o *LocalOperator) Stop() error
- func (o *LocalOperator) Stream(op *pb.Ref_Operation) (*Subscriber, Unsubscriber, error)
- type LocalOperatorOpt
- type Operator
- type Publisher
- type PublisherOpt
- type Runner
- type RunnerOpt
- type Subscriber
- type SubscriberOpt
- type Subscribers
- type TextOutput
- type Unsubscriber
- type WorkFunc
- func CheckScenario(req *pb.Operation_Request) WorkFunc
- func DestroyScenario(req *pb.Operation_Request) WorkFunc
- func ExecScenario(req *pb.Operation_Request) WorkFunc
- func GenerateScenario(req *pb.Operation_Request) WorkFunc
- func LaunchScenario(req *pb.Operation_Request) WorkFunc
- func OutputScenario(req *pb.Operation_Request) WorkFunc
- func RunScenario(req *pb.Operation_Request) WorkFunc
- func UnknownWorkFunc(req *pb.Operation_Request) (WorkFunc, error)
Constants ¶
This section is empty.
Variables ¶
var ( // DefaultOperatorWorkerCount is how many workers to run. The number of // parallel operations is limited to the number of workers. DefaultOperatorWorkerCount int32 = 4 // DefaultOperatorMaxOperationQueue is default maximum number of queued // operations. DefaultOperatorMaxOperationQueue = 10000 // DefaultOperatorMaxOperationEventQueue is the maximum number of events // that can be queued before being persisted in the state by the event // handler. DefaultOperatorMaxOperationEventQueue = 1000 )
Functions ¶
func EventDebugArgs ¶
func EventDebugArgs(event *pb.Operation_Event) []any
EventDebugArgs takes a reference to an operation event and returns a slice of arguments that can be passed ton an hclog.Logger instance for debugging.
func EventTypeString ¶
func EventTypeString(event *pb.Operation_Event) string
EventTypeString takes a reference to an operation event and returns the type of event as a string.
func NewEventFromResponse ¶
func NewEventFromResponse(res *pb.Operation_Response) (*pb.Operation_Event, error)
NewEventFromResponse takes a reference to an operation response and returns a reference to a new operation event. If an error is encountered it will return an event that contains diagnostics of the error as well as an error if possible.
func NewReferenceFromRequest ¶
func NewReferenceFromRequest(op *pb.Operation_Request) (*pb.Ref_Operation, error)
NewReferenceFromRequest takes a reference to an operation request and returns a new reference to the associated operation.
func NewResponseFromRequest ¶
func NewResponseFromRequest(op *pb.Operation_Request) (*pb.Operation_Response, error)
NewResponseFromRequest takes a reference for an operation request and returns a reference to a new operation response.
func ReferenceDebugArgs ¶
func ReferenceDebugArgs(ref *pb.Ref_Operation) []any
ReferenceDebugArgs takes a reference to an operation reference and returns a slice of arguments that can be passed ton an hclog.Logger instance for debugging.
func RequestDebugArgs ¶
func RequestDebugArgs(req *pb.Operation_Request) []any
RequestDebugArgs takes a reference to an operation request and returns a slice of arguments that can be passed ton an hclog.Logger instance for debugging.
func RequestTypeString ¶
func RequestTypeString(op *pb.Operation_Request) string
RequestTypeString takes a reference to an operation request and returns the type of request as a string.
func ResponseDebugArgs ¶
func ResponseDebugArgs(res *pb.Operation_Response) []any
ResponseDebugArgs takes a reference to an operation response and returns a slice of arguments that can be passed ton an hclog.Logger instance for debugging.
func ResponseTypeString ¶
func ResponseTypeString(op *pb.Operation_Response) string
ResponseTypeString takes a reference to an operation response and returns the type of response as a string.
Types ¶
type EventSender ¶
type EventSender struct {
// contains filtered or unexported fields
}
func NewEventSender ¶
func NewEventSender(events chan *pb.Operation_Event) *EventSender
func (*EventSender) Publish ¶
func (e *EventSender) Publish(event *pb.Operation_Event) error
func (*EventSender) PublishResponse ¶
func (e *EventSender) PublishResponse(res *pb.Operation_Response) error
type LocalOperator ¶
type LocalOperator struct {
// contains filtered or unexported fields
}
LocalOperator is an in-memory implementation of the server Operator.
func NewLocalOperator ¶
func NewLocalOperator(opts ...LocalOperatorOpt) *LocalOperator
NewLocalOperator returns a new instance of a LocalOperator.
func (*LocalOperator) Dispatch ¶
func (o *LocalOperator) Dispatch( req *pb.Operation_Request, ) ( *pb.Ref_Operation, []*pb.Diagnostic, )
Dispatch takes an operation request and attempts to dispatch it for execution by the operators worker pool. If the request is successfully converted into a work operation and queued it will return a reference for the operation to the caller.
func (*LocalOperator) Response ¶
func (o *LocalOperator) Response(op *pb.Ref_Operation) (*pb.Operation_Response, error)
Response takes a reference to an operation and returns the response. If no response is found nil will be returned.
func (*LocalOperator) Start ¶
func (o *LocalOperator) Start(ctx context.Context) error
Start starts the operator.
func (*LocalOperator) State ¶
func (o *LocalOperator) State() state.State
State returns the operators state.
func (*LocalOperator) Stop ¶
func (o *LocalOperator) Stop() error
Stop stops the operator. It attempts to gracefully terminate all operations.
func (*LocalOperator) Stream ¶
func (o *LocalOperator) Stream(op *pb.Ref_Operation) (*Subscriber, Unsubscriber, error)
Stream takes a reference to an operation and returns an event subscriber for the operation, an unsubscriber function, and an error. The subscriber can be used to publish and receive events from the event stream. When the unsubscriber function is called the operators event handler will stop publishing events to the subscriber.
type LocalOperatorOpt ¶
type LocalOperatorOpt func(*LocalOperator)
LocalOperatorOpt is a functional option to configure a new LocalOperator.
func WithLocalOperatorConfig ¶
func WithLocalOperatorConfig(cfg *pb.Operator_Config) LocalOperatorOpt
WithLocalOperatorConfig takes the operator configuration and sets it on the local operator.
func WithLocalOperatorLog ¶
func WithLocalOperatorLog(log hclog.Logger) LocalOperatorOpt
WithLocalOperatorLog is a log setter for a new LocalOperator.
func WithLocalOperatorState ¶
func WithLocalOperatorState(s state.State) LocalOperatorOpt
WithLocalOperatorState is a state setter for a new LocalOperator.
type Operator ¶
type Operator interface { Dispatch(req *pb.Operation_Request) (*pb.Ref_Operation, []*pb.Diagnostic) Stream(ref *pb.Ref_Operation) (*Subscriber, Unsubscriber, error) Response(ref *pb.Ref_Operation) (*pb.Operation_Response, error) Stop() error Start(ctx context.Context) error State() state.State }
Operator is the server operation handler.
type Publisher ¶
type Publisher struct {
// contains filtered or unexported fields
}
Publisher is the operation event publisher.
func NewPublisher ¶
func NewPublisher(opts ...PublisherOpt) *Publisher
NewPublisher returns a new instance of the publisher.
func (*Publisher) Publish ¶
func (p *Publisher) Publish(event *pb.Operation_Event) error
Publish publishes an operation event to listeners for the operationID.
func (*Publisher) Stop ¶
func (p *Publisher) Stop()
Stop closes all subscribers and removes and clears the subscribers list.
func (*Publisher) Subscribe ¶
func (p *Publisher) Subscribe(s *Subscriber) Unsubscriber
Subscribe adds a new subscribers for the operation and returns a closer function.
func (*Publisher) Unsubscribe ¶
func (p *Publisher) Unsubscribe(s *Subscriber)
Unsubscribe unsubscribes a subscriber.
type PublisherOpt ¶
type PublisherOpt func(*Publisher)
PublisherOpt is a NewPublisher option.
func WithPublisherLog ¶
func WithPublisherLog(log hclog.Logger) PublisherOpt
WithPublisherLog sets the logger on the publisher.
type Runner ¶
type Runner struct { TFConfig *terraform.Config Module *pb.Terraform_Module // contains filtered or unexported fields }
Runner is a Terraform command runner.
type RunnerOpt ¶
type RunnerOpt func(*Runner)
RunnerOpt is a validate module option.
func WithRunnerTerraformConfig ¶
func WithRunnerTerraformConfig(cfg *pb.Terraform_Runner_Config) RunnerOpt
WithRunnerTerraformConfig configures the Runner with RunnerConfig passed over the wire.
type Subscriber ¶
type Subscriber struct { ID string Events chan *pb.Operation_Event // contains filtered or unexported fields }
Subscriber is an event subscriber.
func NewSubscriber ¶
func NewSubscriber( ref *pb.Ref_Operation, opts ...SubscriberOpt, ) ( *Subscriber, error, )
NewSubscriber takes an operation request and returns a new subscriber instance.
func (*Subscriber) Send ¶
func (s *Subscriber) Send(event *pb.Operation_Event)
Send sends an event to the subscribers event channel. Send will block until something pulls from the events channel.
type SubscriberOpt ¶
type SubscriberOpt func(*Subscriber)
SubscriberOpt is a new subscriber option.
func WithSubscriberLog ¶
func WithSubscriberLog(log hclog.Logger) SubscriberOpt
WithSubscriberLog sets the subscriber logger.
type Subscribers ¶
type Subscribers map[string]*Subscriber
Subscribers are operation event subscribers.
type TextOutput ¶
TextOutput is a terraform text output collector.
type Unsubscriber ¶
type Unsubscriber func()
Unsubscriber is a func that unsubscribes that subscriber from the publisher.
type WorkFunc ¶
type WorkFunc func( context.Context, chan *pb.Operation_Event, hclog.Logger, ) *pb.Operation_Response
WorkFunc is a function that a worker can run.
func CheckScenario ¶
func CheckScenario(req *pb.Operation_Request) WorkFunc
CheckScenario takes an operation request for check and returns a worker function to checks a scenario terraform module.
func DestroyScenario ¶
func DestroyScenario(req *pb.Operation_Request) WorkFunc
func DestroyScenario takes an operation request for generate and returns a worker function to generate a terraform module for a scenario.
func ExecScenario ¶
func ExecScenario(req *pb.Operation_Request) WorkFunc
func ExecScenario takes an operation request for generate and returns a worker function to generate a terraform module for a scenario.
func GenerateScenario ¶
func GenerateScenario(req *pb.Operation_Request) WorkFunc
GenerateScenario takes an operation request for generate and returns a worker function to generate a terraform module for a scenario.
func LaunchScenario ¶
func LaunchScenario(req *pb.Operation_Request) WorkFunc
LaunchScenario takes an operation request for check and returns a worker function to checks a scenario terraform module.
func OutputScenario ¶
func OutputScenario(req *pb.Operation_Request) WorkFunc
func OutputScenario takes an operation request for generate and returns a worker function to generate a terraform module for a scenario.
func RunScenario ¶
func RunScenario(req *pb.Operation_Request) WorkFunc
RunScenario takes an operation request for generate and returns a worker function to generate a terraform module for a scenario.
func UnknownWorkFunc ¶
func UnknownWorkFunc(req *pb.Operation_Request) (WorkFunc, error)
UnknownWorkFunc takes an operation request and returns a work func that will fail because it is unknown.
Source Files ¶
- event_publisher.go
- event_sender.go
- event_subscriber.go
- flightplan.go
- operation.go
- operator.go
- operator_local.go
- runner.go
- runner_module_generate.go
- runner_scenario_check.go
- runner_scenario_destroy.go
- runner_scenario_exec.go
- runner_scenario_generate.go
- runner_scenario_launch.go
- runner_scenario_output.go
- runner_scenario_run.go
- runner_terraform_apply.go
- runner_terraform_destroy.go
- runner_terraform_exec.go
- runner_terraform_init.go
- runner_terraform_output.go
- runner_terraform_plan.go
- runner_terraform_show.go
- runner_terraform_validate.go
- runner_unknown_work.go
- worker.go