Giter Site home page Giter Site logo

Comments (4)

mperham avatar mperham commented on July 25, 2024 1

As object hydration can often raise an error or require the database, this is something out of Sidekiq’s responsibilities IMO. I advise people to use lazy accessors which load the object on demand. Save user_id as an attribute so only the id is persisted to the job.

from sidekiq.

mperham avatar mperham commented on July 25, 2024
  1. Already the default. This adds the client middleware in all environments:

def persist(klass_or_array, config = Sidekiq.default_configuration)
cattrs = build_cattrs_hash(klass_or_array)
config.client_middleware.add Save, cattrs
config.server_middleware.add Load, cattrs
end

2. Sounds intriguing but I'm not sure what that entails. I'd be happy to get a PR or discuss more.

from sidekiq.

qblanc avatar qblanc commented on July 25, 2024

Thanks for the answer !

  1. Sorry I got confused by the config.client_middleware, I didn't knew the Sidekiq.default_configuration was configuring both server and client side at the same time
  2. Our problem is that we are using Current to pass along objects (for instance Current.agent) and the current implementation is serializing with to_s, thus serializing the name of the object rather than the whole object or the id at least. On the server side, the Load method is recreating a Current.agent that is not the previous Current.agent but only a string. Maybe it is bad practice to use Current with records, but the doc is actually taking such an example (Current.user). It would be cool if the module was able to pass along objects/records rather than just strings (unless I only didn't understood how to do it 😬)

from sidekiq.

qblanc avatar qblanc commented on July 25, 2024

Alright, I get the point. Thanks for the insight

from sidekiq.

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.