Skip to content

Add Kotlin usage meter with Postgres quotas and ClickPipes reports - #448

Draft
sdairs wants to merge 2 commits into
mainfrom
codex/usage-meter
Draft

sdairs wants to merge 2 commits into
mainfrom
codex/usage-meter

Conversation

@sdairs

@sdairs sdairs commented Oct 2, 2026

Copy link
Copy Markdown
Collaborator

Account-scoped consumption needs an atomic quota decision and safe retries, while analytical reports can lag. This Kotlin/Ktor API locks the authenticated account in Postgres, commits the daily counter and immutable event together, and retains request IDs across UTC days. ClickPipes replicates only events to ClickHouse; bounded, read-only Java-client reports apply FINAL and tombstone filtering and explicitly declare eventual consistency. The application never dual writes.

Includes explicit Cloud provisioning/TLS/roles/publication/custom-ordering setup and cleanup, versioned migrations/seed, pinned Gradle/JDK/dependency locks, API examples, meaningful opt-in Cloud controls, and credential-free unit/build CI.

Validation in an isolated native Ubuntu ARM 64 VM against own Cloud PostgreSQL 18.6/ClickHouse 26.6.1.2191:4 unit +2 live TLS/midnight controls; two 12-client bursts each completed in 12 HTTPattempts without 503 (one debit for same ID; exact 100 quota); modest 3-client no-retry control; cross-account/auth/input/role denials; post-counter insertion-failure rollback; actual snapshot/CDC; paused pipeline while operational quota advanced; both analytical slots denied/recovered in same client while Postgres writes succeeded; exact final day/feature sums/counts after resume; privileged-maintenance tombstone identity; genuine runtime-only process restart. Fresh source build succeeded without database/Cloud credentials. Earlier 5-second lock timeout was diagnosed and corrected to bounded 20-second SQL/25-second socket limits; no performance or ingestion-SLA claim.

The companion article and private evidence stay local for editorial review. No published article URL, deployment, billing integration, retention policy or resync claim.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant