This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-11-13
Channels
- # announcements (2)
- # babashka (30)
- # beginners (44)
- # biff (20)
- # calva (15)
- # cider (7)
- # clerk (4)
- # clojure (15)
- # clojure-austin (1)
- # clojure-europe (35)
- # clojure-hungary (1)
- # clojure-nl (1)
- # clojure-norway (6)
- # clojure-uk (7)
- # clojurescript (33)
- # conjure (1)
- # cryogen (1)
- # cursive (3)
- # data-science (8)
- # docker (2)
- # emacs (78)
- # gratitude (2)
- # hyperfiddle (26)
- # improve-getting-started (1)
- # jobs-discuss (12)
- # lsp (7)
- # malli (11)
- # missionary (57)
- # off-topic (14)
- # pathom (13)
- # portal (6)
- # reagent (6)
- # releases (3)
- # ring (25)
- # shadow-cljs (18)
- # squint (11)
- # vim (3)
Hello, I'm looking to integrate the new websockets protocols into an adapter that we maintain, and I have several questions: • Why are -send and -send-async separate methods? Couldn't they be a single multi-arity method? In case an adapter does not support it, you can always throw a "not implemented" exception. • Why is there -send-async and not -ping-async and -pong-async? In our case we have the possibility of knowing the termination of those options and in fact we use it but with ring protocols, we lose that option. Thanks :D
-send
and -send-async
are separate methods so they can be in separate protocols. This allows you to check using satisfies?
whether or not a socket supports async behaviour, without relying on catching an exception.
There is not a -ping-async
and -pong-async
because this wasn't supported by the Jakarta Servlet websocket implementation. So we can't assume that if an underlying websocket library supports async messages, that it also supports async ping/pong. However, I could add a new AsyncPingPongSocket
protocol to support it.
other question, do you have plans to continue working on ring-2.0? I mean, we are already using ring-2.0 based protocols for some time now...
Ring 2.0 proved to be too much at once, but a lot of the ideas of Ring 2.0 are still sound. The approach I'm taking now is to implement the functionality of Ring 2.0 in a more piecemeal fashion.
So for example websockets will come in Ring 1.11.
When you say "Ring 2.0 protocols", do you mean the protocols for request/response maps?
That could be a good next step for Ring 1.12 or 1.13.
FYI, we are using our internal adapter using undertow, that is right now ring2.0 based, but I'm working right now on integrate the new websocket ring protocol (instead to have our own) and we have a plan to parametrice the adapter to work with ring1 or ring2 based requests/responses
for now the approach for ring2, I have copied/impoted the ring.request and ring.response from ring 2.0 branch to our repo
One of the difficulties I ran into with Ring2 was the need to support both Ring1 and Ring2 request/response maps. That is, not necessarily the protocols, but the different keys (like :status
vs :ring.request/status
). In retrospect, I'm unsure if this was a good idea.
Indeed, It is a breaking change, of course, But from my point of view is a good fresh view, and allows develop more efficient adapters, that perform less operations if final user does not uses some stuff from request...
Well, the idea was that it wouldn't be a breaking change.
And therein was the difficulty.
From my own experience, developing the adaprter thatwe are already using in production for some time, making an adapter that works in both modes is not difficult task
Yes, it was more the infrastructure around it that I found to be difficult.
Right
but in this case, I think it is not bad approach on the library developers and builitin middlewares is to detect which kind of request or response is coming
I don't think I'll attempt tackling the new keys immediately, at least not in 1.12 or 1.13. However, I don't believe there would be a problem with adding protocols for potentially faster access of request/response data. The adapter would still need to return something that Clojure recognizes as a map for compatibility, but using the protocols could be faster than using keyword lookup.