Could be done in redis also, with a sorted set, where the values are json 
payloads of task data and the scores are timestamps.  On an interval (like 
Jonathan suggested) you could do a query for all items older than 'now' and 
start processing them.

On Sunday, December 16, 2012 12:12:11 PM UTC-8, Jonathan Dickinson wrote:
>
> If you care about failure resilience at all:
>
> 1. You will need a pseudoqueue in SQL (or whatever) with a datetime field 
> indicating when the event needs to fire.
> 2. Every, say, 5 minutes (settimeout) query SQL for anything that needs to 
> happen in the next, say, 6 minutes.
> 3. Calculate the difference between now and when the event needs to occur 
> and settimeout.
> *** If you get anything that needed to happen in the past execute it 
> immediately.
>
> If your server is clustered you will also need a way to mark a row as 
> "server <ID> is dealing with this", "this has been dealt with" (which is 
> soon followed by deleting the row). You cluster will also need to be aware 
> of failing servers so that you can pick up the work they started but did 
> not finish. Your updates have to be atomic (e.g. 'UPDATE [Queue] SET 
> [ServerID] = @ThisServer WHERE [ServerID] IS NULL AND [ID] = @RowID').
>
> This type of pseudoqueue isn't *that* hard to write, you just need to 
> think about it a bit.
>
> On Sunday, 16 December 2012 15:53:40 UTC+2, Filipe wrote:
>>
>> Guys, simple question, but I can't find a way to do this: schedule 
>> date/time events.
>>
>> For example: get dynamically an event from a database (ie 12:00 
>> 01/01/2013 - "first lunch of 2013") and push it to my users only when local 
>> time is exactly 12:00 01/01/2013.
>>
>> What's the clever way to do this?
>>
>>

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Reply via email to