Skip to content

Commit

Permalink
fix: Fix interceptors to use writer
Browse files Browse the repository at this point in the history
  • Loading branch information
liquidz committed Jan 22, 2024
1 parent 1615a1e commit eff06cd
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/elin/interceptor/connect.clj
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
(ns elin.interceptor.connect
(:require
[clojure.core.async :as async]
[elin.function.host :as e.f.host]
[elin.protocol.rpc :as e.p.rpc]
[elin.util.file :as e.u.file]))

(def port-auto-detecting-interceptor
{:name ::port-auto-detecting-interceptor
:enter (fn [{:as ctx :keys [cwd host port]}]
:enter (fn [{:as ctx :keys [elin host port]}]
(if (and host port)
ctx
(let [nrepl-port-file (e.u.file/find-file-in-parent-directories cwd ".nrepl-port")
(let [{:keys [writer]} elin
cwd (e.f.host/get-current-working-directory writer)
nrepl-port-file (e.u.file/find-file-in-parent-directories cwd ".nrepl-port")
host' (or host "localhost")
port' (some-> nrepl-port-file
(slurp)
Expand All @@ -18,13 +21,14 @@

(def output-channel-interceptor
{:name ::output-channel-interceptor
:leave (fn [{:as ctx :keys [message client]}]
:leave (fn [{:as ctx :keys [elin client]}]
(when client
(async/go-loop []
(let [ch (get-in client [:connection :output-channel])
(let [{:keys [writer]} elin
ch (get-in client [:connection :output-channel])
{:keys [text]} (async/<! ch)]
(when text
;; TODO FIXME
(e.p.rpc/echo-message message (str "OUTPUT: " text) "ErrorMsg")
(e.p.rpc/echo-message writer (str "OUTPUT: " text) "ErrorMsg")
(recur)))))
ctx)})

0 comments on commit eff06cd

Please sign in to comment.