Comments (16)
1.i delete appendSub and Added appendNsqd interface for multiple nsqd.
2. deleting NsqConsumer object will disconnect all connection.but, it's not thread-safe,you can only delete NsqConsumer object in the loop thread.
3.you need to update uv-cpp to version 1.4.8
from uvnsq.
yes,one connection can only subscribe to one topic && channel.
from uvnsq.
do you mean a NsqConsumer object append multiple tcp connection?
i think this is unreasonable. one consumer should subscribe one topic。you can new multiple consumers object to manage multiple topics。
this consumers can run on the same loop(thread). so you can share variables to pass data.
from uvnsq.
Yes, I mean 1 consumer = 1 nsq topic and multiple connections to multiple nsqd.
from uvnsq.
I will consider how to implement this feature.
from uvnsq.
I've tried to build such functionality myself using multiple NsqConsumer
objects. But I'm still not sure how to properly close nsqd connections. Is it just by deleting NsqConsumer
instance? Do I need somehow to "de-register" such consumer from event loop?
Sorry for these questions, I'm not an expert in llibuv
...
from uvnsq.
@wlgq2 thank you very much for implementing this feature!
Couple of more questions:
- what if I need to close only a particular nsqd connection? This is a valid case where consumer polling nsqdlookup and watch for new and stale connections (which it needs to add and and remove). So may be it worth to add
removeNsqd
method? - "only delete NsqConsumer object in the loop thread" - you mean where loop is running, right?
- is appending nsqd thread safe?
from uvnsq.
- not support close a particular nsqd connection. uvnsq will auto reconnect a nsqd when this nsqd disconnected.
- i mean,delete NsqConsumer must called in libuv‘s event loop。because libuv is not thread safe. you can use uv::EvnetLoop::runInThisLoop to register a callback run in libuv’s loop。all uvnsq callback run in libuv‘s loop(this means called from uv::EventLoop::run function)。
- i recommend appending nsqd before loop->run();
from uvnsq.
Thanks for the answers. The challenge for 1 and 3 is that nsqd producer can come and go.
For example I want to run consumer and read from topic_1
.
- I call
nsqlookupd
and ask what arensqd
which havetopic_1
. Suppose these nsqd arensqd_1
andnsqd_2
. - Then I connect to
nsqd_1
andnsqd_2
and start handle messages - Time to time I poll
nsqlookupd
to check what are thensqd
which havetopic_1
. And for example at some point of timensqlookupd
says that there is newnsqd_3
which also hastopic_1
. Then I need to appendnsqd_3
and add it to the event loop. - It is very good that
NsqConsumer
will try to reconnect tonsqd
automatically. But there is possibility that somensqd
can completely finish, so it makes sense to remove such connections from consumer. So it would be nice to have a method to removensqd
by host and port:void removeNsqd(string host, uint16_t port)
from uvnsq.
this will make the code complicated,if support for dynamically adding and deleting nsq nodes.
from uvnsq.
yeah, I know, but this is the whole purpose of the nsqlookupd
within NSQ architecture. And this is the most popular pattern of NSQ usage...
from uvnsq.
I've been playing with the latest uvnsq
and it seems there several parts which are necessary for dynamic nsqd:
- in
NsqConsumer
each connection to nsqd shoud have some id (for example stringhost:port
) - Need somehow to track from which connection message came from in order to call
fin
method to the right nsqd.
from uvnsq.
fin auto called in NsqConsumer now .
i will consider whether to support dynamic connect for nsqd, if I have time.
from uvnsq.
@dselivanov
i think the correct design is,one NsqConsumer- one nsqd service. you can use multiple consumers connect multiple nsqds. delete and new consumer for dynamic nsqd.
If you want to deal with multiple nsqd of the same topic,you can set the same callback function for multiple customers while have same topic.
from uvnsq.
Thanks, this makes sense. So such design is more similar to what was in previous version (one connection per nsqConsumer and explicit fin
)
from uvnsq.
i update this
from uvnsq.
Related Issues (4)
- Timestamp decoding HOT 1
- Error when compiling with uv-cpp 1.4.5 HOT 2
- hostname resolution HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from uvnsq.