Go: add context to storage (#17690)

Signed-off-by: Jin Hai <haijin.chn@gmail.com>
This commit is contained in:
Jin Hai
2026-08-03 15:08:21 +08:00
committed by GitHub
parent 2dbdaf951d
commit bddc941814
42 changed files with 634 additions and 527 deletions

View File

@@ -388,7 +388,7 @@ func storeAgentAttachment(ctx context.Context, docID string, payload []byte) (bo
return false, fmt.Errorf("storage not initialized")
}
bucket := fmt.Sprintf("%s-downloads", tenantID)
if err := storageImpl.Put(bucket, docID, payload); err != nil {
if err = storageImpl.Put(ctx, bucket, docID, payload); err != nil {
return false, err
}
return true, nil

View File

@@ -192,7 +192,7 @@ func TestDocsGenerator_Invoke_StoresAgentAttachment(t *testing.T) {
}
state := canvas.NewCanvasState("run-1", "task-1")
state.Sys["tenant_id"] = "tenant-1"
ctx := canvas.WithState(context.Background(), state)
ctx := canvas.WithState(t.Context(), state)
out, err := c.Invoke(ctx, nil, map[string]any{})
if err != nil {
@@ -205,7 +205,7 @@ func TestDocsGenerator_Invoke_StoresAgentAttachment(t *testing.T) {
if !ok || docID == "" {
t.Fatalf("doc_id = %v, want non-empty string", out["doc_id"])
}
blob, err := memStorage.Get("tenant-1-downloads", docID)
blob, err := memStorage.Get(ctx, "tenant-1-downloads", docID)
if err != nil {
t.Fatalf("stored blob missing: %v", err)
}