https://github.com/mrdulin/grpc-go-cnode
A Go gRPC server for CNode community.
https://github.com/mrdulin/grpc-go-cnode
cnode go golang grpc grpc-go grpc-server protobuf protocol-buffers
Last synced: 9 months ago
JSON representation
A Go gRPC server for CNode community.
- Host: GitHub
- URL: https://github.com/mrdulin/grpc-go-cnode
- Owner: mrdulin
- License: mit
- Created: 2018-05-18T07:42:31.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2023-10-26T02:16:50.000Z (over 2 years ago)
- Last Synced: 2025-01-12T18:52:11.765Z (about 1 year ago)
- Topics: cnode, go, golang, grpc, grpc-go, grpc-server, protobuf, protocol-buffers
- Language: Go
- Homepage:
- Size: 1.44 MB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# grpc-go-cnode
[](https://goreportcard.com/report/github.com/mrdulin/grpc-go-cnode)

A Go gRPC server for [CNode](https://cnodejs.org) community built on the top of [RESTful API](https://cnodejs.org/api).
*This project is just for teaching, NOT production ready.*
After modifying the `.proto` files, need to re-compile protocol buffers.
It will generate the service interfaces, models for the server side and service interfaces for client side.
Then, you can implement the interfaces of the services.
Features:
* HTTPs server and gRPC server share same listening address and port
* Print access logs in unary call interceptor
* gRPC Health check for entire server based on [GRPC Health Checking Protocol](https://github.com/grpc/grpc/blob/master/doc/health-checking.md)
* Per RPC call authentication, check [auth.go](./internal/utils/auth/auth.go)
* TLS connection with self-signed credentials
* Support constraint rules and validators for Protocol buffer, check [here](./internal/protobufs/user/service.proto)
* Server reflection, check [GRPC Server Reflection Protocol](https://github.com/grpc/grpc/blob/master/doc/server-reflection.md)
* Integration and unit testings
* Distributed trace with z-pages and stackdriver exporter
Compile protocol buffers:
```bash
make compile-protobuf
```
Don't support read environment variables from OS. Only support read environment variables from `configs/config.yaml`:
```yaml
BASE_URL: https://cnodejs.org/api/v1
PORT: 3000
ACCESS_TOKEN:
GRPC_GO_LOG_SEVERITY_LEVEL: info
GRPC_GO_LOG_VERBOSITY_LEVEL: 1
GOOGLE_CLOUD_PROJECT:
TRACE_ADMIN_CREDENTIAL_FILE:
```
Start the HTTPs server and gRPC server:
```bash
make start
```
Run integration testings:
1. Run `make start` to start the server
2. Run `make test-integration`
Run unit testings:
```bash
make test-unit
```
List all gRPC services using [grpcurl](https://github.com/fullstorydev/grpcurl), using `-insecure` flag to skip server certificate and domain verification.
```bash
☁ grpc-go-cnode [master] grpcurl -insecure localhost:3000 list
grpc.health.v1.Health
grpc.reflection.v1alpha.ServerReflection
topic.TopicService
user.UserService
```
Or using `-cacert` flag to use a file containing trusted root certificates for verifying the server.
```bash
☁ grpc-go-cnode [master] grpcurl -cacert=./assets/server.crt localhost:3000 list
grpc.health.v1.Health
grpc.reflection.v1alpha.ServerReflection
topic.TopicService
user.UserService
```
You will see traces and stats exported on the stdout. You can also see the z-pages provided from the server:
- Traces: http://localhost:8081/debug/tracez
- RPCs: http://localhost:8081/debug/rpcz
E.g. Server side gRPC server traces from z-pages:

Server side gPRC server trace from stackdriver trace:

More info, see [Makefile](./Makefile)