This repository demonstrates a Proof of Concept (PoC) implementation of gRPC using .NET, focusing on server-sent events. It includes both the server and client implementations, illustrating how to build and consume gRPC services for real-time event streaming.
- gRPC Server: Handles client subscriptions and streams real-time events.
- gRPC Client: Connects to the server and processes received events.
- Server-Sent Events: Implements a streaming mechanism using gRPC for efficient real-time data delivery.
- GrpcSSE: Contains the server-side implementation.
- GrpcSSEClient: Contains the client-side implementation.
- proto: Contains the
messages.proto
file defining the gRPC service contracts.
sequenceDiagram
actor Client
participant GrpcSSEClient as gRPC Client
participant GrpcSSE as gRPC Server
participant EventService
Client->>GrpcSSEClient: Start Client
GrpcSSEClient->>GrpcSSE: Connect to Server
GrpcSSE->>EventService: Handle Subscription
loop Stream Events
EventService->>GrpcSSEClient: Send Event Data
end
GrpcSSEClient->>Client: Display Event Data
classDiagram
class GrpcSSE {
+ConfigureServices(IServiceCollection services)
+Configure(IApplicationBuilder app, IWebHostEnvironment env)
}
class EventService {
+Subscribe(SubscribeRequest request, IServerStreamWriter<EventResponse> responseStream, ServerCallContext context)
}
class GrpcSSEClient {
+Main(string[] args)
}
GrpcSSE o-- EventService
GrpcSSEClient <|-- GrpcSSE
- .NET SDK
- gRPC tools
- gRPC NuGet packages:
Grpc.AspNetCore
Grpc.Tools
-
Clone the repository:
git clone https://github.com/your-username/grpc-poc-dotnet.git cd grpc-poc-dotnet
-
Restore dependencies:
dotnet restore
-
Run the server:
cd GrpcSSEServer dotnet run
-
Run the client:
cd GrpcSSEClient dotnet run
This project is licensed under the MIT License. See the LICENSE
file for details.