Skip to content

Commit 0b6139c

Browse files
committed
fix: standardize response body closure and improve code formatting in SSE and registry handling
1 parent 7a30adb commit 0b6139c

3 files changed

Lines changed: 9 additions & 9 deletions

File tree

internal/agent/sse.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ import (
1111
)
1212

1313
const (
14-
sseEndpoint = "https://sse.tensor-fusion.ai/stream"
15-
sseReconnectMin = 1 * time.Second
16-
sseReconnectMax = 30 * time.Second
17-
sseDebounceDelay = 500 * time.Millisecond
18-
sseTopicHeader = "x-sse-topic"
14+
sseEndpoint = "https://sse.tensor-fusion.ai/stream"
15+
sseReconnectMin = 1 * time.Second
16+
sseReconnectMax = 30 * time.Second
17+
sseDebounceDelay = 500 * time.Millisecond
18+
sseTopicHeader = "x-sse-topic"
1919
)
2020

2121
// sseConfigListener connects to the SSE endpoint and triggers config re-fetch on new events.
@@ -70,7 +70,7 @@ func (a *Agent) listenSSE() error {
7070
if err != nil {
7171
return err
7272
}
73-
defer resp.Body.Close()
73+
defer func() { _ = resp.Body.Close() }()
7474

7575
if resp.StatusCode != http.StatusOK {
7676
klog.Warningf("SSE endpoint returned status %d", resp.StatusCode)

internal/api/types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ type AgentStatusRequest struct {
141141
type AgentStatusResponse struct {
142142
Success bool `json:"success"`
143143
ConfigVersion int `json:"config_version"`
144-
License *License `json:"license,omitempty"` // null if no regeneration needed
144+
License *License `json:"license,omitempty"` // null if no regeneration needed
145145
WorkerShareCodes map[string][]string `json:"worker_share_codes,omitempty"` // workerID -> []shareCode
146146
}
147147

internal/studio/registry.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ func getRegistryToken(ctx context.Context, registry, repo, username, password st
196196
if err != nil {
197197
return "", fmt.Errorf("token request failed: %w", err)
198198
}
199-
defer resp.Body.Close()
199+
defer func() { _ = resp.Body.Close() }()
200200

201201
if resp.StatusCode != http.StatusOK {
202202
return "", fmt.Errorf("token endpoint returned %d", resp.StatusCode)
@@ -263,7 +263,7 @@ func ListRemoteTags(ctx context.Context, image string, limit int) ([]string, err
263263
if err != nil {
264264
return nil, fmt.Errorf("registry request failed: %w", err)
265265
}
266-
defer resp.Body.Close()
266+
defer func() { _ = resp.Body.Close() }()
267267

268268
if resp.StatusCode == http.StatusUnauthorized {
269269
return nil, fmt.Errorf("authentication required for %s/%s — run 'docker login %s'", registry, repo, registry)

0 commit comments

Comments
 (0)