coders51 / rabbitmq-stream-js-client

rabbitmq-stream-js-client
MIT License
34 stars 5 forks source link

Check if cached connection can support more pub/subs before reusing #197

Closed tarzacodes closed 5 months ago

tarzacodes commented 5 months ago

Taking from the proposed PR (now closed by the original author) https://github.com/coders51/rabbitmq-stream-js-client/pull/194 Implement conditional reusing of cached connections

tarzacodes commented 5 months ago

Actually, after reviewing our current implementation I found out that we already supported a hard cap on the number of consumers/publishers on a single connection (and the opening of new connections to host those extra publishers/consumers), which can be set thru an env variable. This is good, but we still had two issues: 1) The publisher/consumer ids are unique across connections (they are kept track of in the client), and they increase monothically. So a client opening 257 publishers, even on different connections, would crash since the publisherId must be <256 (it is a uint8) 2) The max number of consumers/publishers can be set higher than 256 This PR linked to this issue takes care of these two points. Now publisher and consumer ids will be kept track of on the connection object.