External updates to database

Hi, I have the following situation:

I have developed something using ROR. The data that is being displayed
by the view needs to be refreshed periodically - The data pertains to
the state of machines in a cluster. I dont want to query the state in my
model, because it may take a long time to do that. I want to have a
thread running (in the background) which is constantly checking the
status and updating the database. When a client makes a query, I just
want to reflect whatever the values updated by this thread is.

So my question is how do I do this within the RoR framework ? The
obvious solution would be to have an independant process which is doing
the queries and updating the db using sql bindings. However, this
coupling makes me nervous - if I change the tables or migrate, I will
need to update this code separately. I would rather use the RoR API’s to
accomplish this if possible.

Any suggestions would be appreciated

thanks
Siddharth

Siddharth wrote:

Hi, I have the following situation:

I have developed something using ROR. The data that is being displayed
by the view needs to be refreshed periodically - The data pertains to
the state of machines in a cluster. I dont want to query the state in my
model, because it may take a long time to do that. I want to have a
thread running (in the background) which is constantly checking the
status and updating the database. When a client makes a query, I just
want to reflect whatever the values updated by this thread is.

So my question is how do I do this within the RoR framework ? The
obvious solution would be to have an independant process which is doing
the queries and updating the db using sql bindings. However, this
coupling makes me nervous - if I change the tables or migrate, I will
need to update this code separately. I would rather use the RoR API’s to
accomplish this if possible.

Any suggestions would be appreciated

thanks
Siddharth

what about having a cron job calling a static method on your model?
for instance:
0 3 * * * current/script/runner -e production “MyModel.do_it()”

  • Jean-Etienne

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs