One thing you could consider is constructing the individual pieces of your 
system as system-maps that you can merge together. (A pattern from " 
<https://medium.com/@hlship/tips-and-tricks-for-component-d00832abcdfa>Tips 
and Tricks for Component" 
<https://medium.com/@hlship/tips-and-tricks-for-component-d00832abcdfa>.)

So you might have a constructor to create a system of your many individual 
feed components (defn feeds [config] (component/system-map ...)) and 
another component that aggregates those feeds. 

Your top level would be something like

(let [config [{:feed :foo :uri "..."} 
              {:feed :bar :uri "..."}]]
  (merge
    (feeds config)
    (aggregator config)
    (component/system-map
      (comment "... the rest of your system ..."))))


It is essentially the same as what you're suggesting except that the 
start/stop calls still happen automatically, and should you have need to 
depend on a specific one of the feed components or for a 
feed component to depend on another part of the system down the line, it's 
an easy addition.  

On the other hand, this is probably not the way to go if you want custom 
handling logic for situations where some feeds are able to start and others 
are not, or some feeds error out mid connection, etc.
If that's the case, such handling logic would probably be easier to 
implement as part of the start/stop of your Feeds component, since it will 
have the discretion to start a subset of the feeds it's connected
to, or stop a subset during runtime.

Best,
Matt

On Monday, September 16, 2019 at 3:26:03 PM UTC-5, Don Jackson wrote:
>
> Hello,
>
> I'm writing an app/system that subscribes to a number of feeds, the number 
> and configuration of the feeds is a configurable run-time thing.
> Seems like I should have a Feed component, which is passed its config when 
> instantiated.
> But having a named slot in the system for each feed would be painful and 
> kinda defeats the point of having a variable number of feeds that get 
> configured.
>
> How best to deal with this in Component?
>
> One thought I had was to create a Feeds (note plural, trailing s) 
> component.
> The Feeds component would be instantiated with a collection of feed 
> configs, and would have a single slot to hold the collection of 
> instantiated feeds.
> This Feeds component would instantiate a Feed component for each feed, and 
> could start/stop them in its own start/stop methods.
>
> I appreciate/understand that my individual Feed components would not be 
> participating in the System dependency injection, but AFAICT they don't 
> need to.
>
> The above seems like it would work fine, but also seems like it is not 
> idiomatic Component.
>
> I would welcome any thoughts/advice as to how best to structure this with 
> Component.
>
> Thanks
>
> Don
>
>
>
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/clojure/32bd2257-3817-4cc6-8b5a-4adef3dccb29%40googlegroups.com.

Reply via email to