Skip to content

refactor: ember-server grpc error handling and protobuf fix - #123

Merged
kacy merged 1 commit into
mainfrom
refactor/ember-server
Feb 14, 2026
Merged

refactor: ember-server grpc error handling and protobuf fix#123
kacy merged 1 commit into
mainfrom
refactor/ember-server

Conversation

@kacy

@kacy kacy commented Feb 14, 2026

Copy link
Copy Markdown
Owner

summary

  • replaces the check_wrong_type(&other).unwrap_or_else(|| Status::internal("unexpected response"))
    pattern with a single unexpected_response() helper across ~50 call sites in grpc.rs.
    the new function handles WrongType, OutOfMemory, Err, and unknown variants in one place.
  • fixes a double-call + unwrap on engine.schema_registry() in connection.rs
    (was calling is_none() then unwrap() on a second call — now uses let-else)
  • adds a detailed comment explaining the scan cursor encoding math

net -41 lines (69 added, 110 removed).

what was tested

  • cargo check -p ember-server --features grpc,protobuf
  • cargo test -p ember-server — all 43 tests pass

design considerations

considered a full grpc_handler! macro to eliminate even more boilerplate, but
the handlers have enough variation in request construction and response mapping
that a macro would be harder to read than the repetitive-but-obvious handlers.
the unexpected_response helper captures the highest-leverage simplification
without sacrificing readability.

grpc.rs:
- replace check_wrong_type + unwrap_or_else pattern with a single
  unexpected_response() helper that maps all error variants in one place
  (~50 call sites simplified from 2 lines to 1)
- add detailed comment on scan cursor encoding math explaining how
  the global cursor encodes shard index and per-shard position

connection.rs:
- fix protobuf double-call + unwrap: replace is_none() check followed
  by a second call + unwrap() with a single let-else binding
@kacy
kacy merged commit e60b203 into main Feb 14, 2026
4 of 7 checks passed
@kacy
kacy deleted the refactor/ember-server branch February 14, 2026 21:49
kacy added a commit that referenced this pull request Feb 19, 2026
grpc.rs:
- replace check_wrong_type + unwrap_or_else pattern with a single
  unexpected_response() helper that maps all error variants in one place
  (~50 call sites simplified from 2 lines to 1)
- add detailed comment on scan cursor encoding math explaining how
  the global cursor encodes shard index and per-shard position

connection.rs:
- fix protobuf double-call + unwrap: replace is_none() check followed
  by a second call + unwrap() with a single let-else binding
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