Skip to content
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

fix bad assertion #6

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions src/com/keminglabs/zmq_async/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,9 @@ Sends messages to complementary `zmq-looper` via provided `zmq-control-sock` (as
;;Relay a message from ZeroMQ socket to core.async channel.
[:control [sock-id msg]]
(let [out (get-in pairings [sock-id :out])]
(assert out)
;;We have a contract with library consumers that they cannot give us channels that can block, so this >!! won't tie up the async looper.
(>!! out msg)
(when out
;;We have a contract with library consumers that they cannot give us channels that can block, so this >!! won't tie up the async looper.
(>!! out msg))
(recur pairings))

;;The control channel has been closed, close all ZMQ sockets and channels.
Expand Down Expand Up @@ -275,8 +275,13 @@ Accepts a map with the following keys:
(when (and socket (or socket-type configurator))
(throw (IllegalArgumentException. "You can provide a ZeroMQ socket OR a socket-type and configurator, not both.")))

(when (and (nil? out) (nil? in))
(throw (IllegalArgumentException. "You must provide at least one of :out and :in channels.")))
(cond
(#{:pair :req :rep :xreq :xrep :dealer :router :xpub :xsub} socket-type)
(assert (and in out) (str socket-type "socket requires both :in and :out channels"))
(#{:pub :push} socket-type)
(assert in (str socket-type "socket requires an :in channel"))
(#{:sub :pull} socket-type)
(assert out (str socket-type "socket requires an :out channel")))

(let [context (or context (doto automagic-context
(initialize!)))
Expand Down