Fork me on GitHub
#yada
<
2017-01-19
>
limist02:01:58

@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))

dominicm08:01:23

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.

dominicm08:01:25

You could extend this protocol to understand the record yada.yada/Handler: https://github.com/weavejester/compojure/blob/master/src/compojure/response.clj

limist17:01:53

@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.

dominicm17:01:51

limist: Does it work if you use it as the only handler? Outside of compojure I mean.

limist19:01:50

@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?

dominicm20:01:03

Correct. You need aleph

limist12:01:58

@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.

dominicm12:01:45

It makes sense that middleware would break it, aleph returns bodies differently to how normal ring middleware would consume it.

limist12:01:42

@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)

limist12:01:18

Any plans to have arachne wrappers for yada?

dominicm12:01:04

I think that you might still be running a jetty server for ring, and that is causing an issue with deferred responses from yada.

dominicm12:01:34

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

limist12:01:09

Yes, you're right; looking at the deps tree, i'm still using ring 1.3.2 and it's using jetty-server

limist12:01:18

Ah, then maybe for existing systems (won't call them legacy yet...), yada is best "integrated" as a microservice, running in its own process.

limist20:01:35

@dominicm In any case, thank you for helping me grok yada further; looks like I'll have to play with it further in a separate and new project.

dominicm20:01:27

No problem :)