Skip to content

Commit d79417f

Browse files
committed
chore: 清理 gRPC 死配置与死产物——传输层早已迁移自研 TCP
全仓扫描 gRPC 残留(决策文档/OTLP 外部协议/否决声明属合法 引用),清理四处死配置与一处过时文案: - buf.gen.yaml / proto/buf.gen.yaml / sdks/go/buf.gen.yaml: 移除 buf.build/grpc/go 与 grpc/python 插件——从未产生被使用 的产物(pkg/pb 与 sdks/*/generated 零 grpc 引用) - make proto 同步清出 10 个 python *_pb2_grpc.py 死产物 (无任何 import 引用) - 删除 sdks/go/scripts/generate_proto.go(gRPC 代码生成脚本, make proto 已走 buf);Makefile 移除无效的 -DENABLE_GRPC=ON (CMake 早已删掉该选项)与 agent help 过时的 'http+grpc' 文案 - 重写 sdks/go/PROTO_GENERATION.md('Mock/Real gRPC mode' 双模 型早已废弃)为 buf 现状说明 - protoc-gen-croupier 描述文案 'gRPC method' → 'proto method' 验证:make proto 全绿、go build ./... 通过、生成产物无 grpc 引用;go.mod 的 google.golang.org/grpc indirect 为依赖链残留 (transport-no-grpc.md 允许,定期评估移除)。
1 parent 1b61423 commit d79417f

18 files changed

Lines changed: 23 additions & 515 deletions

File tree

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ build-sdks: build-sdks-cpp build-sdks-go
139139

140140
build-sdks-cpp:
141141
@echo "[sdks] building C++ SDK..."
142-
@cd sdks/cpp && cmake -B build -DCMAKE_BUILD_TYPE=Release -DENABLE_GRPC=ON
142+
@cd sdks/cpp && cmake -B build -DCMAKE_BUILD_TYPE=Release
143143
@cd sdks/cpp && cmake --build build --parallel
144144

145145
build-sdks-go:
@@ -225,7 +225,7 @@ help:
225225
@echo ""
226226
@echo "Server Targets:"
227227
@echo " server - Build croupier-server"
228-
@echo " agent - Build croupier-agent (http+grpc core)"
228+
@echo " agent - Build croupier-agent (http + TCP transport core)"
229229
@echo ""
230230
@echo "SDK Targets:"
231231
@echo " build-sdks - Build all SDKs (C++, Go)"

buf.gen.yaml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,9 @@ plugins:
55
out: pkg/pb
66
opt:
77
- paths=source_relative
8-
- remote: buf.build/grpc/go:v1.5.1
9-
out: pkg/pb
10-
opt:
11-
- paths=source_relative
12-
- require_unimplemented_servers=false
138
# C++ plugin for SDK (使用 v34.1 对应 protobuf 34.x)
149
- remote: buf.build/protocolbuffers/cpp:v34.1
1510
out: sdks/cpp/generated
1611
# Python plugin for SDK (使用固定版本 v25.1 对应 protobuf 4.25.x)
1712
- remote: buf.build/protocolbuffers/python:v25.1
1813
out: sdks/python/generated
19-
- remote: buf.build/grpc/python:v1.71.0
20-
out: sdks/python/generated

proto/buf.gen.yaml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,3 @@ plugins:
44
out: pkg/pb
55
opt:
66
- paths=source_relative
7-
- remote: buf.build/grpc/go:v1.5.1
8-
out: pkg/pb
9-
opt:
10-
- paths=source_relative
11-
- require_unimplemented_servers=false

sdks/go/Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ build: proto
2424
@echo "Building SDK..."
2525
go build ./...
2626

27-
# Generate proto files from project root
27+
# Generate proto files from project root (buf 流程,与主仓库一致;
28+
# gRPC 插件已移除——内部传输为自研 TCP + protobuf)
2829
proto:
29-
@echo "Generating gRPC code from project proto/ directory..."
30-
@echo "Using fixed version plugins: protoc-gen-go@v1.36.11, protoc-gen-go-grpc@v1.5.1"
31-
go run scripts/generate_proto.go
30+
@echo "Generating protobuf code via buf (no gRPC plugins)..."
31+
cd .. && buf generate sdks/go/buf.gen.yaml
3232

3333
# Check if dependencies for proto generation are installed
3434
check-deps:

sdks/go/PROTO_GENERATION.md

Lines changed: 16 additions & 219 deletions
Original file line numberDiff line numberDiff line change
@@ -1,233 +1,30 @@
11
# Proto Generation Guide
22

3-
This document explains how to generate gRPC code from protobuf files for the Croupier Go SDK.
3+
Croupier 内部 RPC 不使用 gRPC([传输层决策](../../docs/architecture/transport-no-grpc.md)):Server ↔ Agent ↔ SDK 走自研 TCP transport(length-prefix framing)+ protobuf 消息。本文档说明 Go SDK 的 protobuf 代码生成流程。
44

5-
## Overview
5+
## 生成方式(buf,与主仓库一致)
66

7-
The Go SDK can operate in two modes:
8-
1. **Mock mode** - Uses mock gRPC implementation (default, no dependencies required)
9-
2. **Real gRPC mode** - Uses generated gRPC code (requires proto generation)
7+
统一使用 buf 远程插件生成,**只生成 protobuf 消息代码,不生成 gRPC 代码**
108

11-
## Quick Start
12-
13-
### Option 1: Use Mock Mode (Easiest)
14-
15-
No setup required! The SDK automatically uses mock gRPC implementation:
16-
17-
```bash
18-
go run examples/basic/main.go
19-
```
20-
21-
### Option 2: Use Real gRPC
22-
23-
#### Step 1: Install Dependencies
24-
25-
**macOS:**
26-
```bash
27-
brew install protobuf
28-
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
29-
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
30-
```
31-
32-
**Ubuntu/Debian:**
33-
```bash
34-
sudo apt-get install protobuf-compiler
35-
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
36-
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
37-
```
38-
39-
**Other systems:**
40-
Download protoc from [GitHub releases](https://github.com/protocolbuffers/protobuf/releases)
41-
42-
#### Step 2: Generate gRPC Code
43-
44-
```bash
45-
# Using the convenient script
46-
./generate_proto.sh
47-
48-
# Or using Makefile
49-
make proto
50-
51-
# Or directly with Go
52-
go run scripts/generate_proto.go
53-
```
54-
55-
#### Step 3: Build with Real gRPC
56-
57-
```bash
58-
# Using Makefile
59-
make build-with-grpc
60-
61-
# Or with go build
62-
go build -tags=croupier_real_grpc ./...
63-
64-
# Run examples
65-
make example
66-
```
67-
68-
## Advanced Usage
69-
70-
### Custom Proto Branch
71-
72-
To generate from a different branch:
73-
74-
```bash
75-
./generate_proto.sh --branch develop
76-
# or
77-
CROUPIER_PROTO_BRANCH=develop ./generate_proto.sh
78-
```
79-
80-
### Skip Proto Generation
81-
82-
If you have previously generated proto files and want to skip regeneration:
83-
84-
```bash
85-
./generate_proto.sh --skip
86-
# or
87-
CROUPIER_SKIP_PROTO_GEN=1 ./generate_proto.sh
88-
```
89-
90-
### Verbose Output
91-
92-
For detailed output during generation:
93-
94-
```bash
95-
./generate_proto.sh --verbose
96-
```
97-
98-
## Using the Makefile
99-
100-
The Makefile provides convenient targets:
101-
102-
```bash
103-
# Build with mock gRPC (default)
104-
make build
105-
106-
# Build with real gRPC (generates proto first)
107-
make build-with-grpc
108-
109-
# Only generate proto files
110-
make proto
111-
112-
# Check if dependencies are installed
113-
make check-deps
114-
115-
# Install dependencies automatically
116-
make install-deps
117-
118-
# Run tests
119-
make test
120-
121-
# Run comprehensive example
122-
make example
123-
124-
# Clean generated files
125-
make clean
126-
127-
# Show build information
128-
make info
129-
```
130-
131-
## Environment Variables
132-
133-
- `CROUPIER_SKIP_PROTO_GEN`: Set to 1 to skip proto generation
134-
- `CROUPIER_PROTO_BRANCH`: Specify proto branch (default: main)
135-
- `CROUPIER_CI_BUILD`: Set to 1 to enable CI mode (strict error checking)
136-
137-
## Build Tags
138-
139-
The generated gRPC code is protected by the build tag `croupier_real_grpc`. This means:
140-
141-
- Without the tag: Mock implementation is used
142-
- With the tag: Real gRPC implementation is used
143-
144-
Example:
1459
```bash
146-
# Mock implementation
147-
go build ./...
148-
149-
# Real gRPC implementation
150-
go build -tags=croupier_real_grpc ./...
151-
```
10+
# 在仓库根目录
11+
make proto # 主仓库 pkg/pb(transport/agent/SDK 契约消息)
12+
make pack # pack artifacts(protoc-gen-croupier)
15213

153-
## Directory Structure
154-
155-
```
156-
.
157-
├── downloaded_proto/ # Downloaded proto files (temporary)
158-
├── proto/ # Generated Go code
159-
│ ├── build_tags.go # Build tag indicator
160-
│ ├── croupier/ # Generated packages
161-
│ └── google/ # Generated Google APIs
162-
├── scripts/
163-
│ └── generate_proto.go # Proto generation script
164-
└── generate_proto.sh # Convenience wrapper script
14+
# Go SDK 单独生成(sdks/go/pkg/pb)
15+
cd sdks/go && make proto
16516
```
16617

167-
## Troubleshooting
18+
`sdks/go/buf.gen.yaml` 固定插件版本(与主仓库 CI 一致):
16819

169-
### protoc not found
170-
171-
Install protoc:
172-
```bash
173-
# macOS
174-
brew install protobuf
175-
176-
# Ubuntu
177-
sudo apt-get install protobuf-compiler
178-
```
179-
180-
### Go protoc plugins not found
181-
182-
Install the plugins:
183-
```bash
184-
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
185-
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
186-
```
187-
188-
Make sure `$GOPATH/bin` is in your `$PATH`.
189-
190-
### proto download failed
191-
192-
Check your internet connection and branch name:
193-
```bash
194-
./generate_proto.sh --branch main --verbose
195-
```
196-
197-
### Generated code conflicts
198-
199-
Clean and regenerate:
200-
```bash
201-
make clean
202-
make proto
203-
```
204-
205-
## CI Integration
206-
207-
In CI environments, set `CROUPIER_CI_BUILD=1` to enable strict error checking:
208-
209-
```yaml
210-
- name: Generate proto
211-
run: |
212-
export CROUPIER_CI_BUILD=1
213-
make proto
214-
make build-with-grpc
215-
```
20+
- `buf.build/protocolbuffers/go:v1.36.11` —— protobuf 消息代码
21621

217-
## Difference Between Mock and Real gRPC
22+
## 约束
21823

219-
| Feature | Mock Mode | Real gRPC Mode |
220-
|---------|-----------|---------------|
221-
| Dependencies | None | protoc, Go plugins |
222-
| Network calls | Simulated | Real gRPC |
223-
| Performance | Faster | Slower (real calls) |
224-
| Testing | Good for unit tests | Integration tests |
225-
| Production use | No | Yes |
24+
- **不要引入 `protoc-gen-go-grpc` / `buf.build/grpc/*` 插件**——历史上配置过但从未产生被使用的产物,已移除。
25+
- 本地 `protoc` 版本与 buf 远程插件不匹配会生成不兼容代码,一律走 buf。
26+
- 生成的代码在 `sdks/go/pkg/pb/`(git 跟踪),只有 proto 契约变更时才需要重新生成。
22627

227-
## Best Practices
28+
## 历史说明
22829

229-
1. **Development**: Use mock mode for faster iteration
230-
2. **Testing**: Use mock mode for unit tests
231-
3. **Integration**: Use real gRPC for integration tests
232-
4. **Production**: Always use real gRPC
233-
5. **CI**: Enable strict mode with `CROUPIER_CI_BUILD=1`
30+
早期 SDK 文档描述过 "Mock gRPC mode / Real gRPC mode" 双模式与 `generate_proto.sh` 脚本——该模型已随 gRPC 移除而废弃,脚本已删除。

sdks/go/buf.gen.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,3 @@ plugins:
1010
out: sdks/go/pkg/pb
1111
opt:
1212
- paths=source_relative
13-
- remote: buf.build/grpc/go:v1.5.1
14-
out: sdks/go/pkg/pb
15-
opt:
16-
- paths=source_relative

0 commit comments

Comments
 (0)