vardius / message-bus Goto Github PK
View Code? Open in Web Editor NEWGo simple async message bus
Home Page: http://rafallorenz.com/message-bus
License: MIT License
Go simple async message bus
Home Page: http://rafallorenz.com/message-bus
License: MIT License
The "message-bus" import is eliminated when ran from play.golang.org, as it doesn't match the package name as used by the code. It needs to be aliases, as in https://play.golang.org/p/U5nstd936qf
can't use Unsubscribe(Astruct.Foo), this can be supported?
How does this library compare with the usage of systems like Kafka and RabbitMQ as message transporters?
Particularly in terms of performance and security.
Edit: just took a look at the code, it seems like this library doesn't do what I thought.
So is it accurate to say that it's a sync RWMutex wrapper utility?
How can one use it to establish connection between microservices, if at all possible?
I like the new interface. Really, I used the semaphore to control concurrency outside the bus.
And, I hope to keeps both the old interface and the new interface.
v1.0.0
Line 82 in c1f01b6
v1.1.0
Line 93 in bdb2394
Your code is great, but I don't know how to use it. Is there a real application scenario?
I merged it #6 but have to think about it if this is an improvement or not, it increases allocations number
plus if the number of subscribers is high it actually slows down
before
BenchmarkPublish-4 5214352 226 ns/op 0 B/op 0 allocs/op
BenchmarkSubscribe-4 632084 3319 ns/op 730 B/op 5 allocs/op
Benchmark1Subscriber1Topic-4 5545311 225 ns/op 0 B/op 0 allocs/op
Benchmark1Subscriber100Topics-4 2261838 808 ns/op 0 B/op 0 allocs/op
Benchmark100Subscribers1Topic-4 61615 19539 ns/op 0 B/op 0 allocs/op
Benchmark100Subscribers100Topics-4 60561 34031 ns/op 0 B/op 0 allocs/op
after
BenchmarkPublish-4 598759 1981 ns/op 2 B/op 0 allocs/op
BenchmarkSubscribe-4 1000000 4218 ns/op 725 B/op 4 allocs/op
Benchmark1Subscriber1Topic-4 629875 1899 ns/op 13 B/op 0 allocs/op
Benchmark1Subscriber100Topics-4 621306 1935 ns/op 0 B/op 0 allocs/op
Benchmark100Subscribers1Topic-4 6942 206815 ns/op 3343 B/op 8 allocs/op
Benchmark100Subscribers100Topics-4 6996 320923 ns/op 8107 B/op 16 allocs/op
Originally posted by @vardius in #6 (comment)
Did not release new version yet, will think about it and either revert or release
would love to hear second opinion about it.
go func() {
for args := range h.queue {
- h.callback.Call(args)
+ go func(targs []reflect.Value) {
+ h.callback.Call(targs)
+ }(args)
}
}()
Personally I think it is up to a developer of a handler to execute his callback in a goroutine or not, up to him and the package itself should not enforce goroutine here.
cc @me020523
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.