I would suggest using something like https://github.com/stuartsierra/component to control system configuration. This ensures that you can easily start and stop your system in REPL. Using this library, you must configure it so that each processing step is a component, and each component handles installation and channel breaks in its start and stop protocols. In addition, you could create an IStream protocol for each component to be implemented, and each component depends on the components that implement this protocol. He buys you very light modularity.
As a result, you get a system that looks like this:
(component/system-map :scheduler (schedule/new-scheduler file/tmp-dir) :searcher (component/using (search/searcher) {:in :scheduler}) :processor (component/using (process/resultprocessor) {:in :searcher}) :buyer (component/using (buy/buyer) {:in :processor}) :report (component/using (report/reporter) {:in :buyer}))
One good thing with this approach is that you can easily add components if they also rely on the channel. For example, if each component creates its own output channel using tap in the internal mult , you can add a logger for the processor only with a logging component that treats the processor as a dependency.
:processor (component/using (process/resultprocessor) {:in :searcher}) :processor-logger (component/using (log/logger) {:in processor})
I would recommend watching it to find out how it works.
Alvin francis dumalus
source share