Module: workers/scion-queue

workers/scion-queue

This is a Worker script that is used as "threaded queue" for managing SCION event execution: New events for SCION are queued in order to allow raising new events from within SCION-event-processing.

This "threaded queue" receives messages from the "WebWorker environment engine" of mmir.dialogEngine - see mmir.state.StateEngineFactory.StateEngineWebWorkerImpl.

The message / work flow is as follows:

  • on receiving queueJob: add new event-job to the queue
  • on receiving finishedJob:
  • if queue is empty: does nothing
  • if queue is not empty: take next job from queue and send it as a processNextJob message to SCION

Members

private,innerqueuesPlainObject

dictionary of jobId -> JobQueue
See:

Methods

Handler for received messages.
Name Type Description
evt Object the message object with
Name Type Description
data.command "finishedJob" | "queueJob" | "destroyQueue" the message type / name (e.g. finishedJob)
data.engineId Number | String Number the engine's ID for which this job should be queued
data.job module:workers/scion-queue~Job optional the job object (e.g. in case of command queueJob the job that will be queued)

innerdistributeJobs(queue)

Handler for sending messages.

In case of finishedJob: take next job for the engine-queue and send it to SCION, i.e. post a message e with
{String} event.data.command = processNextJob
{Object} event.data.job the job object (that was added before to the queue with command / message queueJob

Name Type Description
queue module:workers/scion-queue~JobQueue the job queue

private,innergetQueue(engineId, isCreate){module:workers/scion-queue~JobQuee}

HELPER get queue for an engine (ID)
Name Type Description
engineId Number | String the engine ID
isCreate Boolean optional if TRUE, the queue will be created if it does not exist yet
Returns:
Type Description
module:workers/scion-queue~JobQuee the queue for the engineId (if isCreate is FALSE, and no queue exits for the engineId, it will return UNDEFINED)

Interface Definitions

Job

the Job object, describing jobs on a JobQueue
Properties:
Name Type Attributes Description
engineId Number | String <optional>
the engine's ID for which this job should be queued
event String <optional>
OPTIONAL the event name (must be present for command "queueJob")
eventData any <optional>
OPTIONAL event data
See:

JobQueue

A JobQueue is an Array with additional property JobQueue.readyForJob {Boolean}
Properties:
Name Type Description
readyForJob Boolean flag that indicates if queue is ready for the next job.
See: