Closed mperham closed 6 months ago
I'm backing off this change. I think the better approach is to adjust the job definition in v2 to use generics so that jobs can define a typed struct for their args which can be safely marshalled by JSON. The larger issue is defining a migration path away from Args []interface{}
.
As #395 notes, unmarshalling JSON in Go can reduce precision for untyped numeric elements (
any
orinterface{}
) because it defaults to using Float64 as the type. We can lose precision as there are some Int64 values which can't be precisely represented as a Float64.This PR aims to do the following:
Decoder.UseNumber()
so that Faktory will preserve numeric elements. This will be off by default in 1.x but can be enabled with a flag. This will be on by default in 2.x.client.Info()
command which returns a nastymap[string]interface{}
requiring loads of type assertions. Not ergonomic or idiomatic. Instead we provide a newclient.CurrentState()
API which returns a client.FaktoryState structure which is almost entirely typed.The test suite runs green locally with UseNumber = true or false.
Related to #395