Documentation
¶
Overview ¶
Package main shows the recommended pattern for using s3db from AWS Lambda.
Key points:
The *s3db.DB is a package-level variable, opened once in init() and reused across warm invocations. The local SQLite file under /tmp survives between warm starts, so subsequent invocations only fetch the manifest + any new changesets — not the full snapshot.
Business logic that shouldn't retry (sending emails, calling external APIs) runs OUTSIDE the Update closure. The closure itself only does database work, since it may be re-invoked on rebase conflict.
Compaction and GC are handled by a separate scheduled Lambda (not shown here) triggered on a cron — they're too slow to run inline with user requests. Alternatively, use WithAutoCompact for light workloads.
Build for Lambda (pure Go, no CGo toolchain needed):
GOOS=linux GOARCH=amd64 go build -o bootstrap ./examples/lambda zip lambda.zip bootstrap