Fork me on GitHub
#beginners
<
2017-01-14
>
dhruv105:01:23

a question regarding using stuart sierra's component library effectively: I am creating an application which will make many rest calls to a different application (App-B) . I have to pass the URL of App-B in a config file. currently, everytime I make a request, I have to access the config file and get the URL for App-B. I am already using the component library and was wondering if i can leverage it here. Here is what I am thinking of doing: Idea1: Create an App-B record which takes accepts a URL as it's arguments and implements the Lifecycle protocol with a start and stop method. The start method will simply attach the URL to the component. (assoc this :url app-b-url) The stop method will dissoc the URL from the component. When I am making the rest call, I will pass the instance of App-B around. --- For this, I feel like using the components is a bit heavy. All I really need is the URL and so I can just use atoms. Idea2: Create a My-App record which also accept's App-B's URL. At system start up (My-App's start time) add the URL to a pre-defined atom. I can deref the atom whenever I'm making a rest call. So the question is, which "Idea" is better? Or is there an eevn simplier solution?

dominicm11:01:35

> Create an App-B record which takes accepts a URL as it's arguments and implements the Lifecycle protocol with a start and stop method. If you pass the url to your new function, no need to do anything in the start

donaldball13:01:21

You might consider writing a protocol with fns for each of the rest calls you make, then having your component implement it.

sveri14:01:34

I will be streaming some clojure, beginner questions welcome: https://www.liveedu.tv/sveri/