Documentation
¶
Overview ¶
Package batch emulates AWS Batch over REST-JSON: compute environments, job queues, scheduling policies, job definitions and jobs. With a container engine every job attempt runs as a container (array jobs, dependencies, retries and timeouts included) and logs to CloudWatch Logs; without one, jobs wait in RUNNABLE.
Index ¶
- Constants
- type Array
- type Attempt
- type Container
- type Def
- type Dep
- type Env
- type Job
- type KV
- type Need
- type OnExit
- type Order
- type Policy
- type Queue
- type Retry
- type Service
- func (s *Service) Close() error
- func (s *Service) Info() core.Info
- func (s *Service) Inspect(table, id string) any
- func (s *Service) Load(b []byte) error
- func (s *Service) Reset()
- func (s *Service) Resources() []core.Table
- func (s *Service) Save() ([]byte, error)
- func (s *Service) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (s *Service) Tick(now time.Time)
- type Timeout
Constants ¶
const NoDocker = "pogi: Docker is not available, so jobs cannot run"
NoDocker is the status reason of jobs that wait for a container engine.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Array ¶
type Array struct {
Size int `json:"size,omitempty"`
Index *int `json:"index,omitempty"`
Summary map[string]int `json:"statusSummary,omitempty"`
}
Array is an array job's size and its children's statuses, or a child's index.
type Attempt ¶
type Attempt struct {
Container *Container `json:"container"`
Started int64 `json:"startedAt,omitempty"`
Stopped int64 `json:"stoppedAt,omitempty"`
Reason string `json:"statusReason,omitempty"`
}
Attempt is how one try of a job ended.
type Container ¶
type Container struct {
Image string `json:"image,omitempty"`
Command []string `json:"command,omitempty"`
Environment []KV `json:"environment,omitempty"`
Vcpus int `json:"vcpus,omitempty"`
Memory int `json:"memory,omitempty"`
Resources []Need `json:"resourceRequirements,omitempty"`
JobRole string `json:"jobRoleArn,omitempty"`
ExecutionRole string `json:"executionRoleArn,omitempty"`
User string `json:"user,omitempty"`
ExitCode *int `json:"exitCode,omitempty"`
Reason string `json:"reason,omitempty"`
LogStream string `json:"logStreamName,omitempty"`
}
Container is a job's container: its definition's container properties with the overrides applied, and how its last attempt ended.
type Def ¶
type Def struct {
Name string `json:"jobDefinitionName"`
Arn string `json:"jobDefinitionArn"`
Revision int `json:"revision"`
Status string `json:"status"`
Type string `json:"type"`
Parameters map[string]string `json:"parameters,omitempty"`
Retry *Retry `json:"retryStrategy,omitempty"`
Timeout *Timeout `json:"timeout,omitempty"`
Container json.RawMessage `json:"containerProperties,omitempty"`
Node json.RawMessage `json:"nodeProperties,omitempty"`
Eks json.RawMessage `json:"eksProperties,omitempty"`
Ecs json.RawMessage `json:"ecsProperties,omitempty"`
Platform []string `json:"platformCapabilities,omitempty"`
PropagateTags bool `json:"propagateTags,omitempty"`
Priority *int `json:"schedulingPriority,omitempty"`
Tags map[string]string `json:"tags,omitempty"`
}
Def is one revision of a job definition; its container, node, EKS and ECS properties are kept as given.
type Dep ¶
Dep is a dependency: on a job, N_TO_N on an array job of the same size, or SEQUENTIAL among an array job's children.
type Env ¶
type Env struct {
Name string `json:"computeEnvironmentName"`
Arn string `json:"computeEnvironmentArn"`
Type string `json:"type"`
State string `json:"state"`
Status string `json:"status"`
StatusReason string `json:"statusReason,omitempty"`
Unmanaged *int `json:"unmanagedvCpus,omitempty"`
Resources map[string]any `json:"computeResources,omitempty"`
ServiceRole string `json:"serviceRole,omitempty"`
UpdatePolicy map[string]any `json:"updatePolicy,omitempty"`
Eks map[string]any `json:"eksConfiguration,omitempty"`
Context string `json:"context,omitempty"`
Cluster string `json:"ecsClusterArn,omitempty"`
Orchestration string `json:"containerOrchestrationType"`
UUID string `json:"uuid"`
Tags map[string]string `json:"tags,omitempty"`
}
Env is a compute environment; its compute resources are kept as given.
type Job ¶
type Job struct {
ID string `json:"jobId"`
Arn string `json:"jobArn"`
Name string `json:"jobName"`
Queue string `json:"jobQueue,omitempty"`
Def string `json:"jobDefinition"`
Status string `json:"status"`
Reason string `json:"statusReason,omitempty"`
Created int64 `json:"createdAt"`
Started int64 `json:"startedAt,omitempty"`
Stopped int64 `json:"stoppedAt,omitempty"`
Attempts []Attempt `json:"attempts,omitempty"`
DependsOn []Dep `json:"dependsOn,omitempty"`
Parameters map[string]string `json:"parameters,omitempty"`
Container *Container `json:"container,omitempty"`
Array *Array `json:"arrayProperties,omitempty"`
Retry *Retry `json:"retryStrategy,omitempty"`
Timeout *Timeout `json:"timeout,omitempty"`
Platform []string `json:"platformCapabilities,omitempty"`
PropagateTags bool `json:"propagateTags,omitempty"`
Priority *int `json:"schedulingPriority,omitempty"`
Cancelled bool `json:"isCancelled,omitempty"`
Terminated bool `json:"isTerminated,omitempty"`
Tags map[string]string `json:"tags,omitempty"`
// contains filtered or unexported fields
}
Job is a job, an array job's parent or one of its children.
type OnExit ¶
type OnExit struct {
Action string `json:"action"`
OnExitCode string `json:"onExitCode,omitempty"`
OnReason string `json:"onReason,omitempty"`
OnStatusReason string `json:"onStatusReason,omitempty"`
}
OnExit decides whether a failed attempt is retried.
type Policy ¶
type Policy struct {
Name string `json:"name"`
Arn string `json:"arn"`
Tags map[string]string `json:"tags,omitempty"`
}
Policy is a scheduling policy, kept as given.
type Queue ¶
type Queue struct {
Name string `json:"jobQueueName"`
Arn string `json:"jobQueueArn"`
State string `json:"state"`
Status string `json:"status"`
StatusReason string `json:"statusReason,omitempty"`
Priority int `json:"priority"`
Order []Order `json:"computeEnvironmentOrder"`
Policy string `json:"schedulingPolicyArn,omitempty"`
TimeLimits []any `json:"jobStateTimeLimitActions,omitempty"`
Tags map[string]string `json:"tags,omitempty"`
}
Queue is a job queue.
type Retry ¶
type Retry struct {
Attempts int `json:"attempts,omitempty"`
OnExit []OnExit `json:"evaluateOnExit,omitempty"`
}
Retry is a retry strategy.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is the Batch emulator.
func (*Service) Close ¶
Close stops the scheduler and the attempts still running, removing their containers.