This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
- # adventofcode (2)
- # announcements (3)
- # babashka-sci-dev (79)
- # beginners (76)
- # biff (2)
- # calva (32)
- # cider (2)
- # clj-kondo (42)
- # clj-on-windows (17)
- # clojure (28)
- # clojure-belgium (1)
- # clojure-berlin (1)
- # clojure-europe (95)
- # clojure-nl (4)
- # clojure-norway (4)
- # clojure-uk (5)
- # clojurescript (27)
- # conjure (5)
- # cursive (3)
- # data-science (16)
- # datomic (67)
- # graalvm (12)
- # hyperfiddle (36)
- # jobs (3)
- # jobs-discuss (1)
- # kaocha (2)
- # klipse (1)
- # leiningen (28)
- # lsp (16)
- # luminus (3)
- # malli (10)
- # nrepl (3)
- # off-topic (57)
- # other-languages (18)
- # re-frame (4)
- # reitit (8)
- # releases (1)
- # remote-jobs (1)
- # scittle (4)
- # shadow-cljs (7)
- # test-check (1)
- # tools-deps (4)
- # vim (11)
- # xtdb (25)
taking a return value from here: https://github.com/babashka/pods/blob/66867eee7f050af0126c83c876f8031e0eae709a/src/babashka/pods/impl.clj#L231
and encoding it and sending it back to the pod. with an
id. and maybe into the pod with a new bencode command like
it would be up to the pod to get it to where it needs to go, with a promise or something.
would we make a new id and send with the invoke (this is your retval id, use it to deliver the return value)? Or could we use the existing invoke id?
What are your feelings on this kind of addition @U04V15CAJ? Assuming it could be done, is it something you would consider merging?
Can you describe the problem to me in terms of examples / requirements instead of proposed code changes?
It would be awesome to make it possible for your callback to return a value, and that value could be sent to the pod, and used there
it's a while ago since I looked at it so maybe you can explain the idea to me in more general terms 😅
I have this bbssh pod underway. And in the pod I need to make a UserInfo class instance. And this is used by JSch to do things like, get the users password. Or ask for a passphrase for a key decryption. or some other things.
so when JSch calls a method on this class, like
getPassword, I could fire an async callback in the bb code... maybe it would return a string. Or maybe it would prompt at the terminal. Or maybe it would open a window with a text prompt. The end user could determine that
Its not a complete blocker, but if it were possible it would lead to a really elegant bbssh api
To recap for myself: In the case of the async watch function, what happens: The client calls watch, which is implemented as a client side function that calls the low level async pod api, which allows you to register a callback that gets called on 1 or more async replies (or an error handler). Those replies get sent back to the client. This is basically the same as a synchronous function call: client asks, pod sends back.
as it's not there I have to hard code the behavior here into the pod. This is the old spire UserInfo part: https://github.com/epiccastle/spire/blob/master/src/clj/spire/ssh.clj#L48-L60
that gets called one or more async replies (or an error handler). Those replies get sent back to the client as arguments on a :success, or a :error callback
and then... the return value of those callbacks is then send back to the pod along with the id
(this could be configurable somehow... or only if its not nil. Details could be worked out)
why - the pod sent those values to the client, why do you want to send them from the client to the pod?
because the client has now used those values to go and do something and return an answer that the pod needs
it ends up here https://github.com/babashka/pods/blob/66867eee7f050af0126c83c876f8031e0eae709a/src/babashka/pods/impl.clj#L93 but
https://github.com/babashka/pods#async The arguments to babashka.pods/invoke are: a pod identifier string derived from the first described namespace.
https://github.com/babashka/pods/blob/master/src/babashka/pods/impl.clj#L448 be just here. If this returns nil it raises an exception
in particular I had to call the client->pod "return the result" call inside a future to prevent a deadlock in bb. For the brave and true who follow along in the future: https://github.com/epiccastle/bbssh/blob/0958baa17c42cb0b22f73852dcbd05a5639015dc/src/bb/pod/epiccastle/bbssh/user_info.clj#L27
it's quite amazing to see. so this code: https://github.com/epiccastle/bbssh/blob/0958baa17c42cb0b22f73852dcbd05a5639015dc/test/bb.clj#L34-L61
and they will be called in your bb code as they are called over in the pod, and your return values will be returned