grpc-server-streaming

module
v0.0.0-...-1005397 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 20, 2024 License: Apache-2.0

README

Cloud Run gRPC Server Streaming sample application

For a general introduction to gRPC on Go, see the official gRPC quickstart.

This sample presents:

  • ./server: a gRPC server application with an RPC that streams the current time in the response (written in Go)
  • ./client: a small program to query the server and show the response messages (written in Go)

Deploy gRPC server to Cloud Run

Use the following button to deploy the application to Cloud Run on your GCP project:

Run on Google Cloud

Once deployed successfully, note the domain name (hostname) of the service.

Make a request using the client

  1. Ensure Go 1.13 (or higher) is installed on your machine.

  2. Clone this repository.

  3. Run the client with the hostname of the deployed service:

    cd grpc-server-streaming
    
    go run ./client -duration 5 -server <HOSTNAME>:443
    
  4. Observe the output, it should be receiving and printing a message every second as the server sends them.

    rpc established to timeserver, starting to stream
    received message: current_timestamp: 2020-01-15T01:12:29Z
    received message: current_timestamp: 2020-01-15T01:12:30Z
    received message: current_timestamp: 2020-01-15T01:12:31Z
    received message: current_timestamp: 2020-01-15T01:12:32Z
    received message: current_timestamp: 2020-01-15T01:12:33Z
    end of stream
    

Cleanup

Remove the grpc-server-streaming Service you deployed from Cloud Run using the Cloud Console.

Directories

Path Synopsis
Package client is a small tool to query the streaming gRPC endpoint.
Package client is a small tool to query the streaming gRPC endpoint.
pkg
Sample grpc server with a streaming response.
Sample grpc server with a streaming response.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL