Remove unused legacy Agent RPC client wrapper
This commit is contained in:
@@ -111,6 +111,7 @@
|
||||
- HTTP 配置读取名称收敛:四份现行读取/发现 Go 文件改为 `snapshots`/`discovery` 的无代次路径,公开快照与 `ReadSIP`/`ReadTask`/`ReadTasks`/`ReadAllTasks` 只保留一套入口。原始 AI JSON、租户数字身份、五类 HTTP 路径及断连拒绝行为未改变;相关调用方和隔离测试同步更新。
|
||||
- Dispatcher 名称收敛:现行 `Current*` 调度、控制、发现、线路选择及执行类型/错误改为 `Runtime`、`Bootstrap`、`DiscoveryFollower` 等唯一代码入口;18 份 Go 源码/测试文件移除代次路径,相关 Agent 控制及调用方同步更新。任务归属、固定 SIP 快照、白名单/时段、额度和结果防重规则不变,现行隔离执行测试继续通过。
|
||||
- Agent 根命令不可达分支:删除旧执行模型的本地录音上传、手工重试、后台通知恢复和旧 Mock originate 代码及专属测试;根命令仍只注册获批的 Mock Agent/Dispatcher。当前录音 RPC、单次 PUT、失败保留和结果恢复另由现行隔离测试覆盖,删除旧命令不改变现有业务数据。
|
||||
- Agent RPC 客户端入口:删除没有现行调用者的旧 `Client`/`DialFromFiles` 包装及仅针对该包装的测试;当前命令仍通过部署提供的双向 TLS 配置建立 gRPC 连接,原证书信任、SAN 和握手回归测试保持不变。旧服务端业务 RPC 与 Proto 仍待后续清理。
|
||||
|
||||
## 验收台账
|
||||
|
||||
|
||||
@@ -1,92 +0,0 @@
|
||||
package rpc
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
agentpb "git.ipao.vip/rogee/go-sip/gen/agent"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/credentials"
|
||||
)
|
||||
|
||||
// Client is a thin generated-stub wrapper. Business retries and reconciliation
|
||||
// remain at the caller; this type never retries an originate automatically.
|
||||
type Client struct {
|
||||
Conn *grpc.ClientConn
|
||||
Agent agentpb.AgentControlServiceClient
|
||||
}
|
||||
|
||||
func Dial(endpoint string, tlsConfig *tls.Config) (*Client, error) {
|
||||
if endpoint == "" {
|
||||
return nil, fmt.Errorf("gRPC endpoint is required")
|
||||
}
|
||||
if tlsConfig == nil {
|
||||
return nil, fmt.Errorf("mTLS configuration is required")
|
||||
}
|
||||
conn, err := grpc.NewClient(endpoint, grpc.WithTransportCredentials(credentials.NewTLS(tlsConfig)))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("dial gRPC endpoint: %w", err)
|
||||
}
|
||||
return &Client{Conn: conn, Agent: agentpb.NewAgentControlServiceClient(conn)}, nil
|
||||
}
|
||||
|
||||
func DialFromFiles(endpoint, caFile, certFile, keyFile, serverName string) (*Client, error) {
|
||||
caPEM, err := readFile(caFile, "CA")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
certPEM, err := readFile(certFile, "certificate")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
keyPEM, err := readFile(keyFile, "key")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
tlsConfig, err := NewClientTLSConfig(caPEM, certPEM, keyPEM, serverName)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return Dial(endpoint, tlsConfig)
|
||||
}
|
||||
|
||||
func readFile(path, label string) ([]byte, error) {
|
||||
if path == "" {
|
||||
return nil, fmt.Errorf("%s file is required", label)
|
||||
}
|
||||
data, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("read %s file: %w", label, err)
|
||||
}
|
||||
return data, nil
|
||||
}
|
||||
|
||||
func (c *Client) ReportExecutionEvent(ctx context.Context, request *agentpb.ReportExecutionEventRequest) (*agentpb.ReportExecutionEventResponse, error) {
|
||||
if c == nil || c.Agent == nil {
|
||||
return nil, fmt.Errorf("AgentControl client is not initialized")
|
||||
}
|
||||
return c.Agent.ReportExecutionEvent(ctx, request)
|
||||
}
|
||||
|
||||
func (c *Client) RequestUpload(ctx context.Context, request *agentpb.RequestUploadRequest) (*agentpb.RequestUploadResponse, error) {
|
||||
if c == nil || c.Agent == nil {
|
||||
return nil, fmt.Errorf("AgentControl client is not initialized")
|
||||
}
|
||||
return c.Agent.RequestUpload(ctx, request)
|
||||
}
|
||||
|
||||
func (c *Client) CompleteUpload(ctx context.Context, request *agentpb.CompleteUploadRequest) (*agentpb.CompleteUploadResponse, error) {
|
||||
if c == nil || c.Agent == nil {
|
||||
return nil, fmt.Errorf("AgentControl client is not initialized")
|
||||
}
|
||||
return c.Agent.CompleteUpload(ctx, request)
|
||||
}
|
||||
|
||||
func (c *Client) Close() error {
|
||||
if c == nil || c.Conn == nil {
|
||||
return nil
|
||||
}
|
||||
return c.Conn.Close()
|
||||
}
|
||||
@@ -175,12 +175,6 @@ func TestTLSRotationRejectsPreviousClientCA(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestDialRequiresTLSConfig(t *testing.T) {
|
||||
if _, err := Dial("bufnet", nil); err == nil {
|
||||
t.Fatal("expected TLS configuration requirement")
|
||||
}
|
||||
}
|
||||
|
||||
func runTLSHandshake(t *testing.T, serverConfig, clientConfig *tls.Config) error {
|
||||
t.Helper()
|
||||
listener, err := tls.Listen("tcp", "127.0.0.1:0", serverConfig)
|
||||
|
||||
Reference in New Issue
Block a user