Timer and Scheduling Service¶
Summary¶
Set up timers to trigger events within Murano.
The Timer services can trigger events once, on an interval, or on a schedule.
Operations
Name | Tag | Summary |
---|---|---|
timer.cancel() | cancel an active timer | |
timer.cancelAll() | cancel all active timers for a given solution | |
timer.list() | List all active timers for a given solution | |
timer.sendAfter() | create a one-shot timer | |
timer.sendInterval() | create an interval timer |
Events
Name | Summary |
---|---|
timer | timer trigger |
Configuration parameters¶
Name | Type | Description |
---|---|---|
schedule | object | The task schedule definition |
schedule.daily | boolean | This task should occur daily |
schedule.hourly | boolean | This task should occur hourly |
schedule.weekly | boolean | This task should occur weekly |
schedule.yearly | boolean | This task should occur yearly |
schedule.monthly | boolean | This task should occur monthly |
Operations¶
cancel¶
Description
This operation will cancel an active timer.
Arguments
Name | Type | Description |
---|---|---|
timer_id | string | The ID of the timer to cancel |
Responses
-
Returns
{object}
when The timer was deleted successfully. Note: if timer ID does not exist, it will still be marked as successfully deleted.Operation successful
{object}
Name Type Description result string Okay if successful -
Returns
{object}
when An error occurredOperation error information
{object}
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¶
Description
This operation will cancel all active timers in the given solution.
Responses
-
Returns
{object}
when The operation completed successfullyOperation successful
{object}
Name Type Description result string Okay if successful -
Returns
{object}
when An error occurredOperation error information
{object}
Name Type Description type string Error type error string Error message status integer Response code
Example
local req = Timer.cancelAll() print(req)
list¶
Description
This operation will list all active timers in the given solution.
Responses
-
Returns
{object}
when The operation completed successfullyAll timers information
{object}
Name Type Description list [ string ] A list of timer id. result string A message describing the result of the operation -
Returns
{object}
when An error occurredOperation error information
{object}
Name Type Description type string Error type error string Error message status integer Response code
Example
local req = Timer.list() print(req)
sendAfter¶
Description
Sets up a timer which will fire once after duration
has passed.
Arguments
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 | The duration of the timer in milliseconds. |
timer_id | string | The ID of the timer. If null, it will be generated for you. |
Responses
-
Returns
{object}
when The timer was created successfullyNew timer task information
{object}
Name Type Description result string A message describing the result of the operation timer_id string The ID of the timer -
Returns
{object}
when An error occurredOperation error information
{object}
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¶
Description
Sets up a timer which will fire once every duration
.
Arguments
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 | The duration of the timer in milliseconds. |
timer_id | string | The ID of the timer. If null, it will be generated for you. |
Responses
-
Returns
{object}
when The timer was created successfullyNew timer task information
{object}
Name Type Description result string A message describing the result of the operation timer_id string The ID of the timer -
Returns
{object}
when An error occurredOperation error information
{object}
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¶
Description
A scheduled timer is occurring. And timer task data is transmitted.
Arguments
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