Documentation ¶
Index ¶
- Constants
- Variables
- func ConnectCloudwatchBezosClient() error
- func NewCheckTargets(resolver Resolver, check *schema.Check) (*schema.CheckTargets, error)
- type AWSResolver
- type CheckTimer
- type Checker
- func (c *Checker) CreateCheck(ctx context.Context, req *opsee.CheckResourceRequest) (*opsee.ResourceResponse, error)
- func (c *Checker) DeleteCheck(ctx context.Context, req *opsee.CheckResourceRequest) (*opsee.ResourceResponse, error)
- func (c *Checker) GetExistingChecks(tries int) ([]*schema.Check, error)
- func (c *Checker) RetrieveCheck(ctx context.Context, req *opsee.CheckResourceRequest) (*opsee.ResourceResponse, error)
- func (c *Checker) Start() error
- func (c *Checker) Stop()
- func (c *Checker) TestCheck(ctx context.Context, req *opsee.TestCheckRequest) (*opsee.TestCheckResponse, error)
- func (c *Checker) UpdateCheck(ctx context.Context, req *opsee.CheckResourceRequest) (*opsee.ResourceResponse, error)
- type CheckerRpcClient
- type CloudWatchRequest
- type CloudWatchWorker
- type Dispatcher
- type HTTPRequest
- type HTTPWorker
- type Interval
- type MetricStatisticsResponse
- type NSQRunner
- type NSQRunnerConfig
- type NewWorkerFunc
- type Publisher
- type RemoteRunner
- type Request
- type Resolver
- type Response
- type Runner
- type Scheduler
- type SlateClient
- type SlateRequest
- type SlateResponse
- type Task
- type TaskGroup
- type Worker
Constants ¶
const ( // MaxTestTargets is the maximum number of test-check targets returned // from the resolver that we use. MaxTestTargets = 5 NumCheckSyncRetries = 11 // BastionProtoVersion is used for feature flagging fields in various Bastion // message types that specify a version number. BastionProtoVersion = 2 // Time to allow requests to read a response body. BodyReadTimeout = 10 * time.Second // Maximum length of response bodies MaxContentLength = 128000 )
const ( MaxRoutinesPerWorkerType = 10 MaxQueueDepth = 10 )
const (
// Checks with an interval less than 15 seconds will fail to be created.
MinimumCheckInterval = 15
)
Variables ¶
var ( BezosClient opsee.BezosClient CloudWatchStatisticsPeriod = 60 )
var (
DefaultResponseCacheTTL = time.Second * time.Duration(5)
)
var Recruiters = &recruiters{ recruitersMap: make(map[string]NewWorkerFunc), }
Functions ¶
func ConnectCloudwatchBezosClient ¶
func ConnectCloudwatchBezosClient() error
func NewCheckTargets ¶
Types ¶
type AWSResolver ¶
type AWSResolver struct { BezosClient opsee.BezosClient VpcId string Region string User *schema.User }
TODO: The resolver should not query the EC2Scanner directly, but should go through the instance/group cache instead.
type CheckTimer ¶
CheckTimer sends a check over a channel at a set interval. TODO(greg): Instead of sending check pointers over this channel, we should send a check execution task -- some wrapper object with a context that includes a deadline. Basically, add contexts to scheduled executions.
func NewCheckTimer ¶
NewCheckTimer creates a new timer and associates the given channel with that timer. Every N seconds (the Check's Duration field), the CheckTimer will send the check over the runChan channel. If this channel blocks for more than N seconds, you will start executing stale check requests. Managing backpressure for this channel is important. TODO(greg): manage backpressure for this channel.
type Checker ¶
type Checker struct { Port int Scheduler *Scheduler Runner *RemoteRunner // contains filtered or unexported fields }
func NewChecker ¶
func (*Checker) CreateCheck ¶
func (c *Checker) CreateCheck(ctx context.Context, req *opsee.CheckResourceRequest) (*opsee.ResourceResponse, error)
func (*Checker) DeleteCheck ¶
func (c *Checker) DeleteCheck(ctx context.Context, req *opsee.CheckResourceRequest) (*opsee.ResourceResponse, error)
func (*Checker) GetExistingChecks ¶
func (*Checker) RetrieveCheck ¶
func (c *Checker) RetrieveCheck(ctx context.Context, req *opsee.CheckResourceRequest) (*opsee.ResourceResponse, error)
func (*Checker) TestCheck ¶
func (c *Checker) TestCheck(ctx context.Context, req *opsee.TestCheckRequest) (*opsee.TestCheckResponse, error)
func (*Checker) UpdateCheck ¶
func (c *Checker) UpdateCheck(ctx context.Context, req *opsee.CheckResourceRequest) (*opsee.ResourceResponse, error)
type CheckerRpcClient ¶
type CheckerRpcClient struct { Client opsee.CheckerClient // contains filtered or unexported fields }
func NewRpcClient ¶
func NewRpcClient(host string, port int) (*CheckerRpcClient, error)
func (*CheckerRpcClient) Close ¶
func (c *CheckerRpcClient) Close()
type CloudWatchRequest ¶
type CloudWatchRequest struct { User *schema.User Region string VpcId string MaxAge time.Duration Target *schema.Target Metrics []*schema.CloudWatchMetric Namespace string StatisticsIntervalSecs int StatisticsPeriod int Statistics []string }
func (*CloudWatchRequest) Do ¶
func (this *CloudWatchRequest) Do(ctx context.Context) <-chan *Response
func (*CloudWatchRequest) GetDimensions ¶
func (this *CloudWatchRequest) GetDimensions(metric *schema.CloudWatchMetric) ([]*opsee_aws_cloudwatch.Dimension, error)
TODO(dan) should we add a target to the metric or assume that they all have the same target
type CloudWatchWorker ¶
type CloudWatchWorker struct {
// contains filtered or unexported fields
}
type Dispatcher ¶
type Dispatcher struct {
// contains filtered or unexported fields
}
func NewDispatcher ¶
func NewDispatcher() *Dispatcher
NewDispatcher returns a dispatcher with populated internal worker groups.
func (*Dispatcher) Dispatch ¶
func (d *Dispatcher) Dispatch(ctx context.Context, tg TaskGroup) chan *Task
Dispatch guarantees that every Task in a TaskGroup has a response. A call to Dispatch will return a channel that is closed when all tasks have finished completion. Cancelling the context will cause Dispatch to insert an error as the response that indicates the context was cancelled.
type HTTPRequest ¶
type HTTPWorker ¶
type HTTPWorker struct {
// contains filtered or unexported fields
}
type NSQRunner ¶
type NSQRunner struct {
// contains filtered or unexported fields
}
func NewNSQRunner ¶
func NewNSQRunner(runner *Runner, cfg *NSQRunnerConfig) (*NSQRunner, error)
type NSQRunnerConfig ¶
type NewWorkerFunc ¶
type RemoteRunner ¶
func NewRemoteRunner ¶
func NewRemoteRunner(cfg *NSQRunnerConfig) (*RemoteRunner, error)
func (*RemoteRunner) RunCheck ¶
func (r *RemoteRunner) RunCheck(ctx context.Context, checkWithTargets *schema.CheckTargets) (*schema.CheckResult, error)
func (*RemoteRunner) Stop ¶
func (r *RemoteRunner) Stop()
type Resolver ¶
A Respolver resolves a target into an array of targets that are * directly addressable by a bastion component. * * It is important to note, that Target IDs should be unique across * a set of responses. This makes them
func NewResolver ¶
func NewResolver(bezos opsee.BezosClient, cfg *config.Config) Resolver
type Response ¶
type Response struct { Response schema.CheckResponseReply Error error }
type Runner ¶
type Runner struct {
// contains filtered or unexported fields
}
A Runner is responsible for running checks. Given a request for a check (see: RunCheck), it will execute that check within a context, returning a response for every resolved check target. The Runner is not meant for concurrent use. It provides an asynchronous API for submitting jobs and manages its own concurrency.
func NewRunner ¶
func NewRunner(checkType interface{}) *Runner
NewRunner returns a runner associated with a particular resolver.
func (*Runner) RunCheck ¶
func (r *Runner) RunCheck(ctx context.Context, check *schema.Check, targets []*schema.Target) ([]*schema.CheckResponse, error)
If the Context passed to RunCheck includes a MaxHosts value, at most MaxHosts CheckResponse objects will be returned.
If the Context passed to RunCheck is cancelled or its deadline is exceeded, all CheckResponse objects after that event will be passed to the channel with appropriate errors associated with them.
type Scheduler ¶
type Scheduler struct { Producer Publisher // contains filtered or unexported fields }
Scheduler is responsible for managing the set of timers used for checks
as well as publishing requests for runners to run checks.
func NewScheduler ¶
func (*Scheduler) CreateCheck ¶
func (*Scheduler) DeleteCheck ¶
func (*Scheduler) RetrieveCheck ¶
type SlateClient ¶
type SlateClient struct { // MaxRetries is the number of times the SlateClient will retry a failed // request. Default: 11 MaxRetries int // contains filtered or unexported fields }
SlateClient -- for clienting slates.
func NewSlateClient ¶
func NewSlateClient(slateUrl string) *SlateClient
func (*SlateClient) CheckAssertions ¶
func (s *SlateClient) CheckAssertions(ctx context.Context, check *schema.Check, checkResponse json.RawMessage) (bool, error)
CheckAssertions issues a request to Slate to determine if a check response is passing or failing.
type SlateRequest ¶
type SlateRequest struct { Assertions []*schema.Assertion `json:"assertions"` Response json.RawMessage `json:"response"` }