https://github.com/ollls/qh2grpc-zio
https://github.com/ollls/qh2grpc-zio
Last synced: 5 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/ollls/qh2grpc-zio
- Owner: ollls
- Created: 2025-10-07T17:03:00.000Z (9 months ago)
- Default Branch: master
- Last Pushed: 2025-10-07T17:58:26.000Z (9 months ago)
- Last Synced: 2025-10-07T19:41:13.382Z (9 months ago)
- Language: HTML
- Size: 55.7 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# qh2grpc-zio
A lightweight gRPC-over-HTTP/2 framework for Scala 3 that implements native gRPC protocol support directly within a ZIO Quartz H2 HTTP/2 server--**without** using Google's standard `ServerBuilder` infrastructure.
## Key Features
- **Native gRPC-over-HTTP/2**: Implements gRPC as HTTP/2 request handlers rather than a separate server stack
- **Unified Endpoints**: Serve both HTTP/2 and gRPC endpoints with minimal overhead
- **Compile-Time Safety**: Method discovery using Scala 3 macros for zero runtime reflection
- **ZIO-Native**: Full integration with ZIO effects and streams
- **Flexible Backends**: Supports both Java NIO and Linux IO-Uring (kernel 5.1+)
- **All 4 gRPC Patterns**: Unary, server streaming, client streaming, and bidirectional streaming
## Technology Stack
- **Scala 3.3.3**
- **ZIO 2.1.16** (functional effect system)
- **zio-quartz-h2 0.7.1** (HTTP/2 server)
- **ScalaPB & zio-grpc 0.6.3** (Protocol Buffers)
- **SBT 1.10.0** (build tool)
## Quick Start
### Prerequisites
- JDK 11+
- SBT 1.10.0+
- `keystore.jks` file with password "password" (included in project)
### Running the Server
```bash
# Start the server (default: HTTPS on localhost:8443)
sbt run
# Run with different log levels
sbt "run --debug" # DEBUG level
sbt "run --error" # ERROR level
sbt "run --trace" # TRACE level
sbt "run --off" # Logging OFF
```
The server will start on `https://localhost:8443` and serve both HTTP/2 and gRPC endpoints.
### Testing the Server
#### Automated Testing
Run the comprehensive test script that validates all 4 gRPC communication patterns:
```bash
# In a separate terminal (with server running)
./test-grpc.sh
```
This tests:
- **Unary to Unary** (`SayHello`)
- **Unary to Stream** (`LotsOfReplies`)
- **Stream to Unary** (`LotsOfGreetings`)
- **Stream to Stream** (`BidiHello`)
#### Manual Testing with grpcurl
**Unary to Unary:**
```bash
grpcurl -v -insecure -proto src/main/protobuf/orders.proto \
-d '{"name": "John", "number": 101}' \
localhost:8443 com.example.protos.Greeter/SayHello
```
**Server Streaming:**
```bash
grpcurl -v -insecure -proto src/main/protobuf/orders.proto \
-d '{"name": "Alice", "number": 42}' \
localhost:8443 com.example.protos.Greeter/LotsOfReplies
```
**Client Streaming:**
```bash
grpcurl -v -insecure -proto src/main/protobuf/orders.proto \
-d @ localhost:8443 com.example.protos.Greeter/LotsOfGreetings <