Fork me on GitHub
#pedestal
<
2017-06-27
>
mgrbyte13:06:00

how to have auto-reloading of edn-resources in dev-mode? (am experimenting w/vase) ?

ddeaguiar13:06:24

@mgrbyte perhaps Pedestal’s service-tools watch impl could help, or at least provide inspiration. https://github.com/pedestal/pedestal/blob/master/service-tools/src/io/pedestal/service_tools/dev.clj#L23

mgrbyte13:06:11

@ddeaguiar thanks. am not sure it would/does in this case. I'm wondering what the vase dev's workflow is?

ddeaguiar13:06:49

So I don’t think the workflow is that different that when you work with a traditional Pedestal service. Just reload the service namespace after making any changes to the vase edn file.

ddeaguiar13:06:25

At least as long as you are running your service in dev mode (i.e., via run-dev)

mgrbyte13:06:50

@ddeaguiar ah ok. I thought I was doing that (and have been using ns-tracker), so must be doing something stupid

ddeaguiar13:06:02

It’s been a while since I’ve worked with Vase so I’ll double check later today as well

mgrbyte14:06:03

can you clarify what action you're thinking of when you say "reload the service namespace" pls. with cider in emacs I do that by re-evaluating the form - not sure what the equiv. is in a regular repl

mgrbyte14:06:30

sorry for the silly question, have gotten a v. confused :s

mgrbyte14:06:33

@ddeaguiar In the repl I do: (run-dev) , then (require '[my-app.ns] :reload) after changing the edn resource file - would you expect that to reflect changes? (it doesn't currently in my setup)

ddeaguiar14:06:06

So I’m typically doing this in emacs and use cider-load-buffer after making changes. I don’t recall what that does under the covers

ddeaguiar14:06:32

cider-load-buffer is mapped to C-c C-k for me

mgrbyte14:06:04

I similarly run this in cider connecting (repl runing separately in the terminal). I use cider-eval-buffer will try load instead.

mgrbyte15:06:43

so I finally figure out a way. Had missed that run-dev will return the service-map and one can (server/stop service-map) and re-restart

ddeaguiar15:06:30

So I just did a quick test using the vase lein template

ddeaguiar15:06:42

you don’t even need to explicitly reload

ddeaguiar15:06:03

any changes to the vase edn file will be picked up on next request

ddeaguiar15:06:13

This is because the value of ::server/routes is a fn and evaluated on every request (https://github.com/cognitect-labs/vase/blob/master/template/src/leiningen/new/vase/server.clj#L52)

mgrbyte15:06:41

Not happening for me.

mgrbyte15:06:26

perhaps it's because I'm using the mutliple vase resource files as per the petstore-full sample?

ddeaguiar15:06:43

hmm, I wouldn’t think so. if your service map routes value is a function, it will be executed on every request. If that function loads vase resource files, then they’ll get loaded on every request

mgrbyte15:06:14

still no joy. I stop and restart the repl, and I see my changes (w/no errors). changing my edn resource file alone, no changes seen. 😕

mgrbyte15:06:54

will see if I can re-produce from a clean project/template.

mgrbyte15:06:02

so can confirm this doesn't work. I checked out vase, started the petstore-full sample with lein run-dev

mgrbyte15:06:37

then edited resources/petstore-full.categories.edn to add a new route, change isn't picked up

mgrbyte15:06:25

Used the describe-api endpoint to check that (http://localhost:8888/api)

ddeaguiar15:06:25

ok let me try that project

ddeaguiar15:06:31

@mgrbyte I didn’t run that project but I can see why it won’t work the same way

ddeaguiar15:06:10

So you’d need stop the service and call run-dev again to load the descriptors

ddeaguiar15:06:28

That’s a suboptimal dev experience but one could argue that was not the point of this sample

mgrbyte15:06:49

Yah, that's was the reasoning by my server stop/start comment ~^6

ddeaguiar15:06:51

I would be great if the samples were consistent in this case

ddeaguiar15:06:13

so my recommendation is to not do it this way in your application

ddeaguiar15:06:28

follow what’s in the lein vase template

mgrbyte15:06:31

I'm really hoping to split up at least the schema into separate files

ddeaguiar15:06:37

you can do that

ddeaguiar15:06:47

and still benefit from hot-reloading

ddeaguiar15:06:32

Just be sure to limit hot-reloading to dev because it does have a performance impact

mgrbyte15:06:42

what would be your recommended approach for that? I'm a n00b at pedestal 🙂

mgrbyte16:06:11

ok, having read the code think I've got a good idea how this will work. thanks for your help and patience @ddeaguiar 🙂

ddeaguiar17:06:28

Glad you were able to figure things out @mgrbyte. When in doubt stick to what’s done in the Pedestal/Vase lein templates. Sometimes the examples stray from that and it’s unclear why.

jjttjj21:06:24

Sorry to be asking endless vase newbie questions here. I can't tell if this is a datomic problem or a vase problem but I keep getting a back the following kind of response when I'm trying to post to create new entities {"whitelist":[{}],"transaction":[[13194139534318,50,"2017-06-27T19:46:27Z"]]}

jjttjj21:06:50

is that indicative of an issue with the schema?