Skip to content

Implementation of scheduler system able to send event in a future date.

Notifications You must be signed in to change notification settings

daaru00/serverless-dynamic-scheduler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Serverless Dynamic Scheduler

CloudFormation EventBridge Lambda StepFunctions DynamoDB

Implementation of scheduler system able to send event in a future date.

Created resources

A set of Lambda function connected to EventBridge rules that handle start, stop and task start. Create StepFunction state machine to wait until a specific date and send events.

Infrastructure Schema

Installation

Using the SAM CLI:

sam build
sam deploy --guided

Parameters

This application need some parameters when you deploy it:

  • EventBusName: The event bus name to connect the integration to.

Usage

Send and receive events from and to the configured event bus (from EventBusName parameter).

All events received and sent require the "id" attribute to identity the correct scheduling configurations.

Start scheduling

With cron expression:

{
  "Source": "test",
  "DetailType": "Schedule Start",
  "Detail": {
    "id": "test:schedule", 
    "cron": "30 * * * *"
  }
}

Limiting iterations:

{
  "Source": "test",
  "DetailType": "Schedule Start",
  "Detail": {
    "id": "test:schedule", 
    "cron": "30 * * * *",
    "limit": 10
  }
}

Send a single event into the future

This schedule event will be sent once base on "duration" property:

{
  "Source": "test",
  "DetailType": "Schedule Start",
  "Detail": {
    "id": "test:duration-5m", 
    "duration": "5m"
  }
}
{
  "Source": "test",
  "DetailType": "Schedule Start",
  "Detail": {
    "id": "test:duration-1h", 
    "duration": "1h"
  }
}

Listen for "tick" event

This event will be send when the scheduling time has been reached:

{
  "Source": "com.my-stack-name",
  "DetailType": "Schedule Tick",
  "Detail": {
    "id": "test:schedule"
  }
}

Stop scheduling

{
  "Source": "test",
  "DetailType": "Schedule Stop",
  "Detail": {
    "id": "test:schedule"
  }
}

Credits

About

Implementation of scheduler system able to send event in a future date.

Topics

Resources

Stars

Watchers

Forks