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.
To get started with this project, you need to clone this repository and install the node dependencies
$ git clone [email protected]:ToeFungi/event-scheduler.git
$ cd event-scheduler
$ npm install
Below illustrates how to schedule events.
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"
}
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"
}
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 | ☑ |
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.
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
You can track any work that is planned, in progress or finished on the public Trello board which can be found here
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.
MIT License
Copyright (c) 2019 Alex Pickering