-
Notifications
You must be signed in to change notification settings - Fork 241
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
Access to actual JSON payload. #18
Comments
Currently, there's no way to access the JSON payload except through the args interface. I am investigating a way to specify the type of object you want for a worker function. Possibly something along the lines of: goworker.RegisterType("MyClass", myFunc, &MyType{}) where you would only do one type assertion within Alternatively, we could use json.RawMessage and have the function do the unmarshalling, but this, too, would require some reworking. Possibly something along the lines of: goworker.RegisterRaw("MyClass", myFunc) then within the worker var val MyType
json.Unmarshal(raw, val) What would work better for you? |
I suppose the |
+1 for RegisterRaw |
👍 As well. I think this will help with a lot of bigger payloads complex payloads. My workaround was actually to just save a temp .json file, and have the goworker trigger a download from s3, and unmarshal it into a struct. Though hacky, cut down time on building lots of workers. |
👍 on RegisterRaw. My workaround was to |
I'm new to Go, and am trying to figure out things. One thing which made goworker a bit hard to use was that the worker get an
args ... interface{}
as the payload. This means that theargs
would need to be manually type asserted to build the actual object structures. This can get cumbersome when its a complex JSON payload.I had asked if there was another way to do this on SO, but it seems like there isn't any.
If access to the JSON is provided, then a struct can be passed to unmarshal to build that type.
Let me know, and thanks for this brilliant package.
The text was updated successfully, but these errors were encountered: