Worker

Blacktraffic. Worker

Represents a Blacktraffic.Worker type that can be repeatedly called to execute browser automation or other tasks. A tab is currently provided by default per task, regardless of whether it actually needs a browser context to execute.

Constructor:
  • arg0_type: string - The worker type to identify with.
  • arg1_options: Object
    • .config_file_path: string - The config JSON5 file to load. Accessible at .config.
    • .do_not_close_tab: boolean
    • .interval: number - The interval in seconds at which to execute run().
    • .log_channel="${worker}_type": string
    • .tags=[]: Array<string>
    • .console_persistence=false: boolean - Whether console outputs should persist between worker jobs.
Instance:
  • .current_job_status="idle": string
  • .is_enabled=true: boolean
  • .jobs=[]: Array<Object>
  • .options: Object
  • .type: string
Methods:
  • disable()
  • enable()
  • error(argn_arguments:any)
  • execute(argn_arguments:any)
  • getBrowser() | Blacktraffic.AgentBrowserPuppeteer
  • getCurrentStatus() | string
  • getCurrentTimeStatus() | { status: string, timestamp: number }
  • getJobList() | Array<Object>
  • getLastSuccessfulJob() | Date
  • getTab() | Object
  • getTabID() | string
  • log(argn_arguments:any)
  • print(arg0_type:string, argn_arguments:any)
  • remove()
  • run()
  • startInterval()
  • stopInterval()
  • warn(argn_arguments:any)
Static Fields:

Constructor

new Worker()

Source:

Members

input_chrome_profile :string

Source:
Type:
  • string

saves_folder :string

[WIP] - Should probably really be set to a default like ./settings/Blacktraffic/workers.

Source:
Type:
  • string

(static) this.console_local :log.Channel

Source:
Type:

Methods

error(…argn_arguments)

Prints an error to both logging channels.

Source:
Parameters:
Name Type Attributes Description
argn_arguments <repeatable>

log(…argn_arguments)

Prints a log to both logging channels.

Source:
Parameters:
Name Type Attributes Description
argn_arguments <repeatable>

print(arg0_type, …argn_arguments)

Prints a message type to both logging channels.

Source:
Parameters:
Name Type Attributes Description
arg0_type string

Either 'error'/'log'/'warn'.

argn_arguments <repeatable>

remove()

Removes the current worker.

Source:

warn(…argn_arguments)

Logs a warning to both logging channels.

Source:
Parameters:
Name Type Attributes Description
argn_arguments <repeatable>

(async) disable() → {Promise.<void>}

Disables the current worker and aborts the task it is carrying out.

Source:
Returns:
Type:
Promise.<void>

(async) enable() → {Promise.<void>}

Enables the current worker. Does not necessarily resume the task.

Source:
Returns:
Type:
Promise.<void>

(async) execute()

Attempts execution of the current worker, used by child classes.

Source:

(async) getBrowser() → {Promise.<Blacktraffic.AgentBrowserPuppeteer>}

Returns the current stored browser object.

Source:
Returns:
Type:
Promise.<Blacktraffic.AgentBrowserPuppeteer>

getCurrentStatus() → {string}

Returns the current status. Either 'done'/'failed'/'idle'/'partially_failed'/'running'/.

Source:
Returns:
Type:
string

getCurrentStatusElement() → {HTMLSpanElement}

Returns the current status element and report.

Source:
Returns:
Type:
HTMLSpanElement

getCurrentTimeStatus() → {Object}

Returns the current time status. Either 'idle'/'running'/'done'.

Source:
Returns:
Type:
Object

getJobList() → {Array.<Object>}

Returns the list of previous jobs carried out by the worker in-session.

Source:
Returns:
Type:
Array.<Object>

getLastSuccessfulJob() → {Date}

Returns the last successful job that was successfully completed.

Source:
Returns:
Type:
Date

(async) getTab() → {Promise.<Object>}

Returns the tab the Worker is currently executing tasks on.

Source:
Returns:
Type:
Promise.<Object>

getTabID() → {string}

Returns the current tab ID.

Source:
Returns:
Type:
string

(async) run() → {Promise.<Array.<Ontology>>}

Runs the current worker thread and executes its .execute() method.

Source:
Returns:
Type:
Promise.<Array.<Ontology>>

startInterval()

Starts the interval timer for the worker.

Source:

stopInterval()

Stops the interval timer for the worker.

Source: