Connecting Components with Channels

Components may need to be connected to pass an ongoing series of values, feeding them from a producer component to a consumer component. The core.async channels are ideal for this purpose. When a component needs channels for incoming or outgoing values, the component can either accept external channels or create them internally and make them available.

For example, consider a component that receives a stream of incoming social media messages. One option would be to have the component accept the incoming channel as part of its configuration:

 
(​defn​ make-feed-processor
 
"Create a new Feed Processor on the given input channel."
 
[input-channel] ,,,)

Alternatively, the feed-processor can construct the channel ...

Get Clojure Applied now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.