-
Notifications
You must be signed in to change notification settings - Fork 164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merge in Channels from vaughan0/go-zmq? #26
Comments
Looks pretty useful! Does it not need thread locking, though? Otherwise between channel activities the routines may switch threads. ZeroMQ sockets are not thread safe. |
That is an interesting point @driskell. That seems like an oversight by both the original author and myself. |
Since the sockets never cross a Goroutine boundary (except after initial creation), I think it just needs each of those routines locking to an OS thread. Then it's probably good :) I think even if this wasn't to be maintained and included - it could still be merged as an "example" pattern? |
Yeah, it could be an example pattern. It just needs to be reworked to have Channels take the Socket as an arg vs being the receiver. I'll see if I have time today to try that. |
I am not an expert on design patters, so I have to rely on the judgement of contributers.Therefore I think the best place for design patterns is in the wiki: https://github.com/pebbe/zmq4/wiki/DesignPatterns I will add a link in the documentation to the wiki |
I created a PR to add a channel interface in #177 . |
First off let me thank you for both writing, and maintaining this library.
I recently switched to it from github.com/vaughan0/go-zmq, mostly because there were some issues with that library I could not quite explain (like my inability to set a hwm despite doing everything I could think of including writing the cgo calls on every socket created for testing.)
The one thing I really miss is the abstraction given using Socket.Channels(). What I am doing, done the standard zmq way, would have me reading from a Router tcp socket, and sending work to a Dealer inproc, and having goroutines reading from that inproc, and then having the main process using a poller to read from the Dealer and write back out on the Router (I forget the name of this pattern at the moment.)
But the Channels abstraction is really nice. It creates a Pair in a single goroutine and uses go channels to communicate between the In and Out. Because so much of my code already relied on this paradigm, I spent some time and ported the channels.go file (https://github.com/vaughan0/go-zmq/blob/master/channels.go) to work with your library (mostly name changes for constants, and some type changes to match what you have done.)
I am wondering if you have any interest in adding this to zmq4? I could submit a pull request but wanted to make sure it was even something you would consider before going through with it.
Thanks again.
The text was updated successfully, but these errors were encountered: