does wrap-reload need to enforce a 1-arg function? #1

Closed
wants to merge 1 commit into
from

3 participants

@trptcolin

So this isn't strictly a ring fix, but aleph is pretty similar, and the only thing keeping one from using ring.middleware.reload with aleph is the arity of the function returned by wrap-reload (aleph sends 2, ring gives 1). This patch makes it work fine for both ring and aleph.

Maybe this is just enforcing the 1-arg ring API, but it'd be nice to be able to use this with aleph.

p.s. Loving all the Ring blogs! Keep 'em coming!

@weavejester
Collaborator

Middleware for Aleph would have different argument types and a different return than middleware in Ring. Additionally, middleware in Aleph always has side-effects, whilst Ring middleware is usually functional.

In a dynamic language like Clojure, it's possible to have the same function have two different type signatures, but it's often not a very good idea. Additionally, if wrap-reload is converted to work with Aleph, what about other Ring middleware that is harder to convert? Do we try and make all middleware work with both systems, or do we make exceptions, and thus wind up with an inconsistent API?

Further, the situations you need to delay a HTTP response are rather limited. Typically it means you're dealing with Websockets or some asynchronous protocol that sits on top of HTTP (like Comet). In both cases you're dealing with a protocol that doesn't have a huge amount in common with HTTP. There isn't a lot of middleware that works with both systems, so there's not a huge incentive to merge the concepts of asynchronous middleware, and normal Ring middleware. Especially as there are things you can do with Ring middleware that you can't do with Aleph middleware, and vice versa.

@mmcgrana
Owner

Hi Collin,

Thanks for the patch, but I'm going to hold off on applying this until we figure out a general solution to the async-in-Ring question. I know that just this little weak would solve your case, but I'd like to come up with a robust solution that works for e.g. all conforming middleware.

By the way, I really enjoyed your series of posts about the time you spent at Relevance. I hope that I can do something like that some time.

  • Mark
@mmcgrana
Owner

Wow, apparently James was responding at the exact same time I was. I think we are on the same page though.

@trptcolin

Thanks for the feedback, James & Mark! I thought it might be a bit of a can of worms to try and get this working with Aleph (which I'm really just looking into for the first time), so I can totally appreciate the desire to keep Ring pure.

Sounds like the best direction for this type of thing for the time being is to write Aleph-specific versions of middlewares I miss from Ring.

I really appreciate all you guys' Clojure OSS work - I'd love to buy you a beer at ClojureConj :)

Thanks,

Colin

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment