storage/gcp/antispam: add optional SpannerClient to AntispamOpts#1054
Merged
AlCutter merged 1 commit intoJul 13, 2026
Merged
Conversation
Contributor
|
Thanks for the PR Erin, reassigning to @AlCutter for review. |
AlCutter
approved these changes
Jul 13, 2026
Allows callers to provide an existing Spanner client to NewAntispam instead of it always creating its own, mirroring Config.SpannerClient on the GCP log storage. This lets multi-tenant deployments share a single client (and its session pool) across the log storage and any number of antispam instances in the same database. An injected client must be connected to the database named by the spannerDB parameter; this is validated at construction since a mismatched client would otherwise silently disable deduplication (lookups treat NotFound as a cache miss). An injected client is also used to apply the initial schema mutations; when no client is provided, table preparation keeps using its own temporary client and behavior is unchanged.
AlCutter
force-pushed
the
gcp-antispam-spanner-client
branch
from
July 13, 2026 11:27
ee4be95 to
f920f02
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds an optional
SpannerClientfield to the GCP antispamAntispamOpts. If set,NewAntispamuses the provided client instead of creating its own, mirroring the existingConfig.SpannerClienton the GCP log storage.Why
Multi-tenant deployments that store several logs' state in one Spanner database (via
SpannerTablePrefix, #1040) currently get a separate Spanner client — with its own session pool — for every antispam instance, on top of the log storage's client. Allowing a shared client keeps session usage bounded no matter how many logs share the database.Notes
spannerDBparameter. This is validated at construction, since a mismatched client would otherwise silently disable deduplication (lookups treat NotFound as a cache miss).Testing
TestAntispamStoragedrives the full append → follow → dedup-lookup cycle through an injected client againstspannertest.TestAntispamSharedClientWrongDatabaseasserts a client connected to a different database is rejected.