Documentation ¶
Index ¶
- Constants
- Variables
- type EnvironmentVariable
- type EnvironmentVariables
- type Exec
- func (e *Exec) Cancel()
- func (e Exec) GetArgs() []interface{}
- func (e Exec) GetBackoff() time.Duration
- func (e Exec) GetBy() string
- func (e Exec) GetCancelChan() chan struct{}
- func (e Exec) GetDuration() time.Duration
- func (e Exec) GetEnvs(passphrase string) (EnvironmentVariables, error)
- func (e Exec) GetEnvsMap(passphrase string) (map[string]interface{}, error)
- func (e Exec) GetErr() interface{}
- func (e Exec) GetExecutionTime() int64
- func (e Exec) GetHash() []byte
- func (e Exec) GetInterval() int
- func (e Exec) GetPriority() int
- func (e Exec) GetResult() interface{}
- func (e Exec) GetRetries() int
- func (e Exec) GetRetriesCount() int
- func (e Exec) GetStatus() string
- func (e Exec) GetTTL() time.Duration
- func (e Exec) GetTimestamp() int64
- func (e *Exec) IncrRetriesCount()
- func (e Exec) Serialize() []byte
- func (e *Exec) SetArgs(a []interface{})
- func (e *Exec) SetBackoff(b time.Duration) error
- func (e *Exec) SetBy(by string)
- func (e *Exec) SetDuration(t time.Duration)
- func (e *Exec) SetErr(err interface{})
- func (e *Exec) SetExecutionTime(t int64) error
- func (e *Exec) SetInterval(i int)
- func (e *Exec) SetPriority(p int) error
- func (e *Exec) SetResult(r interface{})
- func (e *Exec) SetRetries(r int) error
- func (e *Exec) SetStatus(s string)
- func (e *Exec) SetTTL(ttl time.Duration)
- func (e *Exec) SetTimestamp(t int64)
- type Job
- func (j *Job) AddExec(je Exec)
- func (j *Job) Execute(exec *Exec, passphrase string) *Exec
- func (j Job) GetExec(hash []byte) (*Exec, error)
- func (j Job) GetExecs() []Exec
- func (j Job) GetHash() []byte
- func (j Job) GetID() string
- func (j Job) GetLatestExec() Exec
- func (j Job) GetName() string
- func (j Job) GetPrivate() bool
- func (j Job) GetSignature() [][]byte
- func (j Job) GetSubmissionTime() time.Time
- func (j Job) GetTask() string
- func (j Job) IsEmpty() bool
- func (j *Job) Serialize() []byte
- func (j *Job) Sign(priv []byte)
- func (j Job) Verify() bool
- func (j Job) VerifySignature(pub string) bool
- type JobRequestMultiple
- type JobRequestSingle
Constants ¶
View Source
const ( MaxExecs = 10 // max number of jobs allowed in the chain MaxRetries = 5 MaxRetryBackoff = 120 //! 2 minutes DefaultMaxTTL = time.Minute * 10 DefaultRetries = 0 DefaultPriority = NORMAL )
View Source
const ( BOOST = 4 HIGH = 3 MEDIUM = 2 LOW = 1 NORMAL = 0 //! default )
! priorities
View Source
const ( CANCELLED = "CANCELLED" // cancelled by sender QUEUED = "QUEUED" // job added to job queue TIMEOUT = "TIMEOUT" // job timed out RUNNING = "RUNNING" //job being executed FINISHED = "FINISHED" //job done RETRYING = "RETRYING" //job retrying DISPATHCHED = "DISPATCHED" //job dispatched to worker STARTED = "STARTED" //job received by dispatcher (prior to dispatch) )
! statuses
Variables ¶
View Source
var ( ErrExecNotFound = errors.New("Exec Not Found") ErrInvalidPriority = errors.New("Invalid priority number") ErrRetriesOutsideLimit = errors.New("Retries outside limit") ErrRetryDelayOutsideLimit = errors.New("Retry Delay outside limit") ErrExecutionTimeBehind = errors.New("Execution time is past") ErrJobsLenRange = errors.New("Number of jobs is more than allowed") )
View Source
var ( ErrUnverifiedSignature = errors.New("signature not verified") ErrUnableToConvert = errors.New("Unable to convert to string") )
Functions ¶
This section is empty.
Types ¶
type EnvironmentVariable ¶
EnvironmentVariables stores key and value of env variables
func NewEnv ¶
func NewEnv(key, value string) *EnvironmentVariable
func (EnvironmentVariable) GetKey ¶
func (env EnvironmentVariable) GetKey() string
func (EnvironmentVariable) GetValue ¶
func (env EnvironmentVariable) GetValue() string
type EnvironmentVariables ¶
type EnvironmentVariables []EnvironmentVariable
func DeserializeEnvs ¶
func DeserializeEnvs(b []byte) (EnvironmentVariables, error)
func NewEnvVariables ¶
func NewEnvVariables(variables ...EnvironmentVariable) EnvironmentVariables
func (EnvironmentVariables) Serialize ¶
func (e EnvironmentVariables) Serialize() []byte
type Exec ¶
type Exec struct { Hash []byte Timestamp int64 Duration time.Duration //saved in nanoseconds Args []interface{} // parameters Err interface{} Priority int Result interface{} Status string //job status Retries int // number of max retries RetriesCount int //number of retries Backoff time.Duration //backoff time of retries (seconds) ExecutionTime int64 // time scheduled to run (unix) - should sleep # of seconds before adding to job queue Interval int //periodic job exec (seconds) By string //! ID of the worker node that ran this TTL time.Duration //! time limit of job running Pub string //! public key for private jobs Envs []byte // contains filtered or unexported fields }
TODO: add environment variables
func DeserializeExec ¶
func (Exec) GetBackoff ¶
func (Exec) GetCancelChan ¶
func (e Exec) GetCancelChan() chan struct{}
func (Exec) GetDuration ¶
func (Exec) GetEnvsMap ¶
returns environment variables as a map
func (Exec) GetExecutionTime ¶
func (Exec) GetInterval ¶
func (Exec) GetPriority ¶
func (Exec) GetRetries ¶
func (Exec) GetRetriesCount ¶
func (Exec) GetTimestamp ¶
func (*Exec) IncrRetriesCount ¶
func (e *Exec) IncrRetriesCount()
func (*Exec) SetDuration ¶
func (*Exec) SetInterval ¶
func (*Exec) SetPriority ¶
func (*Exec) SetRetries ¶
func (*Exec) SetTimestamp ¶
type Job ¶
type Job struct { ID string Hash []byte Execs []Exec Name string Task string Signature [][]byte // signature of owner SubmissionTime time.Time Private bool //private job flag (default to false - public) }
func DeserializeJob ¶
func (Job) GetLatestExec ¶
func (Job) GetPrivate ¶
func (Job) GetSignature ¶
func (Job) GetSubmissionTime ¶
func (Job) VerifySignature ¶
type JobRequestMultiple ¶
func DeserializeJRM ¶
func DeserializeJRM(b []byte) (JobRequestMultiple, error)
func NewJobRequestMultiple ¶
func NewJobRequestMultiple(id string, exec ...*Exec) *JobRequestMultiple
func (*JobRequestMultiple) AppendExec ¶
func (jr *JobRequestMultiple) AppendExec(exec *Exec)
func (JobRequestMultiple) GetExec ¶
func (jr JobRequestMultiple) GetExec() []*Exec
func (JobRequestMultiple) GetID ¶
func (jr JobRequestMultiple) GetID() string
func (JobRequestMultiple) Serialize ¶
func (jr JobRequestMultiple) Serialize() []byte
func (*JobRequestMultiple) SetID ¶
func (jr *JobRequestMultiple) SetID(id string)
type JobRequestSingle ¶
func DeserializeJRS ¶
func DeserializeJRS(b []byte) (JobRequestSingle, error)
func NewJobRequestSingle ¶
func NewJobRequestSingle(id string, exec *Exec) *JobRequestSingle
func (JobRequestSingle) GetExec ¶
func (jr JobRequestSingle) GetExec() *Exec
func (JobRequestSingle) GetID ¶
func (jr JobRequestSingle) GetID() string
func (JobRequestSingle) Serialize ¶
func (jr JobRequestSingle) Serialize() []byte
func (*JobRequestSingle) SetID ¶
func (jr *JobRequestSingle) SetID(id string)
Source Files ¶
Click to show internal directories.
Click to hide internal directories.