Skip to content

GuilhermeStracini/POC-dotnet-gRPC

Repository files navigation

PoC gRPC using .NET

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.


Features

  • 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.

Project Structure

  • GrpcSSE: Contains the server-side implementation.
  • GrpcSSEClient: Contains the client-side implementation.
  • proto: Contains the messages.proto file defining the gRPC service contracts.

Architecture

Sequence Diagram: gRPC Server-Sent Events

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
Loading

Class Diagram: gRPC Server and Client

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
Loading

Prerequisites


Setup and Run

  1. Clone the repository:

    git clone https://github.com/your-username/grpc-poc-dotnet.git
    cd grpc-poc-dotnet
  2. Restore dependencies:

    dotnet restore
  3. Run the server:

    cd GrpcSSEServer
    dotnet run
  4. Run the client:

    cd GrpcSSEClient
    dotnet run

Useful Links


License

This project is licensed under the MIT License. See the LICENSE file for details.

About

🔬 Proof of Concept of gRPC with .NET

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published