This commit is contained in:
2026-09-01 06:31:41 +02:00
parent ad54651558
commit 695ac8a713
14 changed files with 621 additions and 13 deletions
+10 -1
View File
@@ -155,6 +155,13 @@ func (m *Manager) get(ctx context.Context, id int64) (storedNode, error) {
return n, nil
}
func (m *Manager) Do(ctx context.Context, id int64, method, path string, body any) ([]byte, int, error) {
return m.DoWithTimeout(ctx, id, method, path, body, m.client.Timeout)
}
// DoWithTimeout performs an authenticated agent request with an operation-specific
// timeout. Long-running host package operations use this rather than weakening
// the normal 30-second control-plane timeout for every request.
func (m *Manager) DoWithTimeout(ctx context.Context, id int64, method, path string, body any, timeout time.Duration) ([]byte, int, error) {
n, err := m.get(ctx, id)
if err != nil {
return nil, 0, err
@@ -178,7 +185,9 @@ func (m *Manager) Do(ctx context.Context, id int64, method, path string, body an
if body != nil {
req.Header.Set("Content-Type", "application/json")
}
resp, err := m.client.Do(req)
client := *m.client
client.Timeout = timeout
resp, err := client.Do(req)
if err != nil {
return nil, 0, err
}