Skip to content

A collection of gRPC examples in Go demonstrating unary and streaming RPC patterns

License

Notifications You must be signed in to change notification settings

chaekeun/go-grpc-examples

Repository files navigation

Go gRPC Examples

This repository contains simple and educational examples of using gRPC in Go. It covers various RPC patterns including unary, client streaming, server streaming, and bidirectional streaming.

Prg01: Unary RPC – Square Calculation

  • The server listens on port 50051.
  • The client sends a single integer value (e.g., 4) to the server.
  • The server responds with the square of the number (e.g., 16).

Prg02: Bidirectional Streaming

  • The server listens on port 50051.
  • The client establishes a bidirectional stream with the server.
  • Both client and server send 5 messages to each other through the stream.

Prg03: Client Streaming

  • The server listens on port 50051.
  • The client streams multiple messages to the server.
  • The server counts the number of received messages.
  • When the client finishes (EOF), the server responds with the total count.

Prg04: Server Streaming

  • The server listens on port 50051.
  • The client sends a single number (e.g., 5) to the server.
  • The server logs the number and streams 5 messages back to the client.

Each program demonstrates how to implement and run different types of gRPC functions using Go.

Run Instructions

For each program:

# Run server
go run server.go

# Run client
go run client.go

About

A collection of gRPC examples in Go demonstrating unary and streaming RPC patterns

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages