I'm trying to implement this tutorial: http://www.lucagrulla.com/posts/server-sent-events-with-ring-and-compojure/
In one part, I need to extend a core.async type with the following protocol: https://github.com/ring-clojure/ring/blob/master/ring-core/src/ring/core/protocols.clj#L19.
So, I've tried to implement something like this:
src/async_test/protocol_ext.clj
But this fails with interface ring.core.protocols.StreamableResponseBody is not a protocol.
Then, I tried to monkey-patch ring: opened a new file with the correct path, and added the following lines on the bottom of the protocol declaration, inside `extend-protocol` call:
src/ring/core/protocols.clj
Then, it worked. What's happening? Is Clojure ignoring that StreamableResponseBody is a protocol if there's already an `extend-protocol` call?
Ubuntu 16.04 x86_64, OpenJDK 8
Comment made by: mauricio.szabo
Okay, my bad. Seems that I need to `:require` the protocol, not `:import` it. Sorry about that...
The issue here is that you are importing StreamableResponseBody as a Java class (really an interface). While the protocol does generate a Java interface, you should use the protocol, not the interface, when you extend. This is confusing because they both have the same name.
So, your ns declaration should instead be:
The monkeypatch you tried worked because you were properly referring to the protocol in that case.