This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-09-03
Channels
- # admin-announcements (1)
- # beginners (4)
- # boot (1)
- # chestnut (2)
- # clara (1)
- # cljs-dev (8)
- # cljsjs (50)
- # clojure (40)
- # clojure-austin (3)
- # clojure-brasil (3)
- # clojure-canada (1)
- # clojure-gamedev (2)
- # clojure-italy (3)
- # clojure-russia (19)
- # clojure-spec (14)
- # clojure-uk (1)
- # clojurescript (60)
- # core-async (4)
- # cursive (4)
- # datomic (3)
- # editors-rus (2)
- # emacs (4)
- # events (1)
- # figwheel (2)
- # flambo (4)
- # hoplon (94)
- # jobs (4)
- # leiningen (3)
- # om (9)
- # onyx (64)
- # re-frame (86)
- # reagent (52)
- # spacemacs (4)
- # test-check (1)
- # yada (31)
Am I absolutely going nuts or is it possible that whenever I start Edge it fires a sound? like, a "bloop"???
Yeah it... definitely does. right after "Writing target dir(s)...
So this is going to sound crazy but hear me out. Rome wasn’t built in a day and I’ve got 3 yr old Python Flask web server where 80% of the functionality must lie for the time being. While I’m planning for the long term, my immediate goal is to optimize for lots of concurrent users for just a few endpoints where Python is never going to cut it. Yada seems like the perfect fit for short and long term goals. However I’m left with a challenge, I can’t have the browser talking to two web servers. So my thought is to treat yada as a proxy for any routes that bidi does not match to the python server with aleph.http
and returning the response exactly to the client. I see two ways of doing this by creating a handler for bidi’s 404 or the ‘/‘ root url to do either:
1) Use yada handler where all methods are specified
(resource
{:methods
{:get (fn [ctx] (get "”))
;; all other methods }})
- this will only work if swagger does no validation and not having an actual url doesn’t mess up yada. I could also think of putting this handler at the root url.
2) Do my own ring/response handler at ‘/‘ or 404
- I’m most certain that yada parses the routes would this blow it up? Also a more general question along those lines is, can you exclude endpoints from swagger docs and/or validation?
Sorry this is a bit long and weird, hopefully you see where I’m coming from. Any advise will be appreciated! I’ll be attempting to put this together tomorrow so we’ll see how it goes 😃Actually you couldn’t do it on ‘/‘ because you wouldn’t match. It has to be 404
@eslachance: that's a task to let you know recompilation succeeded. It's the speak
task, feel free to remove it if you hate it.
You can also make the sounds cooler. Checkout boot speak -h
@kingoftheknoll: yada makes a REALLY good proxy. If you use the aleph http client, you can do all the requests async, and yada will return the exact response they return. It's like voodoo. You'd want to do it in the 404 url style, yep 😃
I'm pretty sure you can exclude from swagger somehow, and skip the yada validation by using things like {s/Any s/Any}
in validation positions.
There might be another way that involves extending protocols, but I wouldn't be sure of the implementation. It would be similar to yada's resource and file implementations which you can find in the source.
dominicm : got any proxy example laying around?
I might have to test one of a my app for proxy capabilities, so having a yada proxy server to test everything would be perfect 🙂
@kingoftheknoll: read up on path-info? in the Resources chapter. If you set path info to true, bidi will match on a partial path like /
, so /foo
will be matched and the request will contain a path-info value of foo
.
This way you can process all URIs with a single handler. There's also a way to match on all methods. I think it's :*
but would need to check
But I would caution that if you aren't making use of yada's core featureset you may be better off making your an Aleph handler - see aleph's own docs - yada is just a factory for building such thingd
btw @malcolmsparks your blog post should be the readme for edge repo. It really should. 😛
@frozenlock: https://github.com/juxt/yada/blob/master/talks/clojutre-2015.org#or-any-other-deferred-value
Doc bug. Add a :produces entry. That 406 is the clue
What should i put there? Most examples in the docs say produces ‘text/plain’ or something. Here I’m returning a deferred
Put all the types you are able to return.
Yes, you can return a deferred value from yada, but you need to know the content types of that value for the content negotiation phase to complete. If this is dynamically determined, use a sub-resource
@kingoftheknoll: do you know the content type of the content you are serving?
I'm not 100% sure the role of a proxy in content negotiation.
This is an interesting use-case
@malcolmsparks that worked! I’ll use the sub-resource stuff when I do the full setup. Just testing if I can pass the response back through bun ran into one problem.
So it looks like the Async example given won’t work automatically because the body of a response provided by Aleph.http is a java.io.ByteArrayInputStream
. Request is made but
15:52:57.137 [aleph-netty-server-event-pool-20-3] ERROR aleph.http.core - error sending body of type aleph.http.core.NettyResponse
java.lang.IllegalArgumentException: Don't know how to convert class aleph.http.core.NettyResponse into (stream-of io.netty.buffer.ByteBuf)
Sorry for the delay and such helping the wife clean the house 😃
@kingoftheknoll: can you please share the code that causes this ?
you're returning the entire response with all its metadata, rather than the response body.
@lmergen that makes perfect sense. I’ll give it a test here in a min. Thanks!