Hi everyone ! I am planning to use Pedestal and Component to start en new micro-service. I have done some research on the idiomatic way to bootstrap Pedestal with Component using the reloaded.repl flow. I found those libraries so far : https://github.com/ddeaguiar/component-pedestal https://github.com/grzm/component.pedestal But did not find any clear answer. Did I missed some articles ? Thank you very much
I’m not sure I’m answering your question exactly, but I use component and pedestal and have been happiest using a :router
component that builds its pedestal :routes
dynamically, closing over any other stateful components; and a :jetty
component that’s responsible for the jetty http/s service.
How would you add params for testing a route with response-for
? or a different way to test request maps?
@adamgefen http://pedestal.io/reference/unit-testing should clarify this. If not, let me know so I can update it.
perfect! @ddeaguiar, I overlooked it.
np!
Hi @hmadelaine, glad to see that you’ll be using Pedestal. I authored ddeaguiar/component-pedestal and co-authored pointslope elements (https://github.com/pointslope/elements). I’ve not formally released the former and the later has not been updated in a while. As I’ve worked through various iterations of applications based on component and pedestal, I’ve become less inclined to mix the two.
Let me explain
Pedestal already provides a service representation that is extensible - the service map. You can assoc whatever you like to it and use that info during service initialization
Start/stop entry points are pretty clear. Pedestal’s extension point is also very clear - the interceptor.
All you need to do is create interceptors that make the dependency you are interested available in the context/request
You don’t need component for that
I found that all the machinery I built around this for component basically involved how to create such interceptors and where should such code exist in a project
I don’t feel it adds much value.
....and how would you inject a session for testing session authentication :session {:identity {:username foo}}
?
@adamgefen how is authentication wired into your service now?
buddy session
basically you want to use a stub auth store, right?
yes
What is your auth store? A db? How is that wired in?
because you can stub that on service initialization
it is a table in a postgresql, the project is component with a pedestal component and a postgres component (juxt.modular)
So the db is assoc’d to context by an interceptor?
use a fake store in your system to return what you want
Yes you are right. I don't need to test the db connection.
in regards to injecting session, need to think on that part
ideally you wouldn’t have to first ‘log in’ then run tests
better to have system set up in ‘logged in state’, I think anyway
I see.
maybe I’m making it too complicated
Perhaps can pass in cookie with identity info, exercise stub auth and test what you want
it’s just a header
Yes . I just need a way that it can be passed as a header.
headers can be passed via response-for
But it can't be just the session map, can it?
hmm, don’t recall
try 🙂
thanks! 😄
@ddeaguiar thank you very much for your answer. I am not a pedestal expert so I stick to the tools I am comfortable with. I will dig deeper to understand the true philosophy of pedestal :-)