GithubHelp home page GithubHelp logo

Comments (6)

andrewgodwin avatar andrewgodwin commented on July 24, 2024

This isn't something natively built into channels - response channels won't get listened to by workers in the way you intend (and you have reminded me I should make them unroutable); they'll just get multiple listeners anyway.

If you want to do this, you need to either:

  • Use your own custom messages with an incrementing order key and the global_ordering decorator in strict mode with a custom reply channel that matches a username
  • Manually keep track of the lock state using a datastore
  • Don't use channels for this and use something else

Channels is generally designed for shared-nothing processing, so it's not natively suited to the idea of "one command per user" - by asking for that, you suddenly require that the whole system knows about the rest of it, which is great for processing but awful for performance. This is one of the things, like retrying tasks, that I expect to be built on top of it as an opt-in thing for people.

from channels.

erikash avatar erikash commented on July 24, 2024

Thanks for the elaborate answer!

Regarding the first option, can I use a different order key per "account"?

from channels.

erikash avatar erikash commented on July 24, 2024

Or better terminology would be account revision...

from channels.

andrewgodwin avatar andrewgodwin commented on July 24, 2024

Order is enforced strictly on the value of reply_channel, so match that up as you like.

from channels.

andrewgodwin avatar andrewgodwin commented on July 24, 2024

Be aware, though, that channels is non-guaranteed delivery - there's a chance that one of your messages won't get through at all (very small, but you need to prepare for it). If you absolutely need guaranteed, in-order, exactly-once processing, channels is not the task queue you need.

from channels.

erikash avatar erikash commented on July 24, 2024

Great thanks!

from channels.

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.