-
Notifications
You must be signed in to change notification settings - Fork 4
Description
Problem
Repeatedly executing KCL in the terminal is slow, because each time you execute KCL you have to establish a new connection to the engine via api-deux. This adds latency.
Solution
Start a modeling session with the engine, and keep it alive across multiple KCL programs. Just clear the scene between executing each KCL program.
The start-session command connects the CLI to the engine API via WebSocket. It then opens a tiny HTTP server on localhost (:3333 by default, but configurable) which accepts KCL programs in HTTP bodies. When it receives an HTTP request on that port, it executes the KCL program on the engine. It responds to the HTTP request with either a PNG screenshot, or an error.
This command is nearly ready, it's just got one problem. Right now api-deux times out WebSockets after 30 seconds of idle time. This is OK in the modeling app because users won't be idle for >30s, and if they are, the app reconnects them automatically. But it's not OK for this terminal or testing workflow. So the api-deux timeout should be increased, I'd suggest 5 minutes.