Timer and Scheduling Service

Set up timers to trigger events within Murano.

The Timer services can trigger events once, on an interval, or on a schedule.

Operations

Events

Operations


cancel

This operation will cancel an active timer.

Arguments

parameters - object - Object containing service call parameters.
Name Type Description
timer_id string The ID of the timer to cancel

Responses

The timer was deleted successfully. Note: if timer ID does not exist, it will still be marked as successfully deleted.

Content: object Operation successful

Name Type Description
result string Okay if successful
An error occurred

Content: object Operation error information

Name Type Description
type string Error type
error string Error message
status integer Response code

Example

local req = Timer.sendAfter({timer_id="exampleId",duration=100}) print(req) req = Timer.cancel({timer_id="exampleId"}) print(req)


cancelAll

This operation will cancel all active timers in the given solution.

Responses

The operation completed successfully

Content: object Operation successful

Name Type Description
result string Okay if successful
An error occurred

Content: object Operation error information

Name Type Description
type string Error type
error string Error message
status integer Response code

Example

local req = Timer.cancelAll() print(req)


list

This operation will list all active timers in the given solution.

Responses

The operation completed successfully

Content: object All timers information

Name Type Description
list [ string ] A list of timer id.
result string A message describing the result of the operation
An error occurred

Content: object Operation error information

Name Type Description
type string Error type
error string Error message
status integer Response code

Example

local req = Timer.list() print(req)


sendAfter

Sets up a timer which will fire once after duration has passed.

Arguments

parameters - object - Object containing service call parameters.
Name Type Description
message string, object, array The message to send when the timer is hit. This message will be fired to Solution -> Service -> Timer, and user can handle this message there.
duration integer {1..} The duration of the timer in milliseconds.
timer_id string The ID of the timer. If null, it will be generated for you.

Responses

The timer was created successfully

Content: object New timer task information

Name Type Description
result string A message describing the result of the operation
timer_id string The ID of the timer
An error occurred

Content: object Operation error information

Name Type Description
type string Error type
error string Error message
status integer Response code

Example

local req = Timer.sendAfter({timer_id="abc123", duration=100}) print(req) response.message = req response.code = 200


sendInterval

Sets up a timer which will fire once every duration.

Arguments

parameters - object - Object containing service call parameters.
Name Type Description
message string, object, array The message to send when the timer is hit. This message will be fired to Solution -> Service -> Timer, and user can handle this message there.
duration integer {1..} The duration of the timer in milliseconds.
timer_id string The ID of the timer. If null, it will be generated for you.

Responses

The timer was created successfully

Content: object New timer task information

Name Type Description
result string A message describing the result of the operation
timer_id string The ID of the timer
An error occurred

Content: object Operation error information

Name Type Description
type string Error type
error string Error message
status integer Response code

Example

local req = Timer.sendInterval({timer_id="abc123", duration=100}) print(req) response.message = req response.code = 200

Events


timer

A scheduled timer is occurring. And timer task data is transmitted.

Arguments

request - object - The timer task data
Name Type Description
message object The message to send when the timer is hit. This message will be fired to Solution -> Service -> Timer, and user can handle this message there.
timer_id string The ID of the timer. If null, it will be generated for you.
solution_id string The ID of the solution this timer is associated with.

Example

function handle_timer_timer (request)

 -- Your logic comes here 

end