Code Monkey home page Code Monkey logo

Comments (3)

RichardKnop avatar RichardKnop commented on May 14, 2024

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.

from machinery.

pgruenbacher avatar pgruenbacher commented on May 14, 2024

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

from machinery.

RichardKnop avatar RichardKnop commented on May 14, 2024

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 Result struct, which has a corresponding table in your database. Just return the primary ID of result object. And then whatever code where you are handling result values should just take the primary key and fetch the object from the database.

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.

from machinery.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.