cljka.channel

close!

(close! channel)

Closes the specified channel; emptying it first.

closed?

(closed? ch)

Returns a boolean indicating whether the specified channel is closed.

poll!

(poll! channel)

Polls the specified channel

sink-chan

multimethod

Wraps the given sink target in a channel to sink messages to.

The first argument is the sink target. Target types supported out of the box are:

  • clojure.lang.Atom - the dereferenced value should be a collection
  • java.io.Writer
  • java.io.File
  • java.lang.String - should indicate an absolute file path.

The second argument is an option map for that sink target.

Options supported by all sink targets:

key default description
:pred any? A predicate to use to filter the incoming messages by.
:n nil A limit to the number of messages that will be written to the sink before it closes.

java.io.Writer based targets (i.e. java.io.Writer, File, String) also support the same additional options as for io/writer plus:

key default description
:serializer pprint function taking an object and java.io.Writer that will be used to serialize the object to the Writer.

to!

(to! in-channel sink-target & [{:keys [close-sink?], :or {close-sink? true}, :as opts}])

Starts piping data from the specified input channel to the specified sink target. For more control over the sink channel itself, wrap the sink target use to-chan! instead.

Support options:

key default description
:close-sink? true Whether to close the sink destination once the input channel closes.

Any other specified options are passed as arguments to sink-chan when creating the sink channel. See the documentation for sink-chan for more details.

to-chan!

(to-chan! in-channel sink-channel & [{:keys [close-sink?], :or {close-sink? true}}])

Starts piping data from the specified input channel to the specified sink channel.

key default description
:close-sink? true Whether to close the sink channel once the input channel closes.