Giter Site home page Giter Site logo

support Ready(count) about nsq.js HOT 4 OPEN

juliangruber avatar juliangruber commented on July 25, 2024
support Ready(count)

from nsq.js.

Comments (4)

dweinstein avatar dweinstein commented on July 25, 2024

would be nice

from nsq.js.

dweinstein avatar dweinstein commented on July 25, 2024

err, maybe it's already there? (see this) just wasn't in the docs...

[edit] So I played w/ it a bit and there is a bit of a race condition, I guess--if you set the reader.on('message', ..) handler at same time as doing the reader.ready(x) you'll likely not get it set in time and messages will start. e.g.,:

reader.ready(0)
reader.on('messages', function(msg) {
... // this will still start accumulating
});

vs

reader.ready(0)
setTimeout(function() {
  reader.on('messages', function(msg) {
    ... // this will wait for reader.ready(n) n > 0
  });
}, 1000);

[edit 2] unless you config your reader by specifying ready: false ... so just don't forget to set that to false! Personally I'd probably have both false and 0 have the same behavior here?

from nsq.js.

juliangruber avatar juliangruber commented on July 25, 2024

Excellent research :) We could even have nsq.reader({ ready: 3 }), to set before connecting.

reader.ready(0) won't have the same behavior because it's called after the internal connection has been created, and the ready value will already have been set.

@tj was the Ready api not ready yet?

from nsq.js.

tj avatar tj commented on July 25, 2024

TBH I forget, I think it initiates with a RDY so you can't stop it immediately since it's not sync but otherwise you can adjust

from nsq.js.

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.