项目作者: ToeFungi

项目描述 :
A time based event scheduler designed to run on AWS Lambda functions and utilises AWS infrastructure such as DDB and CloudWatch
高级语言: TypeScript
项目地址: git://github.com/ToeFungi/event-scheduler.git
创建时间: 2019-11-27T18:55:02Z
项目社区:https://github.com/ToeFungi/event-scheduler

开源协议:MIT License

下载


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

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

Usage

Below illustrates how to schedule events.

HTTP Scheduled Event

Scheduling a message to be returned via an HTTP callback mechanism

  1. {
  2. "scheduledTime": "2019-12-05T17:26:32.846Z",
  3. "callback": {
  4. "type": "HTTP",
  5. "url": "https://some-url.com",
  6. "headers": {
  7. "authentication": "Bearer some-token"
  8. }
  9. },
  10. "message": {
  11. "foo": "bar"
  12. }
  13. }

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 -

  1. {
  2. "foo": "bar"
  3. }

SQS Scheduled Event

Scheduling a message to be returned via an SQS callback mechanism

  1. {
  2. "scheduledTime": "2019-12-05T17:26:32.846Z",
  3. "callback": {
  4. "type": "SQS",
  5. "url": "https://some-url.com",
  6. "headers": {
  7. "region": "us-east-1"
  8. }
  9. },
  10. "message": {
  11. "foo": "bar"
  12. }
  13. }

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 -

  1. {
  2. "foo": "bar"
  3. }

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

  1. $ npm run lint
  2. $ npm run test
  3. $ 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