portal

https://github.com/djblue/portal
borkdude 2020-10-17T10:23:35.007600Z

https://twitter.com/borkdude/status/1317407477999243264

💯 1
1
djblue 2020-10-17T17:52:18.008200Z

This is really dope, thanks for sharing!

borkdude 2020-10-17T17:56:07.008400Z

Enjoyed the video :)

❤️ 1
nate 2020-10-17T18:44:19.013700Z

Portal is very cool. I'm going to try using it when I need a data explorer. One hiccup I'm having is that it opens on a random port. I do all my development remotely and use ssh port forwards, so each time I launch portal, they need to be adjusted. I looked through the source and it doesn't look like I can specify a port. Would you be up for a PR adding port as a config option?

nate 2020-10-19T16:37:49.029500Z

@djblue PR opened. Had a couple questions too in the comments https://github.com/djblue/portal/pull/19

👀 1
djblue 2020-10-19T17:09:01.029900Z

@nate to your second question, maybe we can have a lower level api that is only available for server backed rpc implementations. Like first you (portal.launcher/start host port) , then you (portal.api/open) as many times as you like? I think it's simpler but definitely not as easy 😬

nate 2020-10-19T17:10:12.030100Z

ah, that makes a lot of sense

nate 2020-10-19T17:10:53.030300Z

so if you call (portal.api/open), you get the default behavior and if you want to specify the host/port, then you need to run (portal.launcher/start host port) first?

djblue 2020-10-19T17:11:31.030500Z

That's my thinking, would that be reasonable?

nate 2020-10-19T17:11:42.030700Z

I think so

nate 2020-10-19T17:12:23.030900Z

and would this only be necessary for the jvm and node launchers?

👍 1
djblue 2020-10-19T17:13:14.031200Z

I guess it could also be portal.api/start

djblue 2020-10-19T17:13:38.031400Z

With a description about how it's a low level thing that you only need to care about if you want control over the server

nate 2020-10-19T17:14:11.031600Z

yeah, portal.api/start sounds good

nate 2020-10-19T17:14:22.031800Z

I'll update the PR with this later

djblue 2020-10-19T17:14:33.032Z

Sounds great, thanks!

nate 2020-10-19T17:14:44.032200Z

you're welcome, thank you for the feedback

nate 2020-10-21T16:05:31.032400Z

@djblue I was working on this yesterday morning and realized that only port is unchangeable (and should be passed to the start function). host is something that can be different on each open call. Is it confusing to have :portal.colors/theme and :portal.launcher/host as options for open and only honor :portal.launcher/port in start?

nate 2020-10-21T16:06:47.032600Z

the tricky part about making start the way to override host is that it's not an attribute of the server, so I would need to store it in the atom as well so that open can use it

nate 2020-10-21T16:07:13.032800Z

I'm leaning toward host and port being just for start, because that seems less confusing, thoughts?

djblue 2020-10-21T16:16:00.033Z

@nate I agree, keeping those options for start now seems best

nate 2020-10-21T16:16:49.033200Z

cool, thank you

💯 1
nate 2020-10-23T00:10:03.033500Z

Apologies on the delay in getting this done, work rather exploded this week. I should have some time on Saturday to get the PR updated.

👌 1
nate 2020-10-25T03:06:08.034100Z

@djblue I just pushed a commit that separates out the a new start function. I'm sure of the JVM launcher code. I'm less sure of the Node launcher code as I was only able to test it by running the node sample (I couldn't connect my editor to the repl and start/stop, but I was able to stop via the actual REPL prompt). Please let me know what you think of the code and if there's anything I should change. Thank you.

djblue 2020-10-25T03:25:24.034300Z

@nate, to test different environments, I use make e2e . It looks like you might have missed fixing p/close for node. You can run make e2e/node specifically to run those tests.

djblue 2020-10-25T03:28:14.034600Z

The main issues I'm seeing is that the node process isn't terminating which probably means the server is still running.

djblue 2020-10-25T03:34:06.034800Z

diff --git a/src/portal/runtime/node/launcher.cljs b/src/portal/runtime/node/launcher.cljs
index 05f89fe..80926b9 100644
--- a/src/portal/runtime/node/launcher.cljs
+++ b/src/portal/runtime/node/launcher.cljs
@@ -47,14 +47,12 @@
 
 (defn start [options]
   (when (nil? @server)
-    (reset!
-     server
-     (a/let [{:portal.launcher/keys [port host] :or {port 0 host "localhost"}} options
-             server (create-server #'server/handler port host)]
-       server))))
+    (a/let [{:portal.launcher/keys [port host] :or {port 0 host "localhost"}} options
+            instance (create-server #'server/handler port host)]
+      (reset! server instance))))
 
 (defn- stop [handle]
-  (some-> handle :http-server (.close)))
+  (some-> handle :http-server .close))
 
 (defn open [options]
   (let [session-id (random-uuid)]

djblue 2020-10-25T03:34:46.035Z

@nate ☝️ should fix it. a/let returns a promise

nate 2020-10-25T05:23:33.035900Z

Ah! Ok. Thanks for that. I'll add that and run the e2e tests.

nate 2020-10-26T17:28:40.036100Z

@djblue I just pushed up the above code change as a commit. Looks like the jvm, bb, and node e2e tests run well. I can't get e2e/web to work.

djblue 2020-10-26T17:49:03.036300Z

You might have to enable pop-ups but it's fine, everything looks good to me locally.

djblue 2020-10-26T17:51:34.036500Z

@nate I just merged the PR, thanks! I should have a release out in the next couple of days.

nate 2020-10-26T17:53:34.036700Z

awesome, thank you for merging

nate 2020-10-26T17:53:43.036900Z

and thank you for your feedback during the process

👍 1
djblue 2020-10-17T19:04:36.013900Z

That sounds good to me. What name did you have in mind for the config key?

djblue 2020-10-17T19:04:58.014100Z

I think it should be fully qualified, but that's all I got

djblue 2020-10-17T19:06:01.014300Z

:portal.server/port ?

nate 2020-10-17T19:07:49.015500Z

Yeah, that sounds good. Or :portal.expose/port

nate 2020-10-17T19:08:10.016300Z

Or trade expose for ui

djblue 2020-10-17T19:08:45.016500Z

I think that could work. What other keys could you see under that ns?

nate 2020-10-17T19:11:15.018200Z

host in case not accessed over local host. And maybe launch-command for specifying something other than chrome.

nate 2020-10-17T19:11:25.018700Z

Those are the only that come to mind.

djblue 2020-10-17T19:12:47.018900Z

I think I might like :portal.launcher/port :portal.launcher/host and :portal.launcher/command then 👌

nate 2020-10-17T19:14:35.019300Z

Those sound great.

djblue 2020-10-17T19:15:50.019500Z

I don't think we need to implement them all right now, :portal.launcher/port alone would be an awesome add!

djblue 2020-10-17T19:17:04.019700Z

Let me know if you need any help with the code

nate 2020-10-17T19:17:20.020300Z

Cool. Thank you.

borkdude 2020-10-17T19:26:30.020600Z

I might have a similar problem with an upcoming feature for babashka pods: instead of stdin/stdout pods can choose to use a socket for communication and by default, the pod will choose a random open port (this is for pods that want to have full control over the terminal, e.g. TUI)

👌 1
borkdude 2020-10-17T19:32:39.021400Z

@nate random ports usually go in the higher area > 10000 I think? it would be highly co-incidental if that would conflict with one of your pre-configured ssh tunnel ports?

nate 2020-10-17T19:37:51.024900Z

The problem I run into isn't that portal's ports conflict with my already-forwarded ports, but that in order to access the portal port, I have to make a new port forward. When I can specify the portal port, I'll set my forwarding to include a few well chosen ports and just use one of those when opening portal.

👌 1
nate 2020-10-17T19:38:46.026200Z

Your idea about using a socket for pod communication sounds really cool. As does a lanterna pod.

borkdude 2020-10-17T19:40:12.026400Z

Ah right. So there's no need for me to make the port of the pod configurable then I guess?

borkdude 2020-10-17T19:40:53.026600Z

The lanterna pod can already run console-tetris

🎉 3
nate 2020-10-17T19:42:53.027700Z

Yes, indeed.