Documentation ¶
Index ¶
- func TmpFile() string
- type CloudFoundryConfig
- type Context
- func DRMAA2SessionManagerContext(sm drmaa2interface.SessionManager) *Context
- func ErrorTestContext() *Context
- func NewCloudFoundryContext() *Context
- func NewCloudFoundryContextByCfg(cfg CloudFoundryConfig) *Context
- func NewDockerContext() *Context
- func NewDockerContextByCfg(cfg DockerConfig) *Context
- func NewKubernetesContext() *Context
- func NewKubernetesContextByCfg(cfg KubernetesConfig) *Context
- func NewProcessContext() *Context
- func NewProcessContextByCfg(cfg ProcessConfig) *Context
- func NewSingularityContext() *Context
- func NewSingularityContextByCfg(cfg SingularityConfig) *Context
- type DockerConfig
- type Iterator
- type Job
- func (j *Job) After(d time.Duration) *Job
- func (j *Job) AnyFailed() bool
- func (j *Job) Do(f func(job drmaa2interface.Job)) *Job
- func (j *Job) Errored() bool
- func (j *Job) ExitStatus() int
- func (j *Job) Failed() bool
- func (j *Job) HasAnyFailed() bool
- func (j *Job) JobID() string
- func (j *Job) JobInfo() drmaa2interface.JobInfo
- func (j *Job) JobInfos() []drmaa2interface.JobInfo
- func (j *Job) Kill() *Job
- func (j *Job) LastError() error
- func (j *Job) ListAllFailed() []drmaa2interface.Job
- func (j *Job) Notify(n *Notifier) *Job
- func (j *Job) Observe(o Observer) *Job
- func (j *Job) OnError(f func(err error)) *Job
- func (j *Job) OnFailure(f func(job drmaa2interface.Job)) *Job
- func (j *Job) OnFailureRun(cmd string, args ...string) *Job
- func (j *Job) OnFailureRunT(jt drmaa2interface.JobTemplate) *Job
- func (j *Job) OnSuccess(f func(job drmaa2interface.Job)) *Job
- func (j *Job) OnSuccessRun(cmd string, args ...string) *Job
- func (j *Job) OnSuccessRunT(jt drmaa2interface.JobTemplate) *Job
- func (j *Job) Resubmit(r int) *Job
- func (j *Job) Resume() *Job
- func (j *Job) Retry(r int) *Job
- func (j *Job) RetryAnyFailed(amount int) *Job
- func (j *Job) Run(cmd string, args ...string) *Job
- func (j *Job) RunEvery(d time.Duration, end time.Time, cmd string, args ...string) error
- func (j *Job) RunEveryT(d time.Duration, end time.Time, jt drmaa2interface.JobTemplate) error
- func (j *Job) RunT(jt drmaa2interface.JobTemplate) *Job
- func (j *Job) State() drmaa2interface.JobState
- func (j *Job) Success() bool
- func (j *Job) Suspend() *Job
- func (j *Job) Synchronize() *Job
- func (j *Job) Tag() string
- func (j *Job) TagWith(tag string) *Job
- func (j *Job) Template() *drmaa2interface.JobTemplate
- func (j *Job) Then(f func(job drmaa2interface.Job)) *Job
- func (j *Job) ThenRun(cmd string, args ...string) *Job
- func (j *Job) ThenRunT(jt drmaa2interface.JobTemplate) *Job
- func (j *Job) Wait() *Job
- type KubernetesConfig
- type Notifier
- type Observer
- type ProcessConfig
- type SingularityConfig
- type Template
- func (t *Template) AddIterator(name string, itr Iterator) *Template
- func (t *Template) AddMap(name string, f Iterator) *Template
- func (t *Template) MapTo(system string) drmaa2interface.JobTemplate
- func (t *Template) Next() drmaa2interface.JobTemplate
- func (t *Template) NextMap(name string) drmaa2interface.JobTemplate
- type Workflow
- func (w *Workflow) Error() error
- func (w *Workflow) HasError() bool
- func (w *Workflow) Logger() log.Logger
- func (w *Workflow) OnError(f func(e error)) *Workflow
- func (w *Workflow) Run(cmd string, args ...string) *Job
- func (w *Workflow) RunT(jt drmaa2interface.JobTemplate) *Job
- func (w *Workflow) SetLogger(log log.Logger) *Workflow
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CloudFoundryConfig ¶
type CloudFoundryConfig struct { APIAddr string User string Password string DBFile string DefaultTemplate drmaa2interface.JobTemplate }
CloudFoundryConfig descibes where Cloud Foundry (CC API) is found and can be accessed.
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
Context contains a pointer to execution backend and configuration for it.
func DRMAA2SessionManagerContext ¶
func DRMAA2SessionManagerContext(sm drmaa2interface.SessionManager) *Context
DRMAA2SessionManagerContext creates a new Context using any given DRMAA2 Session manager (implementing the drmaa2interface).
func NewCloudFoundryContext ¶
func NewCloudFoundryContext() *Context
NewCloudFoundryContext creates a new Context which allows creating Cloud Foundry tasks when executing a Workflow. It reads the configuration out of environment variables (CF_API, CF_USER, CF_PASSWORD).
func NewCloudFoundryContextByCfg ¶
func NewCloudFoundryContextByCfg(cfg CloudFoundryConfig) *Context
NewCloudFoundryContextByCfg creates a new task execution Context based on the the CloudFoundryContext which describes the API endpoint of the cloud controller API of Cloud Foundry.
func NewDockerContext ¶
func NewDockerContext() *Context
NewDockerContext creates a new Context containing a DRMAA2 session manager which is capable for creating Docker containers.
func NewDockerContextByCfg ¶
func NewDockerContextByCfg(cfg DockerConfig) *Context
NewDockerContextByCfg creates a new Context based on the given DockerConfig.
func NewKubernetesContext ¶
func NewKubernetesContext() *Context
NewKubernetesContext creates a new Context which executes tasks of the workflow in Kubernetes.
func NewKubernetesContextByCfg ¶
func NewKubernetesContextByCfg(cfg KubernetesConfig) *Context
NewKubernetesContextByCfg creates a new Context with kubernetes as task execution engine. The KubernetesConfig configures details, like a default container image which is required when Run() is used or no JobCategory is set in the JobTemplate.
func NewProcessContext ¶
func NewProcessContext() *Context
NewProcessContext returns a new *Context which manages processes.
func NewProcessContextByCfg ¶
func NewProcessContextByCfg(cfg ProcessConfig) *Context
NewProcessContextByCfg returns a new *Context which manages processes which is configured by the ProcessConfig.
func NewSingularityContext ¶ added in v1.0.1
func NewSingularityContext() *Context
NewSingularityContext creates a new Context which allows to run the jobs in Singularity containers. It only works with JobTemplate based run methods (like RunT()) as it requires the JobCategory set to the the Singularity container image.
func NewSingularityContextByCfg ¶ added in v1.0.1
func NewSingularityContextByCfg(cfg SingularityConfig) *Context
NewSingularityContextByCfg creates a new Context which allows to run the jobs in Singularit containers. If the given SingularityConfig has set the DefaultImage to valid Singularity image then the Run() methods are using that container image. That image can be overriden by the RunT() method when setting the JobCategory.
type DockerConfig ¶
type DockerConfig struct { DBFile string DefaultDockerImage string DefaultTemplate drmaa2interface.JobTemplate }
DockerConfig determines configuration options for the Docker containers which are created by the Workflow. A common use-case is setting a default Docker image, which is used when Run() is called or when RunT() is used but the job category is not set in the job template.
type Iterator ¶
type Iterator func(drmaa2interface.JobTemplate) drmaa2interface.JobTemplate
Iterator is a function which transforms a JobTemplate when called.
func NewEnvSequenceIterator ¶
NewEnvSequenceIterator returns an iterator which increments the environment variable env each time when called.
func NewTimeIterator ¶
NewTimeIterator returns a template iterator which return a job template every d time.
type Job ¶
type Job struct {
// contains filtered or unexported fields
}
Job defines methods for job life-cycle management. A job is always bound to a workflow which defines the context and job session (logical separation of jobs) of the underlying backend. The Job object allows to create an manage tasks.
func (*Job) Do ¶
func (j *Job) Do(f func(job drmaa2interface.Job)) *Job
Do executes a function which gets the DRMAA2 job object as parameter. This allows working with the low-level DRMAA2 job object.
func (*Job) ExitStatus ¶
ExitStatus waits until the previously submitted task is finished and returns the exit status of the task. In case of an internal error it returns -1.
func (*Job) Failed ¶
Failed returns true in case the current task stated equals drmaa2interface.Failed
func (*Job) HasAnyFailed ¶
HasAnyFailed returns true if there is any failed task in the chain. Note that the functions implicitly waits until all tasks finsihed.
func (*Job) JobInfo ¶
func (j *Job) JobInfo() drmaa2interface.JobInfo
JobInfo returns information about the last task/job. Which values are actually set depends on the DRMAA2 implementation of the backend specified in the context.
func (*Job) JobInfos ¶
func (j *Job) JobInfos() []drmaa2interface.JobInfo
JobInfos returns all JobInfo objects of all tasks/job run in the workflow. JobInfo contains run-time details of the jobs. The availability of the values depends on the underlying DRMAA2 implementation of the execution Context.
func (*Job) ListAllFailed ¶
func (j *Job) ListAllFailed() []drmaa2interface.Job
ListAllFailed returns all tasks which failed as array of DRMAA2 jobs. Note that it implicitly waits until all tasks are finished.
func (*Job) Observe ¶
Observe executes the functions defined in the Observer when task submission errors, the task failed, and when the job finished successfully. Note that this is a blocking call.
func (*Job) OnError ¶
OnError executes the given function if the last Job operation resulted in an error (like a job submission failure).
func (*Job) OnFailure ¶
func (j *Job) OnFailure(f func(job drmaa2interface.Job)) *Job
OnFailure executes the given function when the previous task in the list failed. Fails mean the job was started successfully by the system but then existed with an exit code != 0.
When running the task resulted in an error (i.e. the job run function errored), then the function is not executed.
func (*Job) OnFailureRun ¶
OnFailureRun submits a task when the previous task ended in a state different than drmaa2interface.Done.
func (*Job) OnFailureRunT ¶
func (j *Job) OnFailureRunT(jt drmaa2interface.JobTemplate) *Job
OnFailureRunT submits a task when the previous job ended in a state different than drmaa2interface.Done.
func (*Job) OnSuccess ¶
func (j *Job) OnSuccess(f func(job drmaa2interface.Job)) *Job
OnSuccess executes the given function after the previously submitted task finished in the drmaa2interface.Done state.
func (*Job) OnSuccessRun ¶
OnSuccessRun submits a task when the previous task ended in the state drmaa2interface.Done.
func (*Job) OnSuccessRunT ¶
func (j *Job) OnSuccessRunT(jt drmaa2interface.JobTemplate) *Job
OnSuccessRunT submits a task when the previous task ended in the state drmaa2interface.Done.
func (*Job) Resubmit ¶
Resubmit starts the previously submitted task n-times. All tasks are executed in parallel.
func (*Job) Retry ¶
Retry waits until the last task in chain (not for the previous ones) is finished. When it failed it resubmits it and waits again for a successful end.
func (*Job) RetryAnyFailed ¶
RetryAnyFailed reruns any failed tasks and replaces them with a new task incarnation.
func (*Job) Run ¶
Run submits a task which executes the given command and args. The command needs to be available on the execution backend.
func (*Job) RunEvery ¶
RunEvery provides the same functionally like RunEveryT but the job is created based on the given command with the arguments.
func (*Job) RunEveryT ¶
func (j *Job) RunEveryT(d time.Duration, end time.Time, jt drmaa2interface.JobTemplate) error
RunEveryT submits a job every d time.Duration regardless if the previously job is still running or finished or failed. The method only aborts and returns an error if an error during job submission happened and the job could not be submitted.
func (*Job) RunT ¶
func (j *Job) RunT(jt drmaa2interface.JobTemplate) *Job
RunT submits a task given specified with the JobTemplate.
func (*Job) State ¶
func (j *Job) State() drmaa2interface.JobState
State returns the current state of the job previously submitted.
func (*Job) Success ¶
Success returns true in case the current task stated equals drmaa2interface.Done and the job exit status is 0.
func (*Job) Suspend ¶
Suspend stops the last task of the job from execution. How this is done depends on the Context. Typically a signal (like SIGTSTP) is sent to the tasks of the job.
func (*Job) Synchronize ¶
Synchronize waits until the tasks of the job are finished. All jobs are terminated when the call returns.
func (*Job) TagWith ¶
TagWith tags a job with a string for identification. Global for all tasks of the job.
func (*Job) Template ¶
func (j *Job) Template() *drmaa2interface.JobTemplate
Template returns the JobTemplate of the previous job submission.
func (*Job) Then ¶
func (j *Job) Then(f func(job drmaa2interface.Job)) *Job
Then waits until the previous task is terminated and executes the given function by providing the DRMAA2 job interface which gives access to the low-level DRMAA2 job methods.
func (*Job) ThenRun ¶
ThenRun waits until the previous task is terminated and executes then the given command as new task.
func (*Job) ThenRunT ¶
func (j *Job) ThenRunT(jt drmaa2interface.JobTemplate) *Job
ThenRunT waits until the previous task is terminated and executes then a new task based on the given JobTemplate.
type KubernetesConfig ¶
type KubernetesConfig struct { DefaultImage string DBFile string DefaultTemplate drmaa2interface.JobTemplate }
KubernetesConfig describes the default container image to use when no other is specified in the JobCategory of the JobTemplate. This allows to use the Run() method instead of RunT().
type Notifier ¶
type Notifier struct {
// contains filtered or unexported fields
}
func NewNotifier ¶
func NewNotifier() *Notifier
NewNotifier creates a job notifier which allows to synchronize multiple job workflows executed concurrently in go functions.
func (*Notifier) ReceiveJob ¶
type Observer ¶
type Observer struct { ErrorHandler func(error) FailedHandler func(drmaa2interface.Job) SuccessHandler func(drmaa2interface.Job) }
Observer is a collection of functions which implements behavior which should be executed when a task submission failed, when the task failed, or when then the job was running successfully.
func NewDefaultObserver ¶
func NewDefaultObserver() Observer
NewDefaultObserver returns an Observer which panics when a task submission error occurred, prints a message and exits the application when the task exits with error code != 0, and prints a message and continues when a task was running successfully.
type ProcessConfig ¶
type ProcessConfig struct { // DBFile is the local file which contains the internal state DB. DBFile string // DefaultTemplate contains the default job submission settings if // not overridden by the RunT() like methods. DefaultTemplate drmaa2interface.JobTemplate }
ProcessConfig contains the configuration for the process context.
type SingularityConfig ¶ added in v1.0.1
type SingularityConfig struct { DefaultImage string DBFile string DefaultTemplate drmaa2interface.JobTemplate }
SingularityConfig contains the default settings for the Singularity containers.
type Template ¶
type Template struct { Jt drmaa2interface.JobTemplate // contains filtered or unexported fields }
Template is a higher level job template for simplifying creating dynamically JobTemplates.
func NewTemplate ¶
func NewTemplate(jt drmaa2interface.JobTemplate) *Template
NewTemplate creates a Template out of a drmaa2interface.JobTemplate
func (*Template) AddIterator ¶
AddIterator registers an interation function which transforms the internal JobTemplate into another JobTemplate. The function is called each time when Next() is called. Multiple Iterators can be registered. The execution order or the Iterators is undefined and does not depend on the registration order.
func (*Template) AddMap ¶
AddMap registers a mapping function (same as Iterator) which converts the underlying DRMAA2 JobTemplate into a specific form. In difference to the iterator functions it does not make any persistent changes to the job template. Its intention is to cover the differencens required in the job template so that a job can run on different backends.
func (*Template) MapTo ¶
func (t *Template) MapTo(system string) drmaa2interface.JobTemplate
MapTo transforms the JobTemplate and returns it. It does not make changes to the underlying Template.
func (*Template) Next ¶
func (t *Template) Next() drmaa2interface.JobTemplate
Next applies all registered Iterators to the internal job template and returns the next version of the job template.
func (*Template) NextMap ¶
func (t *Template) NextMap(name string) drmaa2interface.JobTemplate
NextMap applies all registered Iterators to the internal job template and finally does a temporary mapping of the job template with the mapping function specified.
type Workflow ¶
type Workflow struct {
// contains filtered or unexported fields
}
Workflow contains the backend context and a job session. The DRMAA2 job session provides typically logical isolation between jobs.
func NewWorkflow ¶
NewWorkflow creates a new Workflow based on the given execution context. Internally it creates a DRMAA2 JobSession which is used for separating jobs.
func (*Workflow) Error ¶
Error returns the error if happened during creating a job session or opening a job session.
func (*Workflow) HasError ¶
HasError returns true if there was an error during creating a job session or opening a job session.
func (*Workflow) OnError ¶
OnError executes a function if happened during creating a job session or opening a job session.
func (*Workflow) Run ¶
Run submits the first task in the workflow and returns the Job object. Same as NewJob(w).Run().
func (*Workflow) RunT ¶
func (w *Workflow) RunT(jt drmaa2interface.JobTemplate) *Job
RunT submits the first task in the workflow and returns the Job object. Same as NewJob(w).RunT().