Skip to content

feat: grpc server implementation#117

Merged
kacy merged 3 commits intomainfrom
feat/grpc-server
Feb 14, 2026
Merged

feat: grpc server implementation#117
kacy merged 3 commits intomainfrom
feat/grpc-server

Conversation

@kacy
Copy link
Copy Markdown
Owner

@kacy kacy commented Feb 14, 2026

summary

implements the full grpc server for ember, sitting alongside RESP3 with its
own listener port. all commands route through the same sharded engine, so
behavior is identical regardless of protocol.

  • grpc.rs: tonic service impl (~1200 LOC) covering strings, keys, lists,
    hashes, sets, sorted sets, vectors, server commands, and bidirectional
    pipeline streaming
  • --grpc-port 6380 (default) and --no-grpc CLI flags behind grpc feature
  • grpc listener spawns as a separate tokio task in both run() and
    run_concurrent(), sharing engine, server context, and slowlog
  • vector commands return UNIMPLEMENTED when built without the vector feature
  • tokio-stream added for bidirectional pipeline streaming

error mapping follows grpc conventions:

  • WrongType → FAILED_PRECONDITION
  • OutOfMemory → RESOURCE_EXHAUSTED
  • shard unavailable → UNAVAILABLE
  • generic errors → INTERNAL

no unwrap() or expect() anywhere. every match arm is covered.

what was tested

  • cargo build -p ember-server --features grpc — compiles
  • cargo build -p ember-server — no regression without feature
  • cargo clippy -p ember-server --features grpc -- -D warnings — clean
  • cargo test -p ember-server --features grpc — 43/43 pass
  • cargo fmt --all --check — clean

design considerations

grpc service does not use a separate grpc_convert.rs file as originally
planned. each handler does its own response mapping inline, which keeps the
code simpler and more readable since the mappings are straightforward.

the pipeline rpc uses a spawned task with an mpsc channel rather than direct
stream processing. this allows the pipeline to process commands concurrently
while maintaining response ordering via the request id field.

auth interceptor is not yet implemented (planned for a follow-up). the grpc
listener currently relies on the same protection mechanisms as RESP3 (network
isolation, requirepass at the RESP3 level).

Base automatically changed from feat/grpc-proto to main February 14, 2026 16:11
kacy added 3 commits February 14, 2026 11:12
implements the EmberCache tonic trait with handlers for all command
groups: strings, keys, lists, hashes, sets, sorted sets, vectors,
server commands, and bidirectional pipeline streaming.

each handler follows the same pattern: translate proto request to
ShardRequest, route through the engine, map ShardResponse back to
proto response. vector commands gracefully return UNIMPLEMENTED when
built without the vector feature.

error mapping:
- WrongType → FAILED_PRECONDITION
- OutOfMemory → RESOURCE_EXHAUSTED
- shard unavailable → UNAVAILABLE
- generic errors → INTERNAL

no unwrap() or expect() in any handler.
tokio-stream provides ReceiverStream used by the bidirectional
Pipeline rpc to stream responses back to clients.
adds --grpc-port (default 6380) and --no-grpc CLI args behind the
grpc feature flag. the grpc listener spawns as a separate tokio task
alongside the existing TCP and TLS accept loops, sharing the same
engine, server context, and slowlog.

both run() and run_concurrent() support the grpc listener.
@kacy kacy merged commit f0d62f1 into main Feb 14, 2026
7 checks passed
@kacy kacy deleted the feat/grpc-server branch February 14, 2026 16:13
kacy added a commit that referenced this pull request Feb 19, 2026
* add grpc service implementation

implements the EmberCache tonic trait with handlers for all command
groups: strings, keys, lists, hashes, sets, sorted sets, vectors,
server commands, and bidirectional pipeline streaming.

each handler follows the same pattern: translate proto request to
ShardRequest, route through the engine, map ShardResponse back to
proto response. vector commands gracefully return UNIMPLEMENTED when
built without the vector feature.

error mapping:
- WrongType → FAILED_PRECONDITION
- OutOfMemory → RESOURCE_EXHAUSTED
- shard unavailable → UNAVAILABLE
- generic errors → INTERNAL

no unwrap() or expect() in any handler.

* add tokio-stream dep for grpc pipeline streaming

tokio-stream provides ReceiverStream used by the bidirectional
Pipeline rpc to stream responses back to clients.

* integrate grpc listener into server startup

adds --grpc-port (default 6380) and --no-grpc CLI args behind the
grpc feature flag. the grpc listener spawns as a separate tokio task
alongside the existing TCP and TLS accept loops, sharing the same
engine, server context, and slowlog.

both run() and run_concurrent() support the grpc listener.
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