dudleycarr / nsqjs

NodeJS client library for NSQ
https://nsqjs.com
MIT License
558 stars 75 forks source link

pause but balance all the time #403

Open 743v45 opened 1 year ago

743v45 commented 1 year ago

Normal pause need only one balance, where the balance is always performed.

const nsq = require('./lib/nsq')

const reader = new nsq.Reader('test', 'test', {
  nsqdTCPAddresses: [
    '10.0.6.88:41501',
  ],
})

reader.connect()

reader.on('message', msg => {
  console.log('Received message [%s]: %s', msg.id, msg.body.toString())
  msg.finish()
})

reader.pause();
$ DEBUG=* node local-b.js
  nsqjs:reader:test/test Configuration +0ms
  nsqjs:reader:test/test ReaderConfig {
  nsqjs:reader:test/test   authSecret: null,
  nsqjs:reader:test/test   clientId: null,
  nsqjs:reader:test/test   deflate: false,
  nsqjs:reader:test/test   deflateLevel: 6,
  nsqjs:reader:test/test   heartbeatInterval: 30,
  nsqjs:reader:test/test   maxInFlight: 1,
  nsqjs:reader:test/test   messageTimeout: null,
  nsqjs:reader:test/test   outputBufferSize: null,
  nsqjs:reader:test/test   outputBufferTimeout: null,
  nsqjs:reader:test/test   requeueDelay: 90000,
  nsqjs:reader:test/test   sampleRate: null,
  nsqjs:reader:test/test   snappy: false,
  nsqjs:reader:test/test   tls: false,
  nsqjs:reader:test/test   tlsVerification: true,
  nsqjs:reader:test/test   key: null,
  nsqjs:reader:test/test   cert: null,
  nsqjs:reader:test/test   ca: null,
  nsqjs:reader:test/test   idleTimeout: 0,
  nsqjs:reader:test/test   lookupdHTTPAddresses: [],
  nsqjs:reader:test/test   lookupdPollInterval: 60,
  nsqjs:reader:test/test   lookupdPollJitter: 0.3,
  nsqjs:reader:test/test   lowRdyTimeout: 50,
  nsqjs:reader:test/test   name: null,
  nsqjs:reader:test/test   nsqdTCPAddresses: [ '10.0.6.88:41501' ],
  nsqjs:reader:test/test   maxAttempts: 0,
  nsqjs:reader:test/test   maxBackoffDuration: 128
  nsqjs:reader:test/test } +1ms
  nsqjs:reader:test/test discovered 10.0.6.88:41501 for test topic +4ms
  nsqjs:reader:test/test connecting to 10.0.6.88:41501 +1ms
  nsqjs:reader:test/test:conn:10.0.6.88/41501 CONNECTING +0ms
  nsqjs:reader:test/test pause +1ms
  nsqjs:reader:test/test:rdy PAUSE +0ms
  nsqjs:reader:test/test:conn:10.0.6.88/41501 CONNECTED +7ms
  nsqjs:reader:test/test:conn:10.0.6.88/41501 SEND_MAGIC_IDENTIFIER +1ms
  nsqjs:reader:test/test:conn:10.0.6.88/41501 IDENTIFY +0ms
  nsqjs:reader:test/test:conn:10.0.6.88/41501 {
  nsqjs:reader:test/test:conn:10.0.6.88/41501   client_id: 'taevasnoMini',
  nsqjs:reader:test/test:conn:10.0.6.88/41501   deflate: false,
  nsqjs:reader:test/test:conn:10.0.6.88/41501   deflate_level: 6,
  nsqjs:reader:test/test:conn:10.0.6.88/41501   feature_negotiation: true,
  nsqjs:reader:test/test:conn:10.0.6.88/41501   heartbeat_interval: 30000,
  nsqjs:reader:test/test:conn:10.0.6.88/41501   hostname: 'taevasnoMini.lan',
  nsqjs:reader:test/test:conn:10.0.6.88/41501   long_id: 'taevasnoMini.lan',
  nsqjs:reader:test/test:conn:10.0.6.88/41501   short_id: 'taevasnoMini',
  nsqjs:reader:test/test:conn:10.0.6.88/41501   snappy: false,
  nsqjs:reader:test/test:conn:10.0.6.88/41501   tls_v1: false,
  nsqjs:reader:test/test:conn:10.0.6.88/41501   user_agent: 'nsqjs/0.13.0'
  nsqjs:reader:test/test:conn:10.0.6.88/41501 } +0ms
  nsqjs:reader:test/test:conn:10.0.6.88/41501 IDENTIFY_RESPONSE +2ms
  nsqjs:reader:test/test nsqd_connected +9ms
  nsqjs:reader:test/test:conn:10.0.6.88/41501 {
  nsqjs:reader:test/test:conn:10.0.6.88/41501   max_rdy_count: 2500,
  nsqjs:reader:test/test:conn:10.0.6.88/41501   version: '1.2.1',
  nsqjs:reader:test/test:conn:10.0.6.88/41501   max_msg_timeout: 900000,
  nsqjs:reader:test/test:conn:10.0.6.88/41501   msg_timeout: 60000,
  nsqjs:reader:test/test:conn:10.0.6.88/41501   tls_v1: false,
  nsqjs:reader:test/test:conn:10.0.6.88/41501   deflate: false,
  nsqjs:reader:test/test:conn:10.0.6.88/41501   deflate_level: 6,
  nsqjs:reader:test/test:conn:10.0.6.88/41501   max_deflate_level: 6,
  nsqjs:reader:test/test:conn:10.0.6.88/41501   snappy: false,
  nsqjs:reader:test/test:conn:10.0.6.88/41501   sample_rate: 0,
  nsqjs:reader:test/test:conn:10.0.6.88/41501   auth_required: false,
  nsqjs:reader:test/test:conn:10.0.6.88/41501   output_buffer_size: 16384,
  nsqjs:reader:test/test:conn:10.0.6.88/41501   output_buffer_timeout: 250
  nsqjs:reader:test/test:conn:10.0.6.88/41501 } +3ms
  nsqjs:reader:test/test:conn:10.0.6.88/41501 IDENTIFY_COMPRESSION_CHECK +1ms
  nsqjs:reader:test/test:conn:10.0.6.88/41501 AUTH +0ms
  nsqjs:reader:test/test:conn:10.0.6.88/41501 SUBSCRIBE +0ms
  nsqjs:reader:test/test:conn:10.0.6.88/41501 SUBSCRIBE_RESPONSE +0ms
  nsqjs:reader:test/test:conn:10.0.6.88/41501 READY_RECV +3ms
  nsqjs:reader:test/test ready +7ms
  nsqjs:reader:test/test:rdy:conn:10.0.6.88/41501 INIT +0ms
  nsqjs:reader:test/test:rdy PAUSE +17ms
  nsqjs:reader:test/test:rdy balance +0ms
  nsqjs:reader:test/test:rdy PAUSE +51ms
  nsqjs:reader:test/test:rdy balance +0ms
  nsqjs:reader:test/test:rdy PAUSE +52ms
  nsqjs:reader:test/test:rdy balance +0ms
  nsqjs:reader:test/test:rdy PAUSE +51ms
  nsqjs:reader:test/test:rdy balance +0ms
  nsqjs:reader:test/test:rdy PAUSE +51ms
  nsqjs:reader:test/test:rdy balance +0ms
  nsqjs:reader:test/test:rdy PAUSE +50ms
  nsqjs:reader:test/test:rdy balance +1ms
  nsqjs:reader:test/test:rdy PAUSE +50ms
  nsqjs:reader:test/test:rdy balance +0ms
  nsqjs:reader:test/test:rdy PAUSE +51ms
  nsqjs:reader:test/test:rdy balance +0ms
  nsqjs:reader:test/test:rdy PAUSE +51ms
  nsqjs:reader:test/test:rdy balance +0ms
  nsqjs:reader:test/test:rdy PAUSE +52ms
  nsqjs:reader:test/test:rdy balance +0ms
  nsqjs:reader:test/test:rdy PAUSE +51ms
  nsqjs:reader:test/test:rdy balance +0ms
  nsqjs:reader:test/test:rdy PAUSE +51ms
  nsqjs:reader:test/test:rdy balance +0ms
  nsqjs:reader:test/test:rdy PAUSE +51ms
  nsqjs:reader:test/test:rdy balance +0ms
  nsqjs:reader:test/test:rdy PAUSE +50ms
  nsqjs:reader:test/test:rdy balance +0ms
  nsqjs:reader:test/test:rdy PAUSE +52ms
  nsqjs:reader:test/test:rdy balance +0ms
  nsqjs:reader:test/test:rdy PAUSE +50ms
  nsqjs:reader:test/test:rdy balance +0ms
  nsqjs:reader:test/test:rdy PAUSE +51ms
  nsqjs:reader:test/test:rdy balance +0ms
  nsqjs:reader:test/test:rdy PAUSE +51ms
  nsqjs:reader:test/test:rdy balance +0ms
^C
dudleycarr commented 1 year ago

Good catch! Do you want to attempt a fix?

743v45 commented 1 year ago

I have no global perspective now.

Wait till I figure it out.