minion
minion copied to clipboard
How to pass that :when
Hello, I would like to do something like this:
job "destroy.copy", :when => lambda { args["file_server"] == APP_CONFIG['server']['domain'] } do |args|
...
How should this look?
The when block subscribes or unsubscribes the daemon to the queue so the block cannot introspect messages its not seen yet. It looks like you're trying to make it so the file server handles one type of destroy.copy and a different server handles a different kind.
I would normally handle something like this with different queues per job type
job "destroy.copy.file_server" do ...
There is however a feature in Rabbit I'm not using yet where you can pass headers with a message and those headers can match or not match the binding spec. If I were to support them it would look like
Minion.enqueue "destroy.copy", { "foo" => "bar" }, :headers => { "type" => "file_server"}
and the job would be
job "destroy.copy", :headers => { "type" => "file_server" } do ...
Which is I think what you want. If this solution works for you and the first one I proposed does not let me know and I'll see if I can add it when I get back from my holiday in July.