Coder Social home page Coder Social logo

guiyom-e / cdk-scheduler Goto Github PK

View Code? Open in Web Editor NEW
58.0 2.0 4.0 1.66 MB

Precise-to-the-second CDK construct to schedule events ⏱

License: MIT License

JavaScript 17.17% TypeScript 82.83%
aws awscdk cdk-constructs scheduler serverless cdk scheduling dynamodb

cdk-scheduler's Introduction

image

CDK construct for serverless scheduling

cdk-scheduler, a CDK construct to schedule events precisely and serverless ⏱

This construct enables to trigger an event at a given time on a serverless architecture.

You should use cdk-scheduler if you need to trigger an event at a precise time (down to the second) on your AWS application. If you want to compare options, check out our article on different serverless scheduling solutions.

Understand how the Scheduler works

cdk-scheduler is powered by SQS feature to delay events up to 15 minutes.

A lambda is scheduled to query a DynamoDB Table every 15 minutes, it pushes every events scheduled in the next 15 minutes to SQS with a delay corresponding the desired publication date.

Overview of the architecture

cdk-scheduler architecture diagram: dynamoDB with scheduled event linked to a lambda scheduled every 15 minutes publishes on an SQS with delay

Usage examples with CDK - Typescript

If you want to implement serverless scheduling you can get inspirations from cdk-scheduler full implementations :

  1. Connecting directly the scheduler to an API Gateway
  2. Connecting the Scheduler to a lambda

Payload format

For cdk-scheduler to function properly the elements added to DynamoDB must have the following attributes:

Attribute Type Description
pk string The primary key is always the same. Its value is the attribute partitionKey available in the construct instance
sk string The secondary key should start with the timestamp at which you wish to publish the event. You can concatenate with a unique id to be sure you do not have duplicates if you separate them with a #. For instance: ✅ 1649434680000#d66727f2-9df7-41b7-b2f8-211eb5581640 is a correct secondary key. ❌ 20220422-16:47:00:00Z00#66727f2-9df7-41b7-b2f8-211eb5581640 will never be read.
payload map This is an object, without format contraints. This payload will be sent in the event once it's published. Use this to detail the action you want to execute a the scheduled time

CONTRIBUTING

If you wish to contribute to cdk-scheduler:

  • you can open an issue to suggest improvements or to report a bug
  • you can open a pull-request to implement changes
  • you can send us love on twitter (@adelegauvrit, @nathperriolat and @EGuiyom) ❤️

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.