Hello,
I'm attempting to create a web front-end for 'managing' our beanstalkd
server, and by managing I mean the ability to:
* browse watched and used tubes
* browse jobs belonging to a certain tube {ready | buried | delayed}
* bury a job, delete it, or modify its priority
* view currently active / reserved jobs
After a bit of work and reading, I figured some of what I needed can
not be done, but some others can. Here's what I did, and what I'm
having trouble doing so far:
* note: I'm using Ruby, and the Beanstalk-client gem
Listing tubes and their stats is trivial, given the gem's api.
However, browsing jobs that belong to a given tube was not as trivial.
I've tried two methods to accomplish this, then sticked with the 2nd
one:
1) since it's not possible to iterate over jobs, I created a temp
tube, then reserved every job in the original queue one at a time,
processing them on the way ( pushing into the temp queue , and storing
their data in my output hash ) then deleting them from the original.
Once the queue is empty, I re-do the operation but switch the queues,
so I populate the original queue again from the jobs now residing in
the temp.
caveats: each job was being deleted, and upon creation it's gaining
a new ID .. that did not seem reasonable given that my goal is to
"browse" / read data, besides the fact that it might clash with the
running poller; if the workers are done and they find the queue to be
empty, they will be put to sleep until their timer pops up again ...
very slight chance of happening, but still possible
2) same as method one, instead I dropped the usage of a temp tube, and
stopped deleting the jobs .. I would reserve every one, store data,
then release.. original queue was not affected and it's working fine
Now the reason I mentioned *how* I did what I tried to do is because I
can't get past this, I need to be able to a) bury b) release a
specific job. I have the job ID, but there is no way to retrieve the
job object using an ID except for "peek"ing, and that doesn't allow me
to do either of the operations.
It seems I have to reserve a job to be able to bury or release it. If
I retrieve it by peeking, I can only delete it.
Idea: So I thought, maybe I can change the job's priority and set it
to be the lowest, so that I'll be "sure" to reserve it, reserve, then
modify. But I couldn't do that either, since the gem API doesn't
expose any method by which to change a job's priority.
I'm really confused because it's looking to me like it's alot of
trouble to retrieve this data or manage jobs. How do you guys do it?
And am I way off with what i'm trying to accomplish?
--
You received this message because you are subscribed to the Google Groups
"beanstalk-talk" 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/beanstalk-talk?hl=en.