Pollos helps you send notifications on a given schedule. It also allows you to modify your schedules dynamically.
This API more or less follows JSONAPI v1.0. Scheduling is built on top of Chronos
type: Authorization
value: Token token=#{mytoken}
{
"data" : {
"type" : "notifications",
"attributes" : {
"delivery_method": "topic",
"delivery_option": { "receivers": ["someone"] },
"callback" : "https://abc.com",
"meta": { "a" : "b"},
"message": {
"subject": "Hello!",
"body": "...from the other side"
},
"schedule" : {
"type" : "x.minutes", "x": 2, "time" : "16:51:00", "timezone" : "Europe/Berlin"
}
}
}
}
- delivery_method:
[required: true]How to deliver this notification. Currently, only topic-based mobile notification is supported - delivery_option:
[required: true]Specifies receivers/receiver conditions for a notification. Receivers are specific topics, while conditions are topics matching a specific condition. Valid Representations are"receivers": ["someone", "de"]"receiver_conditions": ["'de' in topics || 'articles' in topics"]
- message:
[required: true]Specifies a message to build. - schedule:
[required: false]- When there is no schedule specified, the job will run immediately.
- When specified, it will instruct the job to run at a specific point in time, optionally with duration to repeat it. See below for more details.
- callback:
[required: false]A callback to POST to after the notification is sent . The status of the request is sent back along with the meta field specified when the request was made - meta:
[required: false]Any custom information you want to store
{
"data":{
"id": "00000000000001",
"type": "TopicNotification",
"attributes":{
"status": "active",
"delivery_method": "topic",
"callback": "https://abc.com",
"chronos_id": null,
"meta":{"a": "b"},
"message": {
"subject": "Hello!",
"body": "...from the other side"
},
"schedule":{ "type": "x.minutes", "x": 2, "time": "16:51:00", "timezone": "Europe/Berlin" },
"delivery_option":{"receivers":["someone" ]},
"scheduled": true,
"recurred":[]
}
},
"jsonapi" : { "version": "1.0" }
}
- status:
The status of the job. Possible values are
- Active: Queued Successfully
- Delivered: Job finished successfully
- Failed: Job failed
- Paused: The notification is paused
- chronos_id: The ID of the job in Chronos.
- scheduled: Whether the job was scheduled or immediate.
- recurred: History of the last occurrences of the job
In case of any errors, an array of errors will be returned with a status of 200.
{
"errors":[
{
"title": "NotificationException Delivery Method is invalid",
"detail": "Delivery Method is invalid"
}
]
}
{
"data":{
"id": "001",
"type": "TopicNotification",
"attributes":{
"status": "active",
"delivery_method": "topic",
"callback": "https://abc.com",
"chronos_id": null,
"meta":{"a": "b"},
"message": {
"subject": "Hello!",
"body": "...from the other side"
},
"schedule":{ "type": "x.minutes", "x": 2, "time": "16:51:00", "timezone": "Europe/Berlin" },
"delivery_option":{"receivers":["someone" ]},
"scheduled": true,
"recurred":[]
}
},
"jsonapi" : { "version": "1.0" }
}
{
"data" : {
"attributes" : {
"callback" : "https://oudeudflxy.localtunnel.me/articles",
"meta": { "a" : "b"},
"schedule" : {
"type" : "x.minutes", "x": 3, "time" : "16:51:00", "timezone" : "Europe/Berlin"
}
}
}
}
The response is synonymous to a GET.
{
"data" : {
"attributes" : {
"pause" : true
}
}
}
{
"data" : {
"attributes" : {
"unpause" : true
}
}
}
{
"data": null,
"jsonapi":{
"version": "1.0"
}
}
"data": [
{
"id": "59d743bf8b0603e927292735",
"type": "TopicNotification",
"attributes":{"status": "active", "delivery_method": 'topic', "callback": null, "chronos_id": null,…}
},
{
"id": "59d743ec8b0603e927292736",
"type": "TopicNotification",
"attributes":{"status": "active", "delivery_method": 'topic', "callback": null, "chronos_id": null,…}
},
...
],
"jsonapi":{
"version": "1.0"
}
The schedule key in the hash contains delayed delivery options. It contains datetime and repetition options for scheduling.
A schedule hash can contain the following information:
schedule: {
type: '...',
time: '00:00', # defaults to 00:00. You can also specify seconds with 00:00:00
repeat: false, # defaults to true
repeat_count: 2, # number of times that this should be repeated, by default infinite!!!
timezone: 'UTC', # defaults to UTC, all timezones supported by TZInfo are supported.
}
The following schedule types are supported.
type: 'day.week', day: 'monday', time: '01:00' # Every Monday at 01:00
type: 'date.year', date: 'dd.mm', time: '00:00' # Every year at the date of 20.10.xxxx
type: 'day.month', date: 15, time: '00:00' # At the 15th every month
type: 'time.day', time: '01:00' # At 01:00 every day
type: 'x.days', x: 2, time: '00:00' # Every 2 days
type: 'x.hours', x: 6, time: '00:00' # Every 6 hours
type: 'x.months', x: 2, time: '00:00' # Every 2 months
type: 'x.minutes', x: 2, time: '00:00' # Every 2 minutes starting from 00:00
Omit the schedule hash to send an immediate notification
{
delivery_method: 'topic',
delivery_options: {
receivers: ['mobile_de']
}
}
This project uses
- mongodb
- Marathon with Mesos with Zookeeper
- Chronos on top of Mesos
- Ruby on Rails
Simplest way to get up and running with all the infrastructure is
docker-compose up
In case you intend to run the app and db on your own,
docker-compose up -f docker-compose-no-rails-and-db
All persistent data is stored inside the ./persistence folder. If you don't want to use Docker, you can setup DC/OS with all required tools and run the Rails App on top of it.
- Install mongodb
- Start Rails
bundle
rails s
- Run specs with
rake
To build and push a new version of the app, use
./bin/build_and_push.sh
ECS hosts all the infrastructure. You can restart the service from ECS UI / CLI.
Mirror Notifications do not require delivery options. At the scheduled time, they make a POST request to the callback URL with the meta parameters that are supplied during the request.
{
delivery_method: 'mirror',
callback: ['http://somewhere.de/callback'],
meta: { a: 'b' }
schedule: {
type: 'day.week',
day: 'monday',
time: '00:00'
}
}