Schedule
The cloud.Schedule resource is used to trigger events at a regular interval.
Schedules are useful for periodic tasks, such as running backups or sending daily reports.
The timezone used in cron expressions is always UTC.
Usage
From cron
bring cloud;
let schedule = new cloud.Schedule(cron: "* * * * *");
schedule.onTick(inflight () => {
  log("schedule: triggered");
});
From rate
bring cloud;
let schedule = new cloud.Schedule(rate: 1m);
schedule.onTick(inflight () => {
  log("schedule: triggered");
});
Simulator (sim)
A standard JavaScript setTimeout function triggers ticks as callbacks.
AWS (tf-aws and awscdk)
See Amazon CloudWatch.
Azure (tf-azure)
🚧 Not supported yet (tracking issue: #1291).
GCP (tf-gcp)
🚧 Not supported yet (tracking issue: #1292).
API Reference 
Schedule 
A schedule.
Initializers 
bring cloud;
new cloud.Schedule(props?: ScheduleProps);
| Name | Type | Description | 
|---|---|---|
|  |  | No description. | 
propsOptional 
- Type: ScheduleProps
Methods 
Preflight Methods
| Name | Description | 
|---|---|
|  | Create a function that runs when receiving the scheduled event. | 
onTick 
onTick(inflight: IScheduleOnTickHandler, props?: ScheduleOnTickOptions): Function
Create a function that runs when receiving the scheduled event.
inflightRequired 
- Type: IScheduleOnTickHandler
propsOptional 
- Type: ScheduleOnTickOptions
Static Functions 
| Name | Description | 
|---|---|
|  | A hook called by the Wing compiler once for each inflight host that needs to use this type inflight. | 
|  | Generates an asynchronous JavaScript statement which can be used to create an inflight client for a resource. | 
onLiftType 
bring cloud;
cloud.Schedule.onLiftType(host: IInflightHost, ops: MutArray<str>);
A hook called by the Wing compiler once for each inflight host that needs to use this type inflight.
The list of requested inflight methods
needed by the inflight host are given by ops.
This method is commonly used for adding permissions, environment variables, or other capabilities to the inflight host.
hostRequired 
- Type: IInflightHost
opsRequired 
- Type: MutArray<str>
toInflight 
bring cloud;
cloud.Schedule.toInflight(obj: IResource);
Generates an asynchronous JavaScript statement which can be used to create an inflight client for a resource.
NOTE: This statement must be executed within an async context.
objRequired 
- Type: IResource
Properties 
| Name | Type | Description | 
|---|---|---|
|  | constructs.Node | The tree node. | 
nodeRequired 
node: Node;
- Type: constructs.Node
The tree node.
Structs 
ScheduleOnTickOptions 
Options for Schedule.onTick.
Initializer 
bring cloud;
let ScheduleOnTickOptions = cloud.ScheduleOnTickOptions{ ... };
Properties 
| Name | Type | Description | 
|---|---|---|
|  | num | The maximum concurrent invocations that can run at one time. | 
|  | MutMap<str> | Environment variables to pass to the function. | 
|  | num | Specifies the number of days that function logs will be kept. | 
|  | num | The amount of memory to allocate to the function, in MB. | 
|  |  | The maximum amount of time the function can run. | 
concurrencyOptional 
concurrency: num;
- Type: num
- Default: platform specific limits (100 on the simulator)
The maximum concurrent invocations that can run at one time.
envOptional 
env: MutMap<str>;
- Type: MutMap<str>
- Default: No environment variables.
Environment variables to pass to the function.
logRetentionDaysOptional 
logRetentionDays: num;
- Type: num
- Default: 30
Specifies the number of days that function logs will be kept.
Setting negative value means logs will not expire.
memoryOptional 
memory: num;
- Type: num
- Default: 1024
The amount of memory to allocate to the function, in MB.
timeoutOptional 
timeout: duration;
- Type: duration
- Default: 1m
The maximum amount of time the function can run.
ScheduleProps 
Options for Schedule.
Initializer 
bring cloud;
let ScheduleProps = cloud.ScheduleProps{ ... };
Properties 
| Name | Type | Description | 
|---|---|---|
|  | str | Trigger events according to a cron schedule using the UNIX cron format. | 
|  |  | Trigger events at a periodic rate. | 
cronOptional 
cron: str;
- Type: str
- Default: undefined
Trigger events according to a cron schedule using the UNIX cron format.
Timezone is UTC. [minute] [hour] [day of month] [month] [day of week] '*' means all possible values. '-' means a range of values. ',' means a list of values. [minute] allows 0-59. [hour] allows 0-23. [day of month] allows 1-31. [month] allows 1-12 or JAN-DEC. [day of week] allows 0-6 or SUN-SAT.
Example
"* * * * *"
rateOptional 
rate: duration;
- Type: duration
- Default: undefined
Trigger events at a periodic rate.
Example
1m
Protocols 
IScheduleOnTickHandler 
- 
Extends: IInflight 
- 
Implemented By: IScheduleOnTickHandler 
Inflight client: @winglang/sdk.cloud.IScheduleOnTickHandlerClient
A resource with an inflight "handle" method that can be passed to Schedule.on_tick.
IScheduleOnTickHandlerClient 
- Implemented By: IScheduleOnTickHandlerClient
Inflight client for IScheduleOnTickHandler.
Methods 
| Name | Description | 
|---|---|
|  | Function that will be called when a message is received from the schedule. | 
handle 
inflight handle(): void
Function that will be called when a message is received from the schedule.