This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-01-19
Channels
- # beginners (34)
- # boot (111)
- # cider (37)
- # clara (57)
- # cljsjs (1)
- # cljsrn (22)
- # clojure (156)
- # clojure-austin (2)
- # clojure-mke (7)
- # clojure-russia (9)
- # clojure-spec (221)
- # clojure-uk (47)
- # clojurescript (42)
- # code-reviews (4)
- # community-development (9)
- # core-async (3)
- # cursive (50)
- # datomic (81)
- # emacs (12)
- # events (5)
- # hoplon (1)
- # jobs (2)
- # lein-figwheel (4)
- # leiningen (1)
- # luminus (3)
- # mount (2)
- # off-topic (1)
- # om (94)
- # om-next (3)
- # onyx (33)
- # re-frame (23)
- # reagent (41)
- # remote-jobs (9)
- # rum (30)
- # slack-help (2)
- # specter (1)
- # untangled (20)
- # yada (17)
@dominicm Right you are, thanks. Looks like yada 1.2.0 does not play nice with datomic 0.9.5544; yada needs io.netty/netty-all 4.1.0.CR3
but datomic needs io.netty/netty-all 4.0.13.Final
Worked-around that by specifying [com.datomic/datomic-pro "0.9.5544" :exclusions [io.netty/netty-all]]
but then ran into another problem: adding a yada resource and handler as a Compojure route, and then trying to go that route throws,
No implementation of method: :render of protocol: #'compojure.response/Renderable found for class: yada.handler.Handler
The code for the yada handler looks like,
(def test-resource
(yada/resource
{:produces {:media-type "text/plain"}
:methods {:get
{:response (fn [ctx] (str "You did a GET with ctx: " ctx))}}}))
(def the-ring-handler-2 (yada/handler test-resource))
(ccore/defroutes yada-routes
(ccore/GET ["/yada-test"]
[:as req]
the-ring-handler-2))
limist: you are returning the handler from a request, not using it to process the request itself.
I guess that compojure normally calls functions if you return them.
(the-ring-handler-2 req)
should work instead.
You could extend this protocol to understand the record yada.yada/Handler: https://github.com/weavejester/compojure/blob/master/src/compojure/response.clj
@dominicm Thanks for the diagnosis and suggestion; I changed it to (the-ring-handler-2 req)
as you wrote, and now see a different error message when going to that URI:
[{:type java.lang.RuntimeException
:message java.lang.Exception: Not supported: java.nio.HeapByteBuffer[pos=0 lim=6873 cap=6873]
:at [com.cognitect.transit.impl.WriterFactory$1 write WriterFactory.java 120]}
{:type java.lang.Exception
:message Not supported: java.nio.HeapByteBuffer[pos=0 lim=6873 cap=6873]
:at [com.cognitect.transit.impl.AbstractEmitter marshalTop AbstractEmitter.java 240]}]
Quite mystifying, these messages...I didn't think the transit format is involved at all in such a simple handler.limist: Does it work if you use it as the only handler? Outside of compojure I mean.
@dominicm In figuring out how to do what you suggested, I realized the problem is likely because I'm using http-kit as the webserver in my current system, not Aleph. It's not possible to just drop-in a yada handler into one's no-Aleph stack, right?
@dominicm After stripping out all middleware, it kind of works. 🙂 That is, visiting the one defined uri doesn't cause any exception, but the expected return string/mesg from the test-resource
(as seen in https://clojurians.slack.com/archives/yada/p1484791558000836 ) doesn't appear either.
It makes sense that middleware would break it, aleph returns bodies differently to how normal ring middleware would consume it.
@dominicm Visiting other URIs gives 404, where the footer mentions "Powered by Jetty://" A bit confusing, I thought netty was behind the scenes. Overall, it's looking non-trivial to add yada to an existing project; it would probably be safer/easier to take the "framework" of Juxt edge, and then move older code into it. (On that note, I probably won't do that; instead, am waiting for Arachne to mature a bit more)
I think that you might still be running a jetty server for ring, and that is causing an issue with deferred responses from yada.
I don't think Arachne has really been discussed around yada, I believe Arachne is quite tightly coupled about how it wants to build things in it's own way
Yes, you're right; looking at the deps tree, i'm still using ring 1.3.2 and it's using jetty-server
Ah, then maybe for existing systems (won't call them legacy yet...), yada is best "integrated" as a microservice, running in its own process.