go-training / proto-go-sample

Sample Code for proto connect.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

proto-go-sample

build sample code

Sample Code for proto connect. Connect is a slim library for building browser and gRPC-compatible HTTP APIs.

Feature

  • Support gRPC and HTTP RESTful API using connect-go library
  • Support OpenTelemetry protocol (OTLP) and APM like uptrace and signoz

Install signoz

Install SigNoz Using Docker Compose

git clone -b main https://github.com/SigNoz/signoz.git && cd signoz/deploy/
docker-compose -f docker/clickhouse-setup/docker-compose.yaml up -d

Ensure that the ports 3301, 4317 and 4318 are open on the machine where you install SigNoz.

Build Server and Client

make build

Start server

Support the following server.

Run three service

# service 01
./bin/gin-server -env-file .env.server01
# service 02
./bin/gin-server -env-file .env.server02
# service 03
./bin/chi-server -env-file .env.server03

Start client

run three client with Go

./bin/client -env-file .env.server01
./bin/client -env-file .env.server02
./bin/client -env-file .env.server03

Testing with other command

Use curl

run client with curl command

curl --header "Content-Type: application/json" \
    --data '{"name": "foobar"}' \
    http://localhost:8080/gitea.v1.GiteaService/Gitea

health check

curl --header "Content-Type: application/json" \
    --data '{"service": "gitea.v1.GiteaService"}' \
    http://localhost:8080/grpc.health.v1.Health/Check

Use grpcurl

run client with grpcurl command

grpcurl \
  -plaintext \
  -d '{"name": "foobar"}' \
  localhost:8080 \
  gitea.v1.GiteaService/Gitea

health check

grpcurl \
  -plaintext \
  -d '{"service": "gitea.v1.GiteaService"}' \
  localhost:8080 \
  grpc.health.v1.Health/Check

Use grpcui

See the details page for grpcui

grpcui -plaintext localhost:8080

page

Use Postman

page

About

Sample Code for proto connect.


Languages

Language:Go 98.0%Language:Makefile 2.0%