fix(client): watch only rule paths, forget vanished worktrees, ping http2

This commit is contained in:
hh committed 2026-09-28 23:14:41 +02:00
1 parent 3b2dcffcf0
commit 4207f7e6f8
4 files changed
+165 -34

No files matched your search

+13 -2
View File
@@ -21,9 +21,14 @@ import (
"lodge/internal/protocol"
)
const requestTimeout = 15 * time.Second
const (
requestTimeout = 15 * time.Second
sendPingAfter = 15 * time.Second
pingTimeout = 10 * time.Second
)
var (
httpClient = &http.Client{Transport: newTransport()}
ErrNotLoggedIn = errors.New("not logged in: run the install command from the lodge admin page")
errConflict = errors.New("server state changed")
)
@@ -89,13 +94,19 @@ func writeFile(path string, data []byte, mode os.FileMode) error {
return os.Rename(temp, path)
}
func newTransport() *http.Transport {
transport := http.DefaultTransport.(*http.Transport).Clone()
transport.HTTP2 = &http.HTTP2Config{SendPingTimeout: sendPingAfter, PingTimeout: pingTimeout}
return transport
}
func (c *Client) request(ctx context.Context, method, path string, body []byte) (*http.Response, error) {
req, err := http.NewRequestWithContext(ctx, method, c.URL+path, bytes.NewReader(body))
if err != nil {
return nil, err
}
req.Header.Set("Authorization", "Bearer "+c.Token)
res, err := http.DefaultClient.Do(req)
res, err := httpClient.Do(req)
if err != nil {
return nil, err
}