Skip to content

build(sessions): vendor session.proto and set up tonic-build [2/12] - #155

Closed
sushanb wants to merge 2 commits into
liufuyang:mainfrom
sushanb:sessions/protos
Closed

sushanb wants to merge 2 commits into
liufuyang:mainfrom
sushanb:sessions/protos

Conversation

@sushanb

@sushanb sushanb commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Summary

Second in the stack. Vendors google/bigtable/v2/session.proto and its transitive proto dependencies from googleapis/googleapis, and adds tonic-build under a new sessions Cargo feature so the session-family types (OpenSessionRequest, CloseSessionRequest, GetClientConfigurationRequest, GoAwayResponse, SessionRefreshConfig, and their inner messages) are generated at build time.

Stacked on #154 (design record). The branch is layered on top of sessions/design-record, so this PR's diff currently includes both the spec/plan commits from #154 and the proto changes from this PR. Once #154 merges, I'll rebase this branch onto main and the diff will collapse to just the proto changes.

Changes

  • Vendored .protos under bigtable_rs/proto/google/{bigtable/v2,api,rpc,type}/ (verbatim from googleapis@main)
  • build.rs compiles only session.proto — all types defined in imported .protos (data.proto, types.proto, request_stats.proto, feature_flags.proto, peer_info.proto, response_params.proto) are redirected via extern_path to their existing generated equivalents in googleapis-tonic-google-bigtable-v2 and googleapis-tonic-google-rpc. No duplicate type generation.
  • Generated bindings exposed as bigtable_rs::session_proto (hidden from public docs; will be consumed by later PRs)
  • sessions Cargo feature (default-off) — users who don't opt in pay zero protoc build cost
  • Smoke test (tests/session_proto_smoke.rs) asserts every session-critical type is generated and that extern-path types resolve to the third-party crate's types

Rationale

The upstream googleapis-tonic-google-bigtable-v2 crate does not yet publish the session envelope types (verified against v0.36.0), but the .proto files are public in googleapis/googleapis. Vendoring + generating locally is the shortest unblocking path; when upstream regenerates, we can swap to their types with an extern_path change (no callers affected).

Test plan

  • cargo build --package bigtable_rs (default features) — succeeds, unchanged behavior
  • cargo build --package bigtable_rs --features sessions — succeeds, generates session_proto
  • cargo test --package bigtable_rs --lib — 2/2 pass (existing tests)
  • cargo test --package bigtable_rs --features sessions --test session_proto_smoke — 2/2 pass
  • cargo fmt --check — clean

Stack

🤖 Generated with Claude Code

Vendors the five specs from googleapis/google-cloud-go/bigtable/docs/specs
verbatim:
- SESSION_SPEC.md — per-Session lifecycle (10 invariants)
- SESSION_CLIENT_SPEC.md — SessionClient topology/config/handshake (4 invariants)
- SESSION_POOL_SPEC.md — pool topology, picking, routing, scaling (5 invariants)
- SESSION_COMPONENT_SPEC.md — 12 boundary MUSTs + ownership matrix
- CLIENT_SIDE_METRICS_SPEC.md — per-attempt metrics field provenance (3 invariants)

Adds SESSION_PORT_PLAN.md, the Rust-port design record: full scope
(direct-access checker only is excluded), proto strategy (vendor
session.proto + tonic-build), module layout mirroring Go's
internal/{transport,session} + debugview + internal/metrics, 12-PR
layered sequence (~22.6k LoC est.), and risks.

Bottom of a 12-PR stack. Subsequent PRs land the implementation
layer-by-layer per SESSION_PORT_PLAN.md.
Vendors google/bigtable/v2/session.proto + its transitive .proto
dependencies (data.proto, types.proto, request_stats.proto,
feature_flags.proto, peer_info.proto, response_params.proto plus
google/api/* and google/rpc/*) at bigtable_rs/proto/, taken verbatim
from googleapis/googleapis@main.

Adds a `sessions` Cargo feature (default-off). When enabled, build.rs
compiles session.proto via tonic-prost-build. Types from imported
.proto files are redirected via extern_path to their existing
generated equivalents in `googleapis-tonic-google-bigtable-v2` and
`googleapis-tonic-google-rpc` — the resulting `session_proto` module
contains only the session-family types (OpenSessionRequest,
CloseSessionRequest, GetClientConfigurationRequest, GoAwayResponse,
SessionRefreshConfig, and their nested messages).

Includes a smoke test (`tests/session_proto_smoke.rs`, feature-gated)
that asserts every session-critical type is generated and that the
extern-path bindings match the third-party crate's types.

Existing `BigTable`/`BigTableConnection` API unchanged; users who
don't enable `sessions` pay no protoc build cost. Rationale and PR
sequence in SESSION_PORT_PLAN.md.

Stacked on: `sessions/design-record` (PR #0 of the stack).
Followed by: session lifecycle (PR liufuyang#2).
@codecov

codecov Bot commented Aug 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 59.1%. Comparing base (2899ca5) to head (a3257b6).
⚠️ Report is 7 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##            main    #155     +/-   ##
=======================================
- Coverage   63.8%   59.1%   -4.6%     
=======================================
  Files          6       6             
  Lines        513     594     +81     
=======================================
+ Hits         327     351     +24     
- Misses       186     243     +57     
Flag Coverage Δ
rust 59.1% <ø> (-4.6%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
bigtable_rs/src/lib.rs 100.0% <ø> (ø)

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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