Class: ExecutionQueue

TrellinatorCore.ExecutionQueue()

The ExecutionQueue is the mechanism by which all functionality that is not executed as the direct result of a notification is executed.

For example if you want something to happen in 3 days' time, you can use the ExecutionQueue.

If you want something to happen on a recurring basis, the function that gets called simply needs to create another entry for itself in the ExecutionQueue.

The ExecutionQueue class provides an interface to create executions in the queue, clear certain executions and force the execution queue to run more often

Constructor

new ExecutionQueue()

Source:

Members

(static) ExecutionQueue.fake_push

Set this to a callback function to be called instead of the normal push function, so that you can test the value that will be pushed to the queue during automated testing

Source:
Example
ExecutionQueue.fake_push = function(function_name,params,signature,dateobj)
{
    if(dateobj.toLocaleString() != expected)
        throw new Error("Wrong datetime pushed");
}

Methods

(static) ExecutionQueue.clear(signature)

Clear the rows from the ExecutionQueue with signature column starting with or matching given string

Parameters:
Name Type Description
signature string

total or partial matching signature string

Source:
Example
function doSomething(notification,signature)
{
    var my_sig = new Notification(notification).card().id()+signature;
    //clear any other executions for this card, related
    //to the function called either globally, as part of 
    //a group or on a specific board
    ExecutionQueue.clear(my_sig);
    ExecutionQueue.push("doSomethingElse",
                        notification,
                        my_sig,
                        Trellinator.now().addDays(3).at("13:00"));
}

(static) ExecutionQueue.nextMinute()

Force the queue to run again in 1 minute

Source:

(static) ExecutionQueue.push(function_name, params, signature, dateobj)

Push a new function to the execution queue

Parameters:
Name Type Description
function_name string

the name of the function to be called. Must be a function defined in the local scope of the Google Apps Script project, can't be from a library or a class member

params Object

whatever argument will be passed into the function

signature string

An arbitrary string that can be used to identify execution rows as being related. Typically you Every function call is passed a signature so you can use that verbatim or add to it. When you clear the queue you can use all or part of the signature

dateobj Date

the date/time when the function should be executed. By default the queue is executed every 10 minutes, and any row with a function scheduled in the past or at precisely the current time is executed, and the originally date/time is passed into the function regardless of when it actually executes

Source:
Example
function doSomething(notification,signature)
{
    ExecutionQueue.push("doSomethingElse",
                        notification,
                        signature,
                        Trellinator.now().addDays(3).at("9:00"));
}