refactor(adapter): fix config at construction, drop setters/getters & query logging#14
Merged
Conversation
… query logging Adapter configuration (namespace, database, secure, sharedTables, async inserts, dual-read sample rate) is now passed via readonly constructor params instead of post-construction setters. Tenant remains a mutable setter — a single adapter serves many tenants across requests. - ClickHouse: setNamespace/setDatabase/setSecure/setSharedTables/ setAsyncInserts/setDualReadSampleRate → constructor params; remove config-mirror getters (getNamespace/getTenant/isSharedTables). - Database: drop setNamespace/setSharedTables (callers configure the injected Utopia\Database directly); keep setTenant. - Usage facade: drop setNamespace/setSharedTables/setDualReadSampleRate; keep setTenant. - Remove the unused query-logging feature (enableQueryLogging, queryLog, logQuery, getQueryLog/clearQueryLog) — not referenced in any consumer. Net -225 LoC. BREAKING: consumers calling the removed setters (e.g. cloud's ->setDatabase()) must move that config into the constructor. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Greptile encountered an error while reviewing this PR. Please reach out to support@greptile.com for assistance. |
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
Adapter configuration is now passed via
readonlyconstructor params instead of post-construction setters.setTenantis the one mutable exception — a single adapter serves many tenants across requests, so tenant legitimately changes over an instance's lifetime.ClickHouse adapter
readonlyconstructor params:setNamespace,setDatabase,setSecure,setSharedTables,setAsyncInserts(→asyncInserts+asyncInsertWait),setDualReadSampleRate. Host/port/namespace/database validation and dual-read-rate clamping moved into the constructor. New params sit after$client, so existing positional callers are unaffected.getNamespace,getTenant,isSharedTables.setTenant,setNextQueryId(per-query runtime state), and the operationalgetRouteLog/clearRouteLog/getConnectionStats.Database adapter
setNamespace/setSharedTables— callers configure the injectedUtopia\Databaseinstance directly (as the tests already do). KeptsetTenant.Usage facade
setNamespace/setSharedTables/setDualReadSampleRate(config is now construction-time). KeptsetTenant(flushes buffer + delegates).Query logging removed
The
enableQueryLoggingflag,queryLog,logQuery(), andgetQueryLog()/clearQueryLog()are gone. A code search acrossappwrite+appwrite-labsfound zero consumers.getConnectionStats()stays (used by tests forrequest_count+ async flags) minus itsquery_logging_enabledkey.Why
Less surface area, immutable-by-default configuration, and a net −225 LoC.
Consumers that call the removed setters must move that config into the constructor. Notably cloud (
app/cli.php,app/worker.php) calls->setDatabase(...)on the usage adapter:A coordinated cloud update is needed before/with the release that bumps this dependency.
Test plan
pint --test✅phpstan(level config) ✅MetricTest,UsageQueryTest) ✅🤖 Generated with Claude Code