Skip to content

Commit 4a44aac

Browse files
fix
1 parent 044075f commit 4a44aac

File tree

1 file changed

+26
-2
lines changed
  • app/contribute/how-to-add-storage

1 file changed

+26
-2
lines changed

app/contribute/how-to-add-storage/page.tsx

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,9 @@ export default function HowToAddStoragePage() {
124124
<ul>
125125
<li>
126126
<code>
127-
SaveFile(encryptor encryption.FieldEncryptor, logger
128-
*slog.Logger, fileID uuid.UUID, file io.Reader) error
127+
SaveFile(ctx context.Context, encryptor
128+
encryption.FieldEncryptor, logger *slog.Logger, fileID
129+
uuid.UUID, file io.Reader) error
129130
</code>{" "}
130131
- saves a backup file to the storage
131132
</li>
@@ -168,6 +169,29 @@ export default function HowToAddStoragePage() {
168169
</li>
169170
</ul>
170171

172+
<div className="rounded-lg border border-amber-200 bg-amber-50 pt-4 px-4 my-6">
173+
<p className="text-sm text-amber-900 m-0">
174+
<strong>⚠️ Context cancellation:</strong> Your{" "}
175+
<code>SaveFile</code> implementation must respect the{" "}
176+
<code>ctx</code> context for cancellation. Check{" "}
177+
<code>ctx.Done()</code> periodically during upload operations
178+
and return early with an appropriate error when the context is
179+
cancelled. This ensures graceful shutdown and backup
180+
cancellation work correctly.
181+
</p>
182+
</div>
183+
184+
<div className="rounded-lg border border-purple-200 bg-purple-50 pt-4 px-4 my-6">
185+
<p className="text-sm text-purple-900 m-0">
186+
<strong>📦 Backpressure handling:</strong> When implementing{" "}
187+
<code>SaveFile</code>, read from the <code>io.Reader</code> in
188+
chunks of up to <strong>32 MB</strong> and upload them
189+
incrementally. This prevents memory exhaustion on large
190+
backups and respects backpressure from the upstream pipe.
191+
Avoid reading the entire file into memory at once.
192+
</p>
193+
</div>
194+
171195
<div className="rounded-lg border border-blue-200 bg-blue-50 pt-4 px-4 my-6">
172196
<p className="text-sm text-blue-900 m-0">
173197
<strong>🔐 Encryption requirement:</strong> All sensitive

0 commit comments

Comments
 (0)