The greptime-meter provides an abstraction about data read/write computation and collection. It consists of the following crates:
- meter-core: provides some core traits and data structures.
- meter-macros: provides some macros for user convenience, include
write_meter!etc. - meter-example: provides a simple implementation of
meter-coreand an example.
cargo doc --open --no-depsMeterRecord::new(catalog, schema, value, rows, source)now takes an explicit insertion row count. Read records userows = 0;valuekeeps its calculated metering meaning (for example, WCU/RCU).- Implement
Collect::on_writewith a boxedSendfuture returningResult<(), meter_core::collect::WriteRejected>. Reject before recording accepted usage.on_readremains synchronous. - Await
write_meter!(catalog, schema, requests, rows, source)and handle its rejection before dispatch. It returns the calculated value on success. Missing calculators still submit the row count withvalue = 0. - For bulk writes, await
write_meter!(record)with a precomputedMeterRecord. This uses the sameRegistry::record_writeoperation without a calculator. meter-macrosdefaults tonoop: both write forms returnOk(0)without evaluating arguments, including row-count scans. Setdefault-features = falseto enable collection. Direct registry calls always invoke registered collectors.
Collection happens before write dispatch. Success means admission and recording, not successful persistence. The registry neither implements quota policy nor refunds usage after a downstream failure. No registered collector permits writes.
Downstream integration is a manual checkpoint: update both meter-core and
meter-macros to the same intended revision and regenerate the consumer's
lockfile. Publishing and downstream dependency changes are separate steps.
Run enabled and noop configurations separately to avoid feature unification hiding the enabled macro implementation:
cargo check --workspace --all-targets
cargo check -p meter-macros -p meter-example --all-targets --no-default-features
cargo fmt --all -- --check
cargo clippy --workspace --all-targets -- -D warnings
cargo clippy -p meter-macros -p meter-example --all-targets --no-default-features -- -D warnings
cargo nextest run --workspace
cargo nextest run -p meter-macros --no-default-features
cargo nextest run -p meter-macros --features noop
cargo test --doc --workspace
cargo test --doc -p meter-macros --no-default-features