Comments (17)
Just curious, what's the use case of having that? I have never used Emitter2... Just for debugging?
from axon.
It's so you can trigger events on more broad or narrow event descriptions. Eg:
sock.on('basketball.nba.bulls', function(data){
// do this only for the bulls events
});
sock.on('basketball.nba.*', function(data){
// do this for all nba events
});
sock.on('basketball.ncaa.*', function(data){
// do this for all ncaa events
});
sock.on('basketball.*.*', function(data){
// do this for all basketball events
});
sock.on('*.*.*', function(data){
// log everything ...
});
from axon.
Gotcha, I will let @visionmedia decide on that. I could see some use cases where it could be beneficial (e.g a monitor system that emits alert types that you could pattern match on the other end, etc). Though I would opt for wrapping up a long over due release with all the new stuff we have in master first. The original project that pushed me to help on this project in the first place is coming back up, so I will finally have the time to head that up again...
from axon.
need to think on this haha, not against it. The one thing I don't like about their pattern matching is that *
in my mind at least should match anything vs having to know the event segments. Maybe as a compromise we could support *
only which would just punt the event name as an argument that you could match on. That's not as attractive though... hmm
from axon.
Yeah totally. I bring it up because it looks like hook.io is EOL and it gave you this. Not to turn axon into hook.io but it may be able to address some of the use cases. Not sure what the performance penalty of using EventEmitter2 is. perhaps having the choice of emitter
or emitter2
may be worth considering.
from axon.
@visionmedia FWIW I agree regarding *
and the event segment. May be a lot of work to do differently though.
from axon.
arguably that sort of thing could be part of the object(s) passed as well, sock.on('basketball', function(data){ data.league })
etc
from axon.
Just to clarify, I would argue that the emitter socket should remain as is, and follow the same feel as the node-core emitter. I would only see this being part of pub/sub through topics:
sock.subscribe('foo*'); // maybe even regexp
sock.on('message', function(msg){});
from axon.
EmitterSocket is definitely a higher level one, we could possibly just produce regexps for the .on() calls filter on "message", but then we lose the possibility of doing selective reception later on unless we do translate those to .subscribe()s
from axon.
this would help for having some stable relay nodes that would relay everything, I'm a little torn since in general you can just use multiple sockets for multiple "topics" but I can see how that would become less true with some scenarios. I'll try out some simple str -> regexp conversions and see what the impact is like and / or EE2. I'm not sure I'm sold on how EE2 handles separators though
from axon.
Thanks for the update. Let me know if there is anything I can do to help. I've been digging this library.
btw - I'm liking the glob-style pattern matching that redis gives you
from axon.
at very least we could add it as some sort of thing you opt-into if there ends up being a perf penalty worth caring about
from axon.
non-scientific benchmarks:
even our multipart support drastically reduces throughput,
so the overhead of regexp-based subscriptions relative to
that one is actually pretty low. I'm sure we could improve multipart,
my guess is .concat()
is probably not great, maybe some other
things too
BEFORE:
min: 244 ops/s
mean: 145032 ops/s
median: 20852 ops/s
total: 109511 ops in 3.349s
through: 141.6328125 mb/s
min: 3031 ops/s
mean: 150450 ops/s
median: 21432 ops/s
total: 114290 ops in 2.592s
through: 146.923828125 mb/s
BEFORE (multipart):
min: 244 ops/s
mean: 80274 ops/s
median: 150689 ops/s
total: 94281 ops in 5.302s
through: 78.392578125 mb/s
AFTER (no subscriptions):
min: 322 ops/s
mean: 138694 ops/s
median: 20565 ops/s
total: 150902 ops in 4.105s
through: 135.443359375 mb/s
min: 861 ops/s
mean: 151069 ops/s
median: 21248 ops/s
total: 312569 ops in 9.340s
through: 147.5283203125 mb/s
AFTER (1 subscription):
min: 389 ops/s
mean: 70102 ops/s
median: 15393 ops/s
total: 98439 ops in 5.148s
through: 68.458984375 mb/s
AFTER (5 subscriptions):
min: 325 ops/s
mean: 67374 ops/s
median: 14977 ops/s
total: 137652 ops in 7.403s
through: 65.794921875 mb/s
from axon.
ah yup http://jsperf.com/concat-push/6
from axon.
wow.
from axon.
hmm removing that only gave me about ~10% increase, I'll profile later and see what's up
from axon.
https://github.com/visionmedia/axon/pull/new/add/emitter-wildcards
from axon.
Related Issues (20)
- Get a callback on the send method
- Allow disabling of the queue HOT 1
- push/pull where pullers pull upon demand
- Support for multiple peers needs improvement HOT 2
- Error on connect for sub socket HOT 4
- subscribers cannot send messages HOT 1
- Send command
- socket.connect blocking gulp task from completing HOT 3
- Binding to UNIX sockets results with RangeError HOT 3
- Is this maintained? HOT 2
- How would I go about tracing RPC(req-rep) calls?
- update package JSON engine values HOT 1
- How to catch this error: read ECONNRESET HOT 1
- Impossible to handle server errors like 'EADDRINUSE' without 'domain'
- Missing typing definition
- `fs.unlink()` is used as if it was synchronous when deleting a stale UNIX socket
- unix socket reconnect fails HOT 2
- tls certificates ? HOT 1
- Deprecated prototypical inheritance
- Is it still maintained ?
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 axon.