Skip to content

Instantly share code, notes, and snippets.

@scalabl3
Last active December 27, 2015 00:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save scalabl3/7235173 to your computer and use it in GitHub Desktop.
Save scalabl3/7235173 to your computer and use it in GitHub Desktop.
Using a Timestamp as a Key for future Notifications

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": []
}
@scalabl3
Copy link
Author

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment