Fork me on GitHub
#pedestal
<
2017-03-22
>
bradford00:03:20

Hi! How do I configure jetty's maxidleconnections in a service? Right now I'm doing:

(def service {:env :prod
              ;; You can bring your own non-default interceptors. Make
              ;; sure you include routing and set it up right for
              ;; dev-mode. If you do, many other keys for configuring
              ;; default interceptors will be ignored.
              ;; :http/interceptors []
              ::http/routes routes
              ;; Root for resource interceptor that is available by default.
              ::http/resource-path "/public"
              ;; Either :jetty or :tomcat (see comments in project.clj
              ;; to enable Tomcat)
              ::http/type :jetty
              ::http/port 8080})

manutter5102:03:48

Interesting, I tried lein clean plus deleting io.pedestal and org.clojure from my .m2 directory, and now I’m getting No matching ctor found for class io.pedestal.interceptor.helpers$on_request$fn__8950, which I’m not using anywhere in my project.

manutter5102:03:01

I think my next attempt is going to be lein new plus incrementally copy over source files from my previous attempt.

mtnygard02:03:53

@manutter51 Are you using any additional libraries that might have been built against an older version of Pedestal? Try adding :pedantic? :abort to your project.clj to see if that's an issue.

deg08:03:18

I'm trying to write some Vase routes, but I can't find a full manual or reference. (I've been copying from the examples, and mostly understand what's going on, but not completely). I've looked at info about Vase, Datamic, and Datalog, and keep finding more pieces, but I can't find a doc that gives me the full picture; especially not from a Vase perspective. Where should I look? Ideally, I'd like a doc where I can find answers to questions like: - How do I create a :get route that takes optional parameters? With this, how could I write a query that will find a user if I ask either api/user?name=joe or api/user?id=42? - What exactly is :in $ ... - When is it needed to give an entity an explicit id property? I would imagine this is seldom needed, yet it seems to be supplied in each of the Vase samples, so I'm missing some fact here. - Etc.?

manutter5110:03:28

@mtnygard Ok, I added :pedantic? :abort, but same results. Here’s my dependencies, as given by lein deps :tree

manutter5110:03:07

Hmm, Slack is saying the snippet was truncated, but it’s all there. As far as I can tell there are no pedestal dependencies except the ones I get via pedestal-service and pedestal-jetty.

manutter5110:03:03

Anyway, just for a sanity check, I did a lein new pedestal-service pedestal-test, and that runs just fine. So I guess I’ll just copy over stuff until the new project also breaks.

ddeaguiar13:03:36

@bradford I don’t have an answer for you but I’d recommend posting it to the pedestal-users group as well.

mtnygard13:03:01

@bradford Here's the answer I got from Paul deGrandis: There is an option within :container-options called :configurator it's a function that takes and returns the Jetty Server argument it's the ultimate escape hatch to do whatever you want to the server *as the very last step in setting up the server* https://github.com/pedestal/pedestal/blob/master/jetty/src/io/pedestal/http/jetty.clj#L196 If it's not passed in, Pedestal sets the function to identity

ddeaguiar13:03:08

@deg, thanks for the document suggestions. I was just wondering, though, were you able to find answers to those questions?

deg13:03:12

@ddeaguiar. Today's questions? No, not really. I did find some docs, mostly on the Datomic site, and now at least understand the syntax of the :in clause. But. my other questions still have me stumped, and are more at the Vase level.

ddeaguiar13:03:48

Ok, re: parameters, have you seen the Handling Parameters section in the Your First API doc? (https://github.com/cognitect-labs/vase/blob/master/docs/your_first_api.md#handling-parameters)

deg14:03:42

Yup, I have read that. Am I missing something? It looks to me like all the parameters are reduced to positional and mandatory by the time they get to the query.

ddeaguiar14:03:42

re: explicit entity ids, I suspect this has to do with Datomic best practices (http://docs.datomic.com/best-practices.html#unique-ids-for-external-keys)

deg14:03:58

Re ids, that's what I figured, finally. So, best practice would be not to specify an explicit id unless I need it for some external purpose?

deg14:03:16

This makes complete sense, but is not the first impression that I got from the Vase samples.

ddeaguiar14:03:04

So setting aside Vase for the moment, If you solely rely on the internal :db/id as an external identifier, it makes data migration more difficult

ddeaguiar14:03:33

I need to think about what this means in terms of a Vase-enabled app, but IMHO it’s really not a Datomic-specific issue either. It’s a good recommendation for any backend store that generates identifiers

ddeaguiar14:03:11

datomic has a notion of entity ids and :db/id is just one variant

deg14:03:50

I'll need to think about that, in the context of my current toy application. But, assuming that I do want an external id on my entities, does Vase (or Datomic?) give an easy way to generate unique ids atomically?

ddeaguiar14:03:35

you can generate unique ids that are Datomic index-friendly using (datomic.api/squuid) (http://docs.datomic.com/clojure/index.html#datomic.api/squuid)

deg14:03:34

Yup, I've seen that Datomic section, but have not fully grokked it yet. So, how would I use squuid in the context of a #vase/transact?

deg14:03:22

I think my questions really keep boiling down to "I'm trying to understand how to do things right, but I'm only learning from samples, rather than formal docs that don't yet exist"

ddeaguiar14:03:14

so to assign your own unique id, you’d need to pass it as part of your entity data in vase transact but

ddeaguiar14:03:58

I think Vase will append a :db/id if it’s not present as well

ddeaguiar14:03:12

So you’d need to include both on transact

ddeaguiar14:03:29

but I’d only query by the entity domain identifier

ddeaguiar14:03:36

I need to go back and dig into Vase more deeply. My understanding of the internals is fuzzy so I’ll stop there before I inadvertently lead you astray.

deg14:03:08

Yes, Vase does seem to append the :db/id. But the samples, e.g. https://github.com/cognitect-labs/vase/blob/master/samples/pet-store/resources/petstore-simple.edn, do also have a domain-specific identifier in the schema, but seem to assume that it somehow magically comes from the client, even on creation.

ddeaguiar14:03:47

sure, it needs to come from the client

ddeaguiar14:03:17

you can add an interceptor that appends it

ddeaguiar14:03:48

I don’t think there’s a way to specify an attribute that get’s associated a value automatically upon transaction

ddeaguiar14:03:20

my instinct tells me that, if anything, that’s would be done by an interceptor sitting in front of the transact action

ddeaguiar14:03:33

At least that’s how I’d do it if I were building a Pedestal app

deg14:03:18

For the client to do it, would require some kind of guid, not just e.g. a simple counter maintained on the server. (But, as I write this, I'm thinking that I'm being naive, and not addressing scalability. So, maybe I'm just blowing smoke here).

deg14:03:57

In any event, this seems like a good paragraph to add somewhere into the docs.

ddeaguiar14:03:33

Again, thanks for the great feedback. I realize that the docs are failing you atm. We’re looking to fix that

deg14:03:47

Any thoughts on my other question (how could I write a query that will find a user if I ask either api/user?name=joe or api/user?id=42)?

deg14:03:35

Thanks. I'm happy to keep helping with the docs, but my knowledge is still limited. I've made a few small PRs, but am afraid to document too much when I'm just guessing.

ddeaguiar14:03:50

Regarding your query question, I don’t know off hand but I’d guess it’s doable using an or query predicate. I’d have to try it

ddeaguiar14:03:33

To clarify, include both params in the :params collection, and use an or in the :query

ddeaguiar14:03:49

But I’ve not tried it!

deg14:03:06

[I have to run... back in a bit, one fast reply] I did try or, but failed to get it to work; with an obscure error message.

ddeaguiar14:03:39

hmm, I’m going to try that later today. I’m curious