A tasker is a piece of code that, upon receiving a task from flor, performs some work and then hands back the task with updated information to flor.
A tasker might do its job in the same Ruby process as the flor worker that invoked it, or it might call some external process.
An external service could be called and the tasker might reply only when the result is available. Timeouts could come in handy here.
TODO
TODO
When using the HashLoader
, one can add a tasker directly, with a Ruby block.
FLOR = Flor::Unit.new(loader: Flor::HashLoader, sto_uri: 'sqlite:/')
FLOR.add_tasker('clerk') { payload['ret'] = 'Kilroy was here' }
This is suitable only for blocks that perform quick operations on the payload and return immediately.
class MyTasker < Flor::BasicTasker
def on_task
end
def on_cancel
end
end
TODO
TODO