Skip to content

A time based event scheduler designed to run on AWS Lambda functions and utilises AWS infrastructure such as DDB and CloudWatch

License

Notifications You must be signed in to change notification settings

ToeFungi/event-scheduler

Repository files navigation

Event Scheduler

Build Status Quality Gate Status Bugs Code Smells Coverage

This is the event scheduler module within the Event Scheduler Domain. It's purpose as a Lambda is to accept incoming events via API Gateway, format these events and store them in DynamoDB.

Table of Content

Installation

To get started with this project, you need to clone this repository and install the node dependencies

$ git clone git@github.com:ToeFungi/event-scheduler.git
$ cd event-scheduler
$ npm install

Usage

Below illustrates how to schedule events.

HTTP Scheduled Event

Scheduling a message to be returned via an HTTP callback mechanism

{
    "scheduledTime": "2019-12-05T17:26:32.846Z",
    "callback": {
        "type": "HTTP",
        "url": "https://some-url.com",
        "headers": {
            "authentication": "Bearer some-token"
        }
    },
    "message": {
      "foo": "bar"
    }
}

The above will attempt send a POST to the URL specified above containing the message body above at the time specified. This will be accurate to about a minute. The response body will look as follows -

{
  "foo": "bar"
}

SQS Scheduled Event

Scheduling a message to be returned via an SQS callback mechanism

{
    "scheduledTime": "2019-12-05T17:26:32.846Z",
        "callback": {
        "type": "SQS",
        "url": "https://some-url.com",
        "headers": {
            "region": "us-east-1"
        }
    },
    "message": {
      "foo": "bar"
    }
}

The above will attempt publish the scheduled event to the URL specified above containing the message body above at the time specified. This will be accurate to about a minute. The response body will look as follows -

{
  "foo": "bar"
}

Overview of Request Payload

Property Description Required
scheduledTime The time that the event should be triggered via the callback configured
callback Callback configuration required when the event is triggered
callback.type Enumerated value [ 'HTTP' | 'SQS' ]
callback.url The URL for the callback to be triggered on
callback.headers Headers that should be supplied as key-value pairs
message The payload that should be delivered

Important to Note

When using the callback type of SQS, the region must be defined within the callback.headers for the message to be properly returned.

When using the callback type of HTTP, the callback will always happen over a POST request.

Tests

This project is completely covered by unit tests. To run these tests you can run the following commands

$ npm run lint
$ npm run test
$ npm run coverage

Ongoing Development

You can track any work that is planned, in progress or finished on the public Trello board which can be found here

Contribution

Any feedback and contributions are welcome. Just create a pull request. Please ensure to include any adjustments to the existing tests and to cover the new code with unit tests.

License

MIT License

Copyright (c) 2019 Alex Pickering

About

A time based event scheduler designed to run on AWS Lambda functions and utilises AWS infrastructure such as DDB and CloudWatch

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published