-
Notifications
You must be signed in to change notification settings - Fork 894
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
Pass struct as result value? #70
Comments
Structs are difficult as all return values must be JSON serializable. Maps might be easier to support but only restricted to maps that can be represented as a valid JSON object. So the implementation might be a bit trickier. |
Actually what I can do is just serialize the structs I need into strings manually myself using the encoding/json package for the time being. It seems similar questions are asked with Redis and the response is to serialize manually. http://stackoverflow.com/questions/27468458/go-how-to-save-and-retrieve-a-struct-to-redis-using-redigo |
This sounds like a bad design. Any tasks exposed via machinery should be quite simple and complex logic (methods that return, accept structs) should be private and called from the simple exposed public tasks. What I would probably do is have some sort of a I would suggest something similar for input arguments, just passing primary keys as arguments and fetching from database / creating structs inside the function. This should keep the public API clean and simple. Bulk of the business logic can be inside private functions / methods. |
Is there an opportunity for a task to return a struct or map value in order to pass more information. For instance if I'm doing file processing tasks, I'd like to convey information like filepaths, sizes, stats, etc. Currently I'm just writing the data to a json file and sending back a string value of the config filepath as a result. Is it problematic for passing such a struct value to chained tasks?
The text was updated successfully, but these errors were encountered: