-
Notifications
You must be signed in to change notification settings - Fork 2
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
Fail Jobs that don't decode as expected #101
Conversation
This may be generally useful, but the immediate need is it will allow us to test some behavior around it, which we are about to improve.
Reproduces #88.
Originally, this decoding failure would enter the `Left` case and only log the error. The Job would hang, neither `ACK`ed nor `FAIL`ed until its reservation expired. Now, as long as it is valid JSON, we reach the `Right`-`Just` branch and attempt to decode it further there. This way, if it can't decode, that exception occurs in the right place to `FAIL` the job, as desired. Closes #88.
5a3289e
to
f2d8d61
Compare
-- | <https://github.com/contribsys/faktory/wiki/Worker-Lifecycle#heartbeat> | ||
heartBeat :: Client -> WorkerId -> IO () | ||
heartBeat client workerId = do | ||
threadDelaySeconds 25 | ||
command_ client "BEAT" [encode $ BeatPayload workerId] | ||
|
||
fetchJob | ||
:: FromJSON args => Client -> Queue -> IO (Either String (Maybe (Job args))) | ||
fetchJob :: Client -> Queue -> IO (Either String (Maybe (Job Value))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So commandJSON
will parse to Value
and then we parse it again in decodeJob
to the type we are expecting?
Why this route instead of logging and throwing the err
in https://github.com/freckle/faktory_worker_haskell/pull/101/files#diff-ac403ab2ca059ce5c79709e5f3fb294cb32ba3260b17fb4c21e185653ec747c9R107 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I see, I guess we don't have a job
to processAndAck
in that case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we don't have a job to processAndAck in that case
Exactly. There were some more details about that in the linked Issue:
When we FETCH to Job SomeAppType, if the args don't parse as SomeAppType, we don't even get back the Job part. Without that, we don't know the jid and can't report the FAIL. To Faktory, the Job was consumed and is in-progress -- until the reservation expiry.
Originally, this decoding failure would enter the
Left
case and onlylog the error. The Job would hang, neither
ACK
ed norFAIL
ed untilits reservation expired.
Now, as long as it is valid JSON, we reach the
Right
-Just
branch andattempt to decode it further there. This way, if it can't decode, that
exception occurs in the right place to
FAIL
the job, as desired.Closes #88.