directory
Version:
v0.0.2
Opens a new window with list of versions in this module.
Published: Jan 22, 2025
License: GPL-3.0
Opens a new window with license information.
README
¶
API definitions
.
├── *.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
How to add new endpoint
.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:
cd ./api
buf generate
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/
- 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
Directories
¶
gen
|
|
grpc/go
Package pb is a reverse proxy.
|
Package pb is a reverse proxy. |
Click to show internal directories.
Click to hide internal directories.