Sorry, I didn't mean to omit peek_job in the Pool interface. I'll send
out beanstalk-client 0.10.0 later today; it'll have peek_job,
peek_ready, peek_delayed, and peek_buried.
I'm not sure why you get UnexpectedResponse -- is it possible you're
running mismatched versions of beanstalkd and beanstalk-client? What
is the response (i.e. what is the output of puts e.inspect in your
implementation of peek_job)?
kr
Then I would expect peek to fail and peek_job to work for you, unless
the job doesn't exist (see below).
> I notice that RawConnection.peek swallows the
> UnexpectedResponse exception whereas RawConnection.peek_job does not.
> Any reason for the inconsistency?
No, in fact that's why you were seeing UnexpectedResponse. It's fixed it in git.
kr
Yes.
> So given that constraint, my strategy will be to check the total-jobs
> variable:
> AsyncObserver::Queue.queue.stats['total-jobs']
> ...
That's reasonable.
> Even better we could change the API so that when a job is submitted it
> returns not just the ID but current unixtime. Then when you call
> peek_job, the method can determine based on stats whether the job has
> disappeared.
>
> I noticed that there is a job_stats method on RawConnection, If you're
> adding to the Pool API, you might as well add that to Pool.
This is exposed as Job#stats. So conn.peek_job(123).stats would work
(though it would result in an extra round trip).
> Thanks for a great innovative plugin!
You're most welcome! I hope you find it useful.
kr