ow.oJob

oJob.__addLog

oJob.__addLog(aOperation, aJobName, aJobExecId, args, anErrorMessage, aId, aTypeArgs) : String

Adds a new log entry to the channel oJob::log for the aJobName provided for the following operations:

- start (start of a job)
- success (successfully end of a job)
- error (erroneous end of a job)
- depsfail (job not started do to failed dependencies)

Optionally, for the operation error, you can provide also anErrorMessage.
Returns the current aJobExecId (or the created one for the operation start).

oJob.add2Todo

oJob.add2Todo(aTodo, aId) : oJob

Add a new aTodo job name or a complete aTodo object with an optional aId.

oJob.addTodos

oJob.addTodos(aTodoList, aJobtTypeArgs, aId) : oJob

Adds a new aTodoList array of job names. Optionally you can provide aId to segment these specific jobs.

oJob.getID

oJob.getID() : String

Returns this oJob instance ID. Useful to lookup logging in the oJob::log channel.

oJob.getJob

oJob.getJob(aJobName) : Map

Retrieves the aJobName definition map so it can be changed and overwritten with "oJob.setJob(aJobName, aJobMap)".

oJob.load

oJob.load(aJobsList, aTodoList, aoJobList, args, aId, init, help)

Loads a set of aJobsList, corresponding aTodoList and a list of aoJobList. Optionally you can provide aId to segment these specific jobs.

oJob.oJob

oJob.oJob() : oJob

Creates an instance of an oJob. O Uses the channel oJob::log for job logging, oJob::jobs for job register, oJob::todo as job todo register and oJob::oJob for oJob instances registry.

oJob.removeJob

oJob.removeJob(aJobName) : oJob

Removes aJobName.

oJob.setJob

oJob.setJob(aJobName, aJob) : oJob

Adds or overwrites an existing aJobName with the configuration aJob.

oJob.start

oJob.start(args, shouldStop, aId, isSubJob) : oJob

Starts the todo list. Optionally you can provide arguments to be used by each job. Optionally you can provide aId to segment these specific jobs.

oJob.stop

oJob.stop()

Stops all oJob processing.

ow.oJob.addJob

ow.oJob.addJob(aJobsCh, aName, jobDeps, jobType, aJobTypeArgs, jobArgs, jobFunc, jobFrom, jobTo, jobHelp, jobCatch, jobEach, jobLang, jobFile, jobCheck)

Provided aJobsCh (a jobs channel) adds a new job with the provided aName, an array of jobDeps (job dependencies), a jobType (e.g. simple, periodic, shutdown), aJobTypeArgs (a map), jobArgs and a jobFunc (a job function).  Optionally you can inherit the job definition from a jobFrom and/or jobTo name ("from" will execute first, "to" will execute after). Also you can include jobHelp.

ow.oJob.addTodo

ow.oJob.addTodo(aOJobID, aJobsCh, aTodoCh, aJobName, aJobArgs, aJobType, aJobTypeArgs)

Provided aOJobID (a oJob instance), aJobsCh (a jobs channel), aTodoCh (a todo channel), aJobArgs (job arguments). Optionally you can force the aJobType and aJobTypeArgs.

ow.oJob.getJobsCh

ow.oJob.getJobsCh() : Channel

Gets the oJob::jobs channel

ow.oJob.getLogCh

ow.oJob.getLogCh() : Channel

Gets the oJob::log channel

ow.oJob.getMainCh

ow.oJob.getMainCh() : Channel

Gets the oJob::oJob channel

ow.oJob.getMetric

ow.oJob.getMetric(aMetricId)

Retrieves the current metric identified by aMetricId

ow.oJob.getMetrics

ow.oJob.getMetrics(aType) : Function

Returns a function to be used with ow.metrics.add to add functions by metric aType

ow.oJob.getMetricsCh

ow.oJob.getMetricsCh() : Channel

Gets the oJob::metrics channel

ow.oJob.getState

ow.oJob.getState() : String

Get current global state, if defined.

ow.oJob.getTodoCh

ow.oJob.getTodoCh() : Channel

Gets the oJob::todo channel

ow.oJob.loadFile

ow.oJob.loadFile(aFile, args, aId)

Loads the configuration from a YAML or JSON aFile and loads all configuration.
Optionally you can provide aId to segment these specific jobs.

Example of YAML:
# Name your includes
#
include:
  - hello.js   # Some nice hello function

# Define the jobs
jobs:
   # Start processing
   - name        : Start processing
     exec        : >
        log("init");
        //sprint(ow.oJob.getJobsCh().getAll());

# Stop processing
   - name        : Stop processing
     type        : shutdown
     exec        : >
        log("done");
        sprint(ow.oJob.getLogCh().getAll());

# Hello world after start processing
   - name	      : Hello world
     deps          : 
        - Start processing
     exec 	      : >
        sprint(args);  
        hello("nuno");

# Bye world
   - name        : Bye
     deps        :
        - Hello world
        - Say the time
     exec        :
        print("bye, nice to meet you.");

# Say the time regularly
   - name        : Say the time
     type        : periodic
     typeArgs    :
        timeInterval   : 1000
        waitForFinish  : true
        cron           : "*\/5 * * * * *"
     exec        : >
        print(new Date());

# List what to do 
todo:
   - Start processing
   - Say the time
   - Hello world
   - Bye
   - Stop processing

# This will be a daemon
ojob:
   daemon: false
   unique:
      pidFile     : helloworld.pid
      killPrevious: true
   channels:
      expose     : true
      port       : 17878
      permissions: r
      #list       :
      #  - oJob::log
      #auth       :
      #  - login: ojob
      #    pass : ojob
      #    permissions: r


ow.oJob.loadJobs

ow.oJob.loadJobs(aFile, args, noReturn) : Array


ow.oJob.loadJSON

ow.oJob.loadJSON(aJSON, dontLoadTodos) : Object

Loads aJSON oJob configuration and returns the processed map (with all includes processed).

ow.oJob.previewFile

ow.oJob.previewFile(aFile) : Map

Returns a map with a preview of the oJob configuration that would be executed with aFile.

ow.oJob.run

ow.oJob.run(providedArgs, aId)

Tries to run the current loaded configuration jobs (on the corresponding channels) with the provided arguments (providedArgs). Optionally you can provide aId to segment these specific jobs.

ow.oJob.runAllShutdownJobs

ow.oJob.runAllShutdownJobs()

Tries to run all the shutdown type jobs accumulated until now.

ow.oJob.runFile

ow.oJob.runFile(aFile, args, aId, isSubJob, aOptionsMap)

Loads aFile configuration and executes the oJob defined with the provided args. Optionally you can provide aId to segment these specific jobs.

ow.oJob.runJob

ow.oJob.runJob(aJob, provideArgs, aId)

With jobs defined try to execute/start aJob, with the provideArgs, directly passing any existing todo list.  Optionally you can provide aId to segment this specific jobs.

ow.oJob.setMetric

ow.oJob.setMetric(aId, aMetricObj)

Sets aMetricObj for the metric identified with aId

ow.oJob.setState

ow.oJob.setState(aState)

Sets the current global state to be used with todo.when

ow.oJob.showHelp

ow.oJob.showHelp(aHelpMap, args, showAnyway) : boolean

Given a job help map and the current arguments determines if there is a need to show help usage text and shows it on stdout. Returns true if help was output, false otherwise.