2026/09/26
< 2026
|
Saturday, September 26, 2026 (#269)
|
|
References |
Auxiliary
- Signal is annoying
Main Work
After the main rework of Ferreteria connection-sessions, and creating the Portal (connections) and Process (running processes locally or remotely) clades, I'm having difficulty figuring out what the API should be for keeping a connection (Portal) open while closing the process and opening a new one.
I'm not sure why this is difficult. It might be that Session is actually getting in the way a little?
...or maybe we just need to draw a distinction in Session's API:
- Open() / Shut(): opens and closes the connection
- Should Shut() give an error if the Process is still open?
- If we close the Process automatically on Shut(), then we end up with asymmetry in the code, right? ...which has been shown to be confusing (to me, anyway).
- Alternatively, we could say that it works like this:
- Open() opens the connection and the process (command must have already been specified)
- Shut() closes the process and the connection (errors if process already shut?)
- Should Shut() give an error if the Process is still open?
- OpenProc() / ShutProc(): opens (runs) and closes (terminates) the process
- OpenProc() should error if command not specified yet
How about:
- Open() / Shut() - opens/closes everything (including Streams)
- Basically just runs OpenPort()+OpenProc() / ShutProc()+ShutPort()
- ...but also opens/closes streams... hmm, maybe we need OpenStrms()/ShutStrms() (nonpublic)
- Open() errors if command-string isn't set (because OpenProc() does)
- Shut() errors if Proc was never opened.
- OpenPort() / ShutPort() - opens and closes the connection
- OpenPort() also sets up the Streams
- ShutPort() errors if the Proc is open
- OpenProc() / ShutProc() - opens (runs) and closes (terminates) the process
- OpenProc() errors if the command-string isn't set
- ShutProc() errors if the Proc was never opened.
Some needed tweaks became apparent there, so here's "how about" v2:
- [public] OpenPort() / ShutPort() - opens and closes the connection
- OpenPort()
also sets up the Streams - ShutPort() errors if the Proc is open
- OpenPort()
- [public] OpenProc() / ShutProc() - opens (runs) and closes (terminates) the process
- OpenProc() errors if the command-string isn't set
- ShutProc() errors if the Proc was never opened.
- [prot] OpenStrms() / ShutStrms() - opens/closes the app-to-exec streams
- OpenStrms() ensures that all 6 streams (3 pairs) have open-requests
- This takes the place of CanalSetup().
- ShutStrms() removes its open-requests from all 6 streams
- This takes the place of CanalShutoff().
- OpenStrms() ensures that all 6 streams (3 pairs) have open-requests
- [public] Open() / Shut() (via [prot] Actual*()) - opens/closes everything (including Streams)
- = OpenPort()+OpenProc()+OpenStrms() / ShutStrms()+ShutProc()+ShutPort()
- Open() errors if command-string isn't set (because OpenProc() does)
- Shut() errors if Proc was never opened.
These calls can be used like this:
- Open() / Shut() if you just want to open the connection, run a single command, and close the connection. Simple but blunt.
- OpenPort() / ShutPort() if you want to do more than one operation while the connection is open
- OpenProc() / ShutProc() (on an open connection) for running a single executable and interacting with it.