Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get Number of Ready Jobs Enqueued into a Tube #64

Closed
micmicsuarez opened this issue Nov 10, 2016 · 1 comment
Closed

Get Number of Ready Jobs Enqueued into a Tube #64

micmicsuarez opened this issue Nov 10, 2016 · 1 comment

Comments

@micmicsuarez
Copy link

micmicsuarez commented Nov 10, 2016

Hi @nesquena, I developed a code that inserts tube's job into an array.

This is my code that inserts a job to an array.

beanstalk = Beaneater.new(Beaneater.configuration.beanstalkd_url)
tube = beanstalk.tubes["my-tube"]
array = Array.new
loop do 
	@array << tube.reserve
	break if @array.size == 100
end

Is there a way to get the number of ready jobs in a tube?

I was thinking to implement like this.

loop do 
	@array << tube.reserve
	break if @array.size == tube.size
end

Thanks,
Michael

@micmicsuarez
Copy link
Author

hi @nesquena, I will close this issue because I got the way on how to retrieve the number of ready jobs in a tube.

I used this code to retrieve the ready jobs.

tube.stats.current_jobs_ready.to_i

I modified my code like this.

loop do 
    @array << tube.reserve
     break if @array.size == tube.stats.current_jobs_ready.to_i
end

Thanks,
Michael

@micmicsuarez micmicsuarez changed the title Get Number of Jobs Enqueued into a Tube Get Number of Ready Jobs Enqueued into a Tube Nov 10, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant