This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-08-21
Channels
- # bangalore-clj (11)
- # beginners (82)
- # boot (1)
- # braveandtrue (29)
- # cider (16)
- # cljdoc (2)
- # cljs-dev (2)
- # clojure (74)
- # clojure-dev (3)
- # clojure-italy (2)
- # clojure-mke (1)
- # clojure-nl (4)
- # clojure-sg (1)
- # clojure-spec (1)
- # clojure-uk (53)
- # clojure-ukraine (1)
- # clojurescript (33)
- # cursive (29)
- # datomic (59)
- # editors (4)
- # emacs (14)
- # fulcro (2)
- # graphql (12)
- # hoplon (2)
- # nyc (4)
- # onyx (5)
- # parinfer (10)
- # pedestal (22)
- # re-frame (11)
- # reagent (35)
- # ring-swagger (5)
- # shadow-cljs (150)
- # tools-deps (9)
- # vim (1)
- # yada (20)
@ikitommi you can use response-for
with async interceptors. Refer to https://github.com/pedestal/pedestal/blob/270a9e49e556b0f2af0bb58ec7a422873c3d065c/service/test/io/pedestal/http_test.clj#L306-L326
ah that’s my fault. You can find release notes here: https://github.com/pedestal/pedestal/releases/tag/0.5.4
@ddeaguiar thanks. But I’m poiking with the interceptor chain directly.
(require '[io.pedestal.interceptor.chain :as pc])
(require '[io.pedestal.interceptor :as pi])
(require '[clojure.core.async :as a])
(-> {:kikka "kukka"}
(pc/enqueue [(pi/interceptor {:enter identity})])
(pc/execute))
;=> {:kikka "kukka"}
(-> {:kikka "kukka"}
(pc/enqueue [(pi/interceptor {:enter (fn [ctx] (a/go ctx))})])
(pc/execute))
;=> nil
It works if I add a custom interceptor as first into the queue and write the value into a promise which i deref outside of the chain, but looking for a better way.
IC, I recall having a workaround for testing requests satisfied by async interceptors before response-for handled them but it eludes me atm. I’ll try and remember
@ikitommi here’s what I did in the past. I tend to avoid with-redefs
but I found this useful. I’m sure there are better ways, though.
I think that could be interesting outside of tests too, as the interceptor chain can be run as standalone too.
One solution would be to add a second arity to execute with a second argument which is a callback called when all done.
(let [on-complete (promise)]
(-> {:kikka "kukka"}
(pc/enqueue [(pi/interceptor {:enter (fn [ctx] (a/go ctx))})])
(pc/execute on-complete)
(deref on-complete 1000 ::timeout))