Documentation ¶
Index ¶
- Constants
- func ErrCode(msg string, err error) error
- func NewID() string
- type DatabaseRunner
- type DummyRunner
- type InstanceRunner
- type Job
- type Locker
- type QueueError
- type QueuedJob
- type Queuer
- type RedisLocker
- type RedisQueuer
- type Repository
- type Runner
- type RunnerError
- type S3Repository
- func (s *S3Repository) Create(ctx context.Context, account, group string, job *Job) (*Job, error)
- func (s *S3Repository) Delete(ctx context.Context, account, group, id string) error
- func (s *S3Repository) Get(ctx context.Context, account, group, id string) (*Job, error)
- func (s *S3Repository) List(ctx context.Context, account, group string) ([]string, error)
- func (s *S3Repository) Update(ctx context.Context, account, group, id string, job *Job) (*Job, error)
- type S3RepositoryOption
- type ServiceRunner
- type ServiceRunnerScaleInput
- type Tag
- type TaskRunner
- type TaskRunnerRunInput
Constants ¶
const ErrExecFailure = "ExecutionFailure"
const ErrMissingDetails = "MissingDetails"
const ErrPostExecFailure = "PostExecutionFailure"
const ErrPreExecFailure = "PreExecutionFailure"
const ErrQueueIsEmpty = "QueueIsEmpty"
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DatabaseRunner ¶ added in v0.9.0
func NewDatabaseRunner ¶ added in v0.9.0
func NewDatabaseRunner(config map[string]interface{}) (*DatabaseRunner, error)
NewDatabaseRunner creates and configures a new database runner. An endpoint or endpoint template is required the endpoint and endpoint template are not currently validated but this can/should be done in the future. If a a token is passed, it will be configured but is not required.
func (*DatabaseRunner) Run ¶ added in v0.9.0
func (r *DatabaseRunner) Run(ctx context.Context, account string, parameters interface{}) (string, error)
Run executes the DatabaseRunner. The instance_id and database_action are required. Allowable actions are 'start' and 'stop'. If an endpoint is configured on the runner, it will be used, otherwise we assume there is an endpointTemplate and try to execute it. Database actions are currently only executed with the PUT method and a body containing {"state": "action"}.
type DummyRunner ¶
type DummyRunner struct {
Template string
}
func NewDummyRunner ¶
func NewDummyRunner(config map[string]interface{}) (*DummyRunner, error)
NewDummyRunner creates a new dummy runner that doesn't do anything, but requires a template and returns that executed template when called
type InstanceRunner ¶
type InstanceRunner struct { Endpoint string EndpointTemplate string Token string Encrypt bool AuthHeader string }
func NewInstanceRunner ¶
func NewInstanceRunner(config map[string]interface{}) (*InstanceRunner, error)
NewInstanceRunner creates and configures a new instance runner. An endpoint or endpoint template is required the endpoint and endpoint template are not currently validated but this can/should be done in the future. If a a token is passed, it will be configured but is not required.
func (*InstanceRunner) Run ¶
func (r *InstanceRunner) Run(ctx context.Context, account string, parameters interface{}) (string, error)
Run executes the InstanceRunner. The instance_id and instance_action are required. Allowable actions are 'start', 'stop' and 'reboot'. If an endpoint is configured on the runner, it will be used, otherwise we assume there is an endpointTemplate and try to execute it. Instance actions are currently only executed with the PUT method and a body containing {"state": "action"}.
type Job ¶
type Job struct { Account string Description string Details map[string]string Enabled bool ID string ModifiedBy string ModifiedAt *time.Time Name string Group string ScheduleExpression string }
Job is the detail about a job
func (*Job) MarshalBinary ¶
func (Job) MarshalJSON ¶
MarshalJSON is a custom JSON marshaller for a job
func (*Job) NextRun ¶ added in v0.6.1
NextRun returns the next invocation of the schedule expression
func (*Job) UnmarshalBinary ¶
func (*Job) UnmarshalJSON ¶
UnmarshalJSON is a custom JSON unmarshaller for a job
type QueueError ¶
Error wraps lower level errors with code, message and an original error
func NewQueueError ¶
func NewQueueError(code, message string, err error) QueueError
New constructs a QueueError and returns it as an error
type RedisLocker ¶
type RedisLocker struct { Expire time.Duration Prefix string // contains filtered or unexported fields }
RedisLocker is a redis lock/unlock provider.
func NewRedisLocker ¶
func NewRedisLocker(prefix, address, password string, db int, expiration string) (*RedisLocker, error)
NewRedisLocker returns a new redis lock provider
func (*RedisLocker) Lock ¶
func (l *RedisLocker) Lock(key, id string) error
Lock locks l.Prefix-key with the value id in a redis set. This uses SetNX. If the result is an error or false, the key was not set and the lock was not aquired.
type RedisQueuer ¶
type RedisQueuer struct { BackupName string Name string Window int64 // contains filtered or unexported fields }
func NewRedisQueuer ¶
func NewRedisQueuer(name, address, password string, db int, window int64) (*RedisQueuer, error)
func (*RedisQueuer) Enqueue ¶
func (q *RedisQueuer) Enqueue(queued *QueuedJob) error
Add jobs to both sets
func (*RedisQueuer) Fetch ¶
func (q *RedisQueuer) Fetch(queued *QueuedJob) error
func (*RedisQueuer) Finalize ¶
func (q *RedisQueuer) Finalize(id string) error
Finalize does the final steps once a job is completed successfully, currently this is just dequeuing the backup job created when the job was queued.
type Repository ¶
type Repository interface { Create(ctx context.Context, account, group string, job *Job) (*Job, error) Delete(ctx context.Context, account, group, id string) error Get(ctx context.Context, account, group, id string) (*Job, error) List(ctx context.Context, account, group string) ([]string, error) Update(ctx context.Context, account, group, id string, job *Job) (*Job, error) }
type Runner ¶
type Runner interface {
Run(ctx context.Context, account string, parameters interface{}) (string, error)
}
Runner has a Run method and runs a job
type RunnerError ¶
func NewRunnerError ¶
func NewRunnerError(code, message string, err error) RunnerError
New constructs a RunnerError and returns it as an error
type S3Repository ¶
type S3Repository struct { S3 s3iface.S3API Bucket string Prefix string // contains filtered or unexported fields }
S3Repository is an implementation of a jobs respository in S3
func New ¶
func New(opts ...S3RepositoryOption) (*S3Repository, error)
New creates an S3Repository from a list of S3RepositoryOption functions
func NewDefaultRepository ¶
func NewDefaultRepository(config map[string]interface{}) (*S3Repository, error)
NewDefaultRepository creates a new repository from the default config data
func (*S3Repository) Delete ¶
func (s *S3Repository) Delete(ctx context.Context, account, group, id string) error
Delete deletes a job in the s3 jobs repository
func (*S3Repository) Get ¶
Get gets a job from the s3 jobs repository - jobs are in the path /<account>/<group>/<job id>
type S3RepositoryOption ¶
type S3RepositoryOption func(*S3Repository)
S3RepositoryOption is a function to set repository options
func WithBucket ¶
func WithBucket(bucket string) S3RepositoryOption
WithBucket sets the bucket for the S3Repository
func WithEndpoint ¶
func WithEndpoint(endpoint string) S3RepositoryOption
WithEndpoint sets the endpoint for the S3Repository
func WithPrefix ¶
func WithPrefix(prefix string) S3RepositoryOption
WithPrefix sets the bucket prefix for the S3Repository
func WithRegion ¶
func WithRegion(region string) S3RepositoryOption
WithRegion sets the region for the S3Repository
func WithStaticCredentials ¶
func WithStaticCredentials(akid, secret, token string) S3RepositoryOption
WithStaticCredentials authenticates with AWS static credentials (key, secret, token)
type ServiceRunner ¶ added in v0.6.0
type ServiceRunner struct { Endpoint string EndpointTemplate string Token string Encrypt bool AuthHeader string }
func NewServiceRunner ¶ added in v0.6.0
func NewServiceRunner(config map[string]interface{}) (*ServiceRunner, error)
NewServiceRunner creates and configures a new service runner. An endpoint or endpoint template is required the endpoint and endpoint template are not currently validated but this can/should be done in the future. If a a token is passed, it will be configured but is not required.
func (*ServiceRunner) Run ¶ added in v0.6.0
func (r *ServiceRunner) Run(ctx context.Context, account string, parameters interface{}) (string, error)
Run executes the ServiceRunner. The service_cluster, service_name and service_action are required. Allowable actions are 'scale'. If an endpoint is configured on the runner, it will be used, otherwise we assume there is an endpointTemplate and try to execute it.
type ServiceRunnerScaleInput ¶ added in v0.6.0
type TaskRunner ¶ added in v0.10.0
type TaskRunner struct { Endpoint string EndpointTemplate string Token string Encrypt bool AuthHeader string }
func NewTaskRunner ¶ added in v0.10.0
func NewTaskRunner(config map[string]interface{}) (*TaskRunner, error)
NewTaskRunner creates and configures a new task runner. An endpoint or endpoint template is required the endpoint and endpoint template are not currently validated but this can/should be done in the future. If a token is passed, it will be configured but is not required.
func (*TaskRunner) Run ¶ added in v0.10.0
func (r *TaskRunner) Run(ctx context.Context, account string, parameters interface{}) (string, error)
Run executes the TaskRunner. The task_cluster, task_name and task_action are required. Allowable actions are 'run'. If an endpoint is configured on the runner, it will be used, otherwise we assume there is an endpointTemplate and try to execute it.