contribsys / faktory_worker_go

Faktory workers for Go
Mozilla Public License 2.0
242 stars 43 forks source link

Cannot set retries to 0. #26

Closed MrJoy closed 5 years ago

MrJoy commented 5 years ago

https://github.com/contribsys/faktory/blob/master/server/commands.go#L57

Setting this in the server creates a problem wherein Go-based clients cannot set the retry count to 0: The use of omitempty in the definition of Job will result in any field whose value is the default for that type being omitted. Since 0 is the default value for int in Go, the JSON marshaller omits the field when this is set to zero.

You could address this by making the field a *int, but that will result in compile errors for existing Go clients that attempt to set this value. You could also address this by removing the omitempty declaration, but that will break clients silently if they construct a Job without going through faktory.NewJob and don't set this field properly.

Regardless, I'm now stuck in a situation where my only option is to use -1 and thus send jobs to the dead queue, when I'd prefer they get discarded. Any suggestions here?

mperham commented 5 years ago

I believe we should remove omitempty from this element. The retry element is one that we want to always be there. Apps should be using the NewJob constructor.