1

i would like to trigger an event sometime in the future based on an event that is currently happening. I do not expect the volume to be too high, so i care a lot more about simplicity than performance.

For example:

  • event A happens. i need event B to happen a day later (not time critical)
  • system stores a record of event in db
  • ongoing process looks through the db, and executes the event Bs that are ready, and removes them from db

Does this make sense? I am using Ruby on rails - I imagine this is a fairly common usecase

meow
  • 27,476
  • 33
  • 116
  • 177

2 Answers2

2

Use the DelayedJob gem. Refer to this screen-cast for more details.

Harish Shetty
  • 64,083
  • 21
  • 152
  • 198
1

Yes it absolutely makes sense :). You should be probably looking at a Scheduler or a process that runs in the background. Take a look here and here

Basically, whenever you finish executing your event A, you will be putting an entry in the database with a field indicating when it should run. As you say, your ongoing process which should be scheduled to run in the background can either be scheduled in steps or do a polling and query the DB and carry on from there like you've said.

bragboy
  • 34,892
  • 30
  • 114
  • 171