Re: Actually using component.

2015-06-10 Thread Dru Sellers
I really am dense at times. :( I was confusing the 'component' for the system map in this line: https://github.com/weavejester/duct/blob/master/duct/src/duct/component/endpoint.clj#L6 #PalmToFace -d On Tuesday, June 9, 2015 at 5:57:48 PM UTC-5, James Reeves wrote: On 9 June 2015 at 23:16,

Re: Actually using component.

2015-06-09 Thread Jeroen van Dijk
I think the most important rule when using component is to only use local state like Timothy stated, i.e. nothings gets def-ed. You could write an application that a -main function that starts the system and you would never need a global reference to the system. In practise however, you do make

Re: Actually using component.

2015-06-09 Thread Atamert Ölçgen
On Tue, Jun 9, 2015 at 6:12 AM, Timothy Baldridge tbaldri...@gmail.com wrote: Stuart addresses two anti-patterns in your PRs. Perhaps I can help explain them. Let's say we have a system that looks like this: (defrecord DBConnection []) (defrecord DBLayer [db-connection]) (defrecord

Re: Actually using component.

2015-06-09 Thread James Reeves
On 9 June 2015 at 23:16, Dru Sellers d...@drusellers.com wrote: @James do you only have one component that has all of your routes? or do you have each component supply its own routes? If you imagine a component providing its own routes, I'd love to see a duct example with two routes set up.

Re: Actually using component.

2015-06-09 Thread Dru Sellers
@James do you only have one component that has all of your routes? or do you have each component supply its own routes? If you imagine a component providing its own routes, I'd love to see a duct example with two routes set up. I believe that would be multiple endpoint components. Looking at

Re: Actually using component.

2015-06-08 Thread J Irving
Hey Dru Take a look at Duct: https://github.com/weavejester/duct If you make a new app using that template, you should get some pointers from the boilerplate it generates. cheers, Jonathan On Mon, Jun 8, 2015 at 5:51 PM, Dru Sellers d...@drusellers.com wrote: So, I guess I am a bit lost, how

Actually using component.

2015-06-08 Thread Dru Sellers
So, I guess I am a bit lost, how does someone actually use component? I have an application all set up with it and it seems to be working as I would expect but Stuart seems to be steering me in a different direction. https://github.com/stuartsierra/component/pull/35

Re: Actually using component.

2015-06-08 Thread James Reeves
My recommendation is to use a closure. So I'd write your example as: (defn username-endpoint [{:keys [db]}] (routes (GET /:username [username] (let [user (users/get-user db username)] (str h1Hello (:name user) /h1) So you pass your configuration map into the endpoint

Re: Actually using component.

2015-06-08 Thread Timothy Baldridge
Stuart addresses two anti-patterns in your PRs. Perhaps I can help explain them. Let's say we have a system that looks like this: (defrecord DBConnection []) (defrecord DBLayer [db-connection]) (defrecord AppLayer [db-layer]) We can construct a system thusly: {:db-connection (-DBConnection