simulator

package
v0.11.14 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2020 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadHosts

func LoadHosts(dir string, logger log.Logger) (map[string]*queryRunner, error)

LoadHosts will load the host specifications and return a map of the queryRunners representing these host types.

Types

type HostSimulation

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

HostSimulation is the type which contains the state of a simulated host

func LaunchSimulation

func LaunchSimulation(logger log.Logger, host QueryRunner, grpcURL, uuid, enrollSecret string, opts ...SimulationOption) *HostSimulation

LaunchSimulation is a utility which allows the user to configure and run an asynchronous instance of a host simulation given a set of functional options

func (*HostSimulation) Enroll

func (h *HostSimulation) Enroll() error

Enroll is the implementation of the host simulation's enrollment functionality

func (*HostSimulation) Healthy

func (h *HostSimulation) Healthy() bool

Healthy is a helper which performs an introspection on the simulation instance to determine whether or not it is healthy

func (*HostSimulation) PublishLogs

func (h *HostSimulation) PublishLogs() error

PublishLogs is the implementation of the host simulation's log publishing functionality

func (*HostSimulation) RequestConfig

func (h *HostSimulation) RequestConfig() error

RequestConfig is the implementation of the host simulation's config retrieval functionality

func (*HostSimulation) RequestQueries

func (h *HostSimulation) RequestQueries() error

RequestQueries is the implementation of the host simulation's request new queries functionality

func (*HostSimulation) Shutdown

func (h *HostSimulation) Shutdown() error

Shutdown will attempt to gracefully shutdown the simulation

type QueryRunner

type QueryRunner interface {
	RunQuery(sql string) (results []map[string]string, err error)
}

QueryRunner is the interface which defines the pluggable behavior of a simulated host. Each "type" of host may have their own implementation of this interface.

type SimulationOption

type SimulationOption func(*HostSimulation)

SimulationOption is a functional option pattern for defining how a host simulation instance should be configured. For more information on this patter, see the following blog post: https://dave.cheney.net/2014/10/17/functional-options-for-friendly-apis

func WithInsecure

func WithInsecure() SimulationOption

WithInsecure is a functional option which allows the user to declare that when connecting to the remote API, the client should skip TLS certificate verification but still use TLS

func WithInsecureGrpc

func WithInsecureGrpc() SimulationOption

WithInsecureGrpc is a functional option which allows the user to declare that WithInsecure is a functional option which allows the user to declare that when connecting to the remote API, the client should turn off TLS entirely

func WithPublishLogsInterval

func WithPublishLogsInterval(interval time.Duration) SimulationOption

WithPublishLogsInterval is a functional option which allows the user to specify how often the simulation host should log status and results logs

func WithRequestConfigInterval

func WithRequestConfigInterval(interval time.Duration) SimulationOption

WithRequestConfigInterval is a functional option which allows the user to specify how often the simulation host should check-in to the server and ask for a new config

func WithRequestQueriesInterval

func WithRequestQueriesInterval(interval time.Duration) SimulationOption

WithRequestQueriesInterval is a functional option which allows the user to specify how often the simulation host should check-in to the server and ask for queries to run

Jump to

Keyboard shortcuts

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