refactor: ember-server grpc error handling and protobuf fix - #123
Merged
Conversation
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
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
summary
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.
engine.schema_registry()in connection.rs(was calling
is_none()thenunwrap()on a second call — now useslet-else)net -41 lines (69 added, 110 removed).
what was tested
cargo check -p ember-server --features grpc,protobufcargo test -p ember-server— all 43 tests passdesign considerations
considered a full
grpc_handler!macro to eliminate even more boilerplate, butthe 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_responsehelper captures the highest-leverage simplificationwithout sacrificing readability.