Skip to content

Commit c534bfc

Browse files
authored
Merge pull request #14 from utopia-php/feat/remove-setters-2
refactor(adapter): fix config at construction, drop setters/getters & query logging
2 parents dd77631 + 89759c6 commit c534bfc

8 files changed

Lines changed: 144 additions & 369 deletions

File tree

README.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,16 @@ composer require utopia-php/usage
3636
use Utopia\Usage\Usage;
3737
use Utopia\Usage\Adapter\ClickHouse;
3838

39+
// Configuration is fixed at construction; only the tenant changes per request.
3940
$adapter = new ClickHouse(
4041
host: 'clickhouse-server',
4142
username: 'default',
4243
password: '',
4344
port: 8123,
44-
secure: false
45+
secure: false,
46+
namespace: 'my_app',
47+
sharedTables: true,
4548
);
46-
47-
// Multi-tenant setup
48-
$adapter->setNamespace('my_app');
49-
$adapter->setSharedTables(true);
5049
$adapter->setTenant('project_123');
5150

5251
$usage = new Usage($adapter);
@@ -333,9 +332,11 @@ Extend `Utopia\Usage\Adapter` and implement:
333332
- `sumDaily(array $queries, string $attribute): int`
334333
- `sumDailyBatch(array $metrics, array $queries): array`
335334
- `purge(array $queries, ?string $type): bool`
336-
- `setNamespace(string $namespace): self`
337335
- `setTenant(?string $tenant): self`
338-
- `setSharedTables(bool $sharedTables): self`
336+
337+
Namespace, database, shared-tables mode, async inserts, query logging and the
338+
dual-read sample rate are set once via the adapter constructor (see "Using
339+
ClickHouse Adapter" above). Only the tenant changes over an instance's lifetime.
339340

340341
## System Requirements
341342

src/Usage/Adapter.php

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -158,18 +158,4 @@ abstract public function sumDaily(array $queries = [], string $attribute = 'valu
158158
* @return array<string, int> Metric name => sum value
159159
*/
160160
abstract public function sumDailyBatch(array $metrics, array $queries = []): array;
161-
162-
/**
163-
* Enable parity sampling for routed reads. At rate=0 the sampler is
164-
* disabled (default). At rate>0 each routed read is re-executed against
165-
* the raw table with the given probability and logs a dual_read_warning
166-
* entry when totals diverge by more than 1%. Pass 1.0 for every-read
167-
* sampling (CI use) or small values (0.01) for production canaries.
168-
*
169-
* Adapters without parity sampling override this with a no-op.
170-
*/
171-
public function setDualReadSampleRate(float $rate): self
172-
{
173-
return $this;
174-
}
175161
}

0 commit comments

Comments
 (0)