Fork me on GitHub
#pedestal
<
2017-12-14
>
fmind13:12:15

Hi, I was wondering about the state of pedestal

fmind13:12:44

the architecture is really nice, and there is many libraries available to enrich pedestal already

fmind13:12:21

but as I checked on http://pedestal.io, the documentation is really poor compared to the quality of framework

fmind13:12:21

moreover, it's difficult to assess the momentum of pedestal. Ring seems more popular, but companies seems to prefer pedestal

luskwater13:12:41

I know there’s ongoing work in the docs; how much, I don’t know (other than contributing a few small fixes/clarifications)

fmind13:12:26

I plan to create a small template for my web project. I started with Ring, but the architecture of pedestal seems more compelling to me

fmind13:12:39

and if it works, I'll try to contribute to the documention

fmind13:12:03

but it really bothers me. Pedestal seems to be a nice framework, but the ecosystem is lacking (template, documentation, guides ...)

luskwater13:12:58

Yes: topics, but not links to anything. Granted

oconn14:12:14

Hey all. I’ve been fighting with route matching for a bit and I’m sure I’m missing something pretty simple. I have the following two routes;

["/v1/org/self"    :get (conj common (xpa-org/get-organizations-self))]
["/v1/org/:org-id" :get (conj common (xpa-org/get-organization)) :constraints {:org-id uuid-constraint}]
When I make a request to /v1/org/self it always appears to only want to match the second route (`/v1/org/:org-id`). I believe I could turn /v1/org/self into /v1/org/self/orgs and it would work, but I’m trying to figure out if the above is possible without changing the structure of my routes. The expanded routes do include both.

ikitommi15:12:31

@oconn wildcards always override others, by design, but not with linear-router. Agree that it's not right.

oconn15:12:33

Ok cool, thanks for the insight

ikitommi15:12:13

I think it woudn't with either /v1/orgs/self/orgs either. Wildcards are REALLY greedy.

donaldball15:12:45

There is the :constraints metadata

oconn15:12:51

yeah I think I’m going to go with /v1/orgs/self/orgs but it would be nice to weight them somehow

oconn15:12:15

Yeah so above I am using constraints but it returns a 404

oconn15:12:29

after failing the constraint on :org-id

donaldball15:12:45

What’re your constraints?

oconn15:12:56

:constraints {:org-id uuid-constraint}

oconn15:12:00

which is…

donaldball15:12:01

oh, hah, sorry, too early 😛

oconn15:12:53

#"[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}"

donaldball15:12:39

FWIW that’s not specified as metadata, no idea if it will actually work in that form

oconn15:12:00

I believe the constraint is being applied. When I remove it and make a request to /v1/org/self the request is routed through the /org/:org-id handler. Then when I add it I end up receiving a 404

ikitommi15:12:44

If there is a wild route, it masks all static routes.

luskwater15:12:56

@donaldball I think that is a legitimate “constraint clause” as mentioned in the docs somewhere (just read it): http://pedestal.io/reference/routing-quick-reference#_table_syntax

ikitommi15:12:17

even If the static path has more segments.

luskwater15:12:46

It would mask the static routes unless you use {:io.pedestal.http/router :linear-search} I think

luskwater15:12:14

and the non-wild route precedes the wild one

donaldball15:12:17

Ha ha wow. I guess you could put the switch in your route handler for the “self” case

donaldball15:12:26

if you added it to your regex

shaun-mahood16:12:57

Is anyone aware of any existing projects to get pedestal interceptors into ring?

mpenet17:12:37

We use the interceptor lib with a custom jetty adapter here

mpenet17:12:08

We dont use specific interceptor "instances" from pedestal tho

shaun-mahood17:12:04

@mpenet: Are you using it with a bunch of existing ring middleware, or is everything custom interceptors?

ikitommi18:12:33

how would interceptors work with ring? I think middleware is the equivalent to interceptor, but fundamentally different. But it's relatively easy to write code that could be used as either one.

ikitommi18:12:04

I think Pedestal = Interceptors.

fmind18:12:01

Pedestal is data oriented. Fundamentally, interceptors are hash map with an :enter and :leave keys that point to functions. It's up to pedestal to combine and execute these interceptors. One nice thing is thar pedestal works with core.async. And if tomorrow, we find a better way that core async, we could replace the execution engine without changing interceptor descriptions.

fmind18:12:15

On ring, middleware are simple functions. They take the next handler as a parameter, and execute it when they want. They can perform task before our after the next function execution.

shaun-mahood18:12:27

@ikitommi: The main issue I have with ring middleware is how understandable/visible it is - every time I have tried to set add new middleware to a ring project I end up spending a bunch of time moving things around so that things are applied in the right order, or enabling/disabling middleware until things work. It's difficult to know what is actually happening without diving into the code, and I've found it painful to figure out where and how I want to log things related to them.

fmind18:12:35

But by doing so, you cannot control the execution. Ring start the first handler through a simple functions call. You can't plug something like core.async easily

shaun-mahood18:12:02

I want to be able to inspect the stack of earlier interceptors to see how my data has changed, and see what is still remaining to be run.

ikitommi18:12:12

i agree, but If you take Interceptors instead If mw, is it Ring anymore? (your original question)

ikitommi18:12:42

I'm using both, depending on a project.

ikitommi18:12:58

and writing libs that support both styles.

ikitommi18:12:52

and you can inspect & reorder mw-chains too, but only before the chain is created. Once it's chained, it's just a fn.

fmind19:12:46

I started to learn Pedestal and I'm a bit confuse about some Clojure librairies

fmind19:12:19

I want to develop an API oriented web stack, and I think Pedestal is a good start for that purpose

fmind19:12:58

but then, there is many librairies like liberator, vase and lacinia. I don't know which one to integrate, and I can't find pros and cons on the internet

fmind19:12:34

is vase compatible with lacinia ? is there a way to switch to another DB than datomic ?

fmind19:12:58

and on the client side, what is the quickest way to integrate with Clojurescript ? om.next ? fulcro ?

fmind19:12:25

do you know some templates that combine these tools ?

mtnygard19:12:06

@fmind I sympathize. There are a plethora of options and not a lot of "stacks" that offer pre-integrated components.

mtnygard19:12:43

I'm one of the maintainers of Vase & Pedestal, so I have a personal preference toward those. Vase is quite tied to Datomic in its current state, though.

fmind19:12:58

yes ... the Clojure community takes modularity to hearth, but it's not the most productive option for quick development

fmind19:12:32

and there is a lot of back-up from experienced programmers who met the problem these technologies try to address

luskwater19:12:16

Nothing prevents you from - creating your own data-readers so you can have #fmind/jdbc action literals (or the like) - adding an interceptor that hangs a pooled Connection on the context and takes it back on the way out - don’t know about quickest way: I was hoping to use Vase, but find that my client’s standard server framework (Java) is heavy and burdensome, but perhaps must be used

fmind20:12:03

I like the design of vase, but I'm afraid that the dependence to REST and Datomic will bite me on the long term

mtnygard20:12:41

@fmind I understand. What are your technology constraints? (E.g., are you restricted to certain DB?)

fmind20:12:26

I work in a research environment and I have few tech constraints. I'm quite found of Datomic, but we can't pay the price for Datomic pro

ordnungswidrig20:12:55

Liberator maintainer here, just keep in mind that liberator (and anything that runs on the ring model) works perfectly fine with pedestal. You’ll lose some of the async / non-blocking properties of pedestal, though.

mtnygard20:12:37

I've been working on an evolution of Vase that makes it easier to add new actions that go beyond Datomic. That's at https://github.com/mtnygard/vase/tree/fern-input

mtnygard20:12:45

Not released yet, but in a usable state.

fmind20:12:56

@mtnygard @ordnungswidrig thanks for your feedbacks

fmind20:12:27

I want to start small with a small web app that provides both REST and GraphQL end points.

fmind20:12:14

my plan was to start with Pedestal + Lacinia and see which of vase liberator would be the best fit

ordnungswidrig20:12:29

@mtnygard vase-fern looks very promising. I will dig into that very likely.

ordnungswidrig20:12:47

@fmind I’m thinking for a while now how to bring the niceness of liberator to the pedestal world but I’ve yet to hit a sweet spot. Maybe I’ll have a bright moment over the holidays 😛

mtnygard20:12:03

@ordnungswidrig If you want to chat about it, hit me up. I like what Liberator brings!

fmind20:12:43

The good thing with Clojure is that it's easy to test stuff. I will try to use both lib and see what is the best fit

fmind20:12:12

Would you have any recommandation for the client side with Clojure script ?