Fork me on GitHub
#duct
<
2018-03-26
>
rickmoynihan10:03:35

@weavejester I don’t see how the above separates module and configuration keys? Do you mean that’s done via refsets? Or via derive from :duct/module?

rickmoynihan11:03:29

Hmm… Another question… It seems that nothing in duct or integrant will load-namespaces for parents defined in duct_hierarchy.edn. Is this intended?

rickmoynihan11:03:46

i.e. it looks like children get loaded automatically, but not parents.

weavejester14:03:38

@rickmoynihan Currently modules, special keys like :duct.core/include, and normal configuration keys are in the same map.

weavejester15:03:10

The plan is to change that, so there is a “module config” consisting of only modules.

weavejester15:03:24

The module configuration produces a map of transformation functions, which are placed in dependency order and then reduced over an empty map.

weavejester15:03:53

Some of the modules will be profiles, and profiles just merge their value into the map.

weavejester15:03:25

So instead of something like:

{:duct.core/include ["foo"]
 :duct.module/bar {}
 :duct.core/project-ns baz}

weavejester15:03:30

You’d instead have:

{:duct.profile/foo #duct/include "foo"
 :duct.module/bar {}
 :duct.profile/base {:duct.core/project-ns baz}}

weavejester15:03:06

In the former case we have a special key, a module key, and a normal key.

weavejester15:03:21

In the latter case, all keys are modules.

rickmoynihan15:03:47

Ok, I think I see where you’re going.

weavejester15:03:18

Regarding duct_hierarchy.edn, the hierarchy file just defines the keyword hierarchy. It’s useful because it’s a lot quicker to search the classpath for duct_hierarchy.edn and read that in, than it is to compile every Clojure file on the classpath.

rickmoynihan15:03:10

yeah I can see that

weavejester15:03:37

The load-namespaces function works separately to that. It iterates through the keys in the configuration and loads them. I seem to recall that there was a patch recently to Integrant that ensured that the parents of the keys in the configuration were loaded.

rickmoynihan15:03:10

ok, that patch sounds like what I’m after

weavejester15:03:57

That was included in Integrant 0.6.3

rickmoynihan15:03:47

ahh ok my app seems to be including 0.6.2

rickmoynihan15:03:16

I suspect a dependency somewhere needs bumped, as I created this app from the lein template yesterday

weavejester15:03:55

Probably. I’ve been working on the alpha version, so the stable version may have gotten a little behind.

rickmoynihan15:03:28

cool no biggie… will try updating in my app to 0.6.3

rickmoynihan15:03:18

Yeah that issue appears to be precisely what I was trying to describe. Thanks a million.

weavejester15:03:51

No problem! I’ll try to get around to updating the template deps today

rickmoynihan15:03:55

Ok can confirm 0.6.3 fixes the issue I was having 🙂

beta103620:03:33

is there any special reason why server.http.aleph doesn't support async handlers?

weavejester20:03:15

@beta1036 Like Ring async handlers? Or Aleph handlers? The key is just a small wrapper around Aleph, so it should support everything Aleph does

beta103620:03:42

i meant ring handlers which get three arguments.

weavejester20:03:01

Does Aleph support those by default?

beta103620:03:03

to be clearer, i would like to use ring middleware functions.

beta103620:03:28

with the jetty server you would specify async? true, i think.

beta103620:03:01

but the aleph server doesn't seem to support that.

weavejester20:03:18

As far as I know, Aleph doesn’t support the three-argument arity. You need a wrapper.

beta103620:03:19

although it seems like it would be an easy thing to do.

beta103621:03:17

wouldn't it make sense for server.http.aleph to call the 3 arg handler with the callbacks completing a deferred when async? is true?

beta103621:03:49

or is there a better way to do something like that?

weavejester21:03:02

Aleph isn’t my project, and server.http.aleph is just a thin wrapper around the server.

weavejester21:03:58

If you want to use Aleph with Ring async middleware, that requires a wrapper that changes manifold’s deferreds into callbacks.

beta103621:03:46

wouldn't it make sense to do this wrapping in server.http.aleph?

beta103621:03:22

i thought that would be symmetrical to how the jetty server does it.

weavejester21:03:56

That’s not something that’s related to Duct. All the server.http.aleph library does is provide the thinnest possible wrapper around Aleph. Adding more, creating something on top of Aleph, is best saved for another project.

beta103621:03:53

i see. so if i want to switch from async ring with jetty to aleph, i just write my own wrapper instead of using server.http.aleph, right?

weavejester21:03:00

None of it’s complected, so ideally you just write some middleware that converts between callbacks and deferreds.

weavejester21:03:18

Then use server.http.aleph.

weavejester21:03:27

It’s essentially entirely orthogonal to Duct. You just need a middleware that converts to and from Aleph’s API.

beta103621:03:19

sure. i was just wondering about the scope of server.http.aleph. thanks for the clarification!

beta103621:03:48

is there a way to make different routes use different middleware?

beta103621:03:29

for example to be able to use both sync and async routes while using ring middleware.

weavejester21:03:45

@beta1036 Yes, you can apply them to Compojure routes directly, or via Ataraxy’s metadata hints if you’re doing that. Essentially however you add middleware per route normally.

beta103622:03:46

would i then set the :middleware for :duct.core/handler to an empty vector? anything specified there would be applied before the router, right?

weavejester22:03:31

Yes, though I don’t see why you would.

weavejester22:03:20

If I was doing it, I’d use the three argument form for all the middleware.

weavejester22:03:48

You can go from async to sync easily enough. It’s going the other way that’s problematic.

beta103622:03:57

that's right. i see that it's not difficult, i'm just looking for the most elegant way of doing it.

beta103622:03:10

thanks for the education. 🙂