aboutsummaryrefslogtreecommitdiff
path: root/exec_response.go
AgeCommit message (Collapse)Author
2026-02-06all: improve the Server-Sent Events (SSE) outputShulhan
In the ExecResponse, store the event in the Output instead of message data, so the server can iterate the Output directly and pass it to WriteEvent directly. The event ID now start at 1 with type "begin". This is to minimize confusion when comparing empty Last-Event-ID from client, which is equal to 0.
2026-02-03all: fix data race in tests and [httpServer.ExecuteTail]Shulhan
In the test for AwwanLocal, use buffer with lock, so each write and read is safe. In the httpServer, the test found data race during ExecuteTail when accessing [ExecResponse.EndAt]. We fix it by locking the resource during call to end() and when accessing the EndAt field.
2024-03-22all: replace module "share" with "pakakeh.go"Shulhan
The "share" project has been moved to SourceHut with new name "pakakeh.go".
2023-12-04all: write the output as is when sending with server-sent eventsShulhan
Previously, if the command output is "line1\n\nline2\n", the web output it as line1 line2 it should be line1 line2 This fix the empty line not displayed in wui output.
2023-12-01all: handle reconnecting when streaming executionShulhan
In "/awwan/api/execute/tail" SSE endpoint, in order for client to be able to reconnect and start streaming from the last know output, we need to send the ID for each message that we send. The ID is the index of Output in slice. If client does not send Last-Event-ID, we send all Output from beginning, otherwise, we send only message start from index in Last-Event-ID.
2023-12-01all: implement HTTP API to fetch execution output by IDShulhan
The new API is "GET /awwan/api/execute/tail" that implement Server-sent events, not a normal GET request. Its accept the query parameter "id" with value is the execution ID from "/awwan/api/execute". Once called with valid ID, it will streaming the command output to client. By using this new API, the WUI can receive the output of command immediately without waiting for all commands to be completed. Implements: https://todo.sr.ht/~shulhan/awwan/5 Signed-off-by: Shulhan <ms@kilabit.info>
2023-12-01all: refactoring HTTP endpoint for ExecuteShulhan
Previously, the Execute endpoint wait for command execution to finish. In case the command takes longer than proxy or server write timeout, it will return with an timeout error to client. In this changes, we generate an execution ID for each request and return it immediately. The next commit will implement HTTP endpoint to fetch the latest status and/or output by execution ID. References: https://todo.sr.ht/~shulhan/awwan/5
2023-11-16all: refactoring, rename HttpResponse to ExecResponseShulhan