Implement a multi user schedule management system. The idea is to allow user to set reminders and the system should notify them once it expires.
Currently, I can handle setting reminder, user talking to an endpoint, set a reminder for specific time and also multiple reminders, store to database -- using express server.
But my issue is that I need an automated trigger function that shoots the reminder once it expires.
I looked at Node schedule but idea of pool of waiting functions doesn't seem to be the right way to do it .
I was thinking some kind background job that runs all database and check against database , execute notification if reminder is due , but then huge problem on sending reminder on time , when it has crawl through all of them.
Then i was thinking maybe something of database with an internal trigger( maybe internal timer) function that automatically send notification when its expire clock ticks
P.S It's an SMS based app.
Hi sorry for the late delay, (in middle of exams ) any i want to thank you so much for the response , but can you be more specific or provide some resource links
I have spent a couple of hours on these and my issue is TriggerAt // takes a date how do i pass the function to be executed on triggerAt event ,
On reading on message queuse on redis, i found only few examples on how to implement this using nodejs , i happened upon kues which allows me to create jobs and process to carry out that job
// ..
queue.process('payment', (job, done) => {
...
queue.create('medicine::dosage', data)
.priority('critical')
.save() ..... // can set it triggerAt ,
but it can find any triggerAt type of feature or plus it just seem to call create and execute in a synchronise manner.
Shreyansh Pandey
node, coffee and everything in between
Alright, the simplest would be is to setup a Redis-based queue. The idea is very simple: put the data in the queue, something like:
{ type: "reminder", id: <DATABASE_BASED_ID> triggerAt: <TIMESTAMP_FORMAT_OF_THE_TRIGGER_TIME> }Since this is a very cheap operation, the background workers can keep on checking for the reminders in the queue, and when they find one which has a
triggerAtattribute with a value more than or equal to the current time, execute it: get the data, send the notification (use a push notification service), and then delete the job.All is async. :)
If you need assistance in implementing this, feel free to contact me! I hope this helps! :)