.
├── *.proto # gRPC service definitions
├── buf.gen.yaml # buf plugins config
├── buf.yaml # buf dependecies
├── http.yaml # mapping gRPC->HTTP endpoints
├── gen # autogenerated:
│ └── grpc
│ └── go
│ ├── *.pb.go # generated go gRPC clients
│ ├── *_grpc.pb.go # generated go gRPC server endpoints stubs
│ └── *.pb.gw.go # generated go HTTP wrappers for gRPC server endpoints
└── openapi
└── ceph-api.swagger.json # genrated openapi spec
.proto
files from api/
directory are the single source of truth for API definition.
- To add new endpoint to existing service edit corresponding proto file, or add a new proto file with a new service definition.
- To generate REST endpoint for defined rpc method, add mapping to api/http.yaml. GRPC gateway library is used to generate and serve REST API from gRPC.
- Run buf command from
api/
directory:The command will generate: go code stubs for gRPC and HTTP endpoints and go gRPC client in api/gen/grpc/go/, and openapi spec in api/openapi/cd ./api buf generate
- Implement go stub for API handler in pkg/api/
- In case of introducing new gRPC service (not adding new endpoint to existing service), register it in pkg/api/grpc_server.go and http handlers in pkg/api/grpc_http_gateway.go