pedestal

hmadelaine 2019-04-16T12:08:30.013700Z

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

donaldball 2019-04-16T15:45:13.016100Z

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.

manandearth 2019-04-16T16:30:56.017600Z

How would you add params for testing a route with response-for? or a different way to test request maps?

2019-04-16T16:33:29.018300Z

@adamgefen http://pedestal.io/reference/unit-testing should clarify this. If not, let me know so I can update it.

manandearth 2019-04-16T16:34:58.018800Z

perfect! @ddeaguiar, I overlooked it.

2019-04-16T16:35:05.019Z

np!

2019-04-16T18:36:11.019200Z

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.

2019-04-16T18:36:29.019500Z

Let me explain

2019-04-16T18:37:13.019700Z

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

2019-04-16T18:38:02.019900Z

Start/stop entry points are pretty clear. Pedestal’s extension point is also very clear - the interceptor.

2019-04-16T18:38:27.020100Z

All you need to do is create interceptors that make the dependency you are interested available in the context/request

2019-04-16T18:38:31.020300Z

You don’t need component for that

2019-04-16T18:39:27.020500Z

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

2019-04-16T18:40:19.020700Z

I don’t feel it adds much value.

manandearth 2019-04-16T18:50:30.021100Z

....and how would you inject a session for testing session authentication :session {:identity {:username foo}}?

2019-04-16T18:53:13.021800Z

@adamgefen how is authentication wired into your service now?

manandearth 2019-04-16T18:54:39.022800Z

buddy session

2019-04-16T18:56:10.023400Z

basically you want to use a stub auth store, right?

manandearth 2019-04-16T18:56:32.023600Z

yes

2019-04-16T18:59:14.024700Z

What is your auth store? A db? How is that wired in?

2019-04-16T18:59:40.025Z

because you can stub that on service initialization

manandearth 2019-04-16T19:01:55.026700Z

it is a table in a postgresql, the project is component with a pedestal component and a postgres component (juxt.modular)

2019-04-16T19:02:25.027400Z

So the db is assoc’d to context by an interceptor?

2019-04-16T19:02:43.027900Z

use a fake store in your system to return what you want

manandearth 2019-04-16T19:03:31.028700Z

Yes you are right. I don't need to test the db connection.

2019-04-16T19:04:38.029400Z

in regards to injecting session, need to think on that part

2019-04-16T19:04:59.029800Z

ideally you wouldn’t have to first ‘log in’ then run tests

2019-04-16T19:05:21.030300Z

better to have system set up in ‘logged in state’, I think anyway

manandearth 2019-04-16T19:06:03.031Z

I see.

2019-04-16T19:06:14.031300Z

maybe I’m making it too complicated

2019-04-16T19:06:41.032100Z

Perhaps can pass in cookie with identity info, exercise stub auth and test what you want

2019-04-16T19:06:47.032300Z

it’s just a header

manandearth 2019-04-16T19:07:24.033100Z

Yes . I just need a way that it can be passed as a header.

2019-04-16T19:08:36.034Z

headers can be passed via response-for

manandearth 2019-04-16T19:08:59.034500Z

But it can't be just the session map, can it?

2019-04-16T19:09:50.034700Z

hmm, don’t recall

2019-04-16T19:09:55.034900Z

try 🙂

manandearth 2019-04-16T19:10:12.035200Z

thanks! 😄

hmadelaine 2019-04-16T20:07:47.037600Z

@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 :-)