-
Notifications
You must be signed in to change notification settings - Fork 2
Ruby interface
Creating a nice Ruby interface seems like an easy problem at first. This doesn’t look hard to implement:
Jobby(max_children: 3, socket: "/tmp/my_job.sock") do
puts "Well this is just marvellous!"
end
Unfortunately, it’s not simple to do in a generic way. REE is COW-friendly and allows us to simply fork
and run the server, passing the block to it (woohoo!). MRI 1.8 isn’t at all COW-friendly and, currently, MRI 1.9 lies somewhere in between.
If the calling process is large, 1.8 and 1.9 may not want to fork to start the server. We must resort to creating a new Ruby process and passing the Ruby code to it somehow. I don’t think this is possible in a 1.8 and 1.9 compatible way (ruby2ruby is 1.8 only and 1.9 doesn’t have a way to access the text of a block.
Of course, writing the code to be used in the child in a separate file and reading that in is a possibility.
Lots of food for thought.