Closed pbrisbin closed 3 years ago
Faktory does not have any way to push implicit state into a job but the batch callback can take any set of arguments you wish, including the BID.
b = Faktory::Batch.new
b.success = {"jobtype":"MySuccessCallback","args":[b.bid],"queue":"critical"}
...
Typically I would have job errors going to my email so I can fix any issues, DMS not necessary. If you don't have something like that, I would suggest using complete and sending a notification if the batch status shows that there are failures remaining in the batch.
Oh, that approach would certainly work, but can you translate that ruby into the line-protocol?
b = Faktory::Batch.new
# bid = BATCH NEW {"description":"An optional description for the Web UI", "success":{ what's going here? } }
b.success = {"jobtype":"MySuccessCallback","args":[b.bid],"queue":"critical"}
# What command is this then?
Ah right, I was confused. Wiki updated.
https://github.com/contribsys/faktory/wiki/Ent-Batches#callbacks
All callback jobs get special attributes in the custom
hash which provide context. Those attributes are not passed to the callback job as arguments but you can set them as thread-local variables (implicit state) or dynamically set an accessor on the job.
Callback jobs automatically have custom _bid ... set with their associated Batch ID ...
That's exactly what I was wondering, thanks!
I have an interesting BATCH use case and I'm just wondering if there's a way to accomplish it...
We want to use BATCH to wrap a bunch of Jobs and notify Dead Man's Snitch (DMS) at the end.
When you notify DMS, you can:
status=0
(I'll call this "success")status=n | n > 0
(I'll call this "failure")Faktory gives us:
success
(runs if all Jobs succeeded)complete
(always runs)I'm not sure how to best map the check-in's I want to perform in DMS to these, since there's no
failure
Job. Do I check-in neutral fromcomplete
and success fromsuccess
? This is probably what I'll try, but I'm not optimistic about how things will appear in the DMS UI.This got me thinking, if the
complete
Job knew its Batch Id, it could useBATCH STATUS
to find out what it needs to know and check-in appropriately with DMS all from the one callback. Is this possible?