Categorygithub.com/Nikhil-Giramkar/Go-gRPC-Demo
repository
0.0.0-20240629050632-36af2a1704c2
Repository: https://github.com/nikhil-giramkar/go-grpc-demo.git
Documentation: pkg.go.dev

# Packages

No description provided by the author
No description provided by the author
No description provided by the author

# README

Go-gRPC-Demo

Why?

In a REST or GraphQL architecture we have
Client sending request
Server giving response

But this process is

  • Slow
  • Synchronous
  • Not Scalable

  • How?

    How to make the client server intercation Scalable?

    For that we use Remote Procedure Calls (RPC)

    RPC directly calls functions from client to server Instead of JSON, we use protobuf files Here, payload size is small and accelerates communication

    Client Server communication can happen via Streaming (sequences of mesages)
    Stream is continous flow of data
    Its asynchronous
    Extremely scalable
    Usecase: MICROSERVICES!, Blockchains


    There are mainly 4 types of communications in GRPC
    1. Unary API

      Regular request-response

    2. Server Streaming

      Client sends a request to server

      Server sends a strea of data to client

    3. Client Streaming

      Client sends a stream of data to server

      Server provides a siple response to client

    4. Bi-Directional Streaming

      Both client and server can communicate via streaming.

      And they can do this parallely,

      Not like request response wehre client sneds first and then server gives response - not like this.

      Its like a two way-traffic

      Even though its a stream, not a queue, sequence of messages is preserved


    To Run the project

    Install the dependencies
    go mod tidy
    

    Run the server

    go run server/main.go
    

    Run the client

    go run client/main.go