public
Last active

Using a Timestamp as a Key for future Notifications

  • Download Gist
gistfile1.md
Markdown

Notification Document

KEY: 10/31/2013::20:00

{
    "email": [
        { "uid": 1029, "content_id": "c::2822020", "type": "halloween" }
        { "uid": 2058, "content_id": "c::2822020", "type": "halloween" }
    ],
    "push": [
       { "phone": "404-555-1212", "content_id": "c::2822021" } 
    ]
}

and another one the following minute:

KEY: 10/31/2013::20:01

{
    "email": [
      { "uid": 2203, "content_id": "c::2822020", "type": "halloween" }
      { "uid": 8928, "content_id": "c::2822020", "type": "halloween" }
    ],
    "push": []
}

You create a worker that once a minute grabs the notifications document and puts the tasks within the document into worker queues for each type of task (of course you can just have one type or many types). Then you have a bank of workers that watch the queue(s) and perform the tasks (they are ignorant workers that don't need to know bout how the tasks get into the queue).

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.