babashka / pods

Pods support for JVM and babashka

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support running pod over socket

borkdude opened this issue · comments

Users will invoke the pod with:

(load-pod "foo" {:tcp true}) ;; bb decides on the port
(load-pod "foo" {:tcp true :port 16667}) ;; port forced by the user

Babashka can pass an environment variable BABASHKA_POD_PORT=16667 and then the pod will open that port. From then on babashka communicates with the pod via that port instead of stdin/stdout.

The above isn't that nice, since the user needs to know / sees implementation details.

Alternative: pod is first started in the normal way. Babashka gets back a describe message with tcp true and then starts the pod again using sockets instead of stdin/stout. This might affect startup time since we need to start the pod twice.

Alternative: or maybe there's another way: if we execute the pod only once and write some describe message to a fixed location, we can always re-use that, if it's already there. Like pod-foo --describe . But then we would need to know if the pod supported such a thing.

Currently implemented:

For pods running over sockets, the user specifies (load-pod ... {:socket true}). The pod will write a file .babashka-pod-<pid>.port with the port number on which its server runs followed by a newline (to indicate that the port number is complete and not still being written). The pod is responsible for cleaning up this file (it can do so after the pod client connects).

TODO:

  • write tests
  • Instead of {:socket true} maybe it would be nicer to make it {:transport :socket}. We could also add {:transport :http} if we wanted to talk to a server that implemented a pod :).
  • docs