后端: 1.阶段 6 memory 服务化 CP1-CP3 落地 - 新增 cmd/memory 独立进程入口,落地 services/memory dao/rpc/sv 与 memory zrpc pb - 将 memory.extract.requested outbox 消费与 memory worker 迁入 cmd/memory,单体 worker 不再消费 memory outbox - 新增 gateway/client/memory、shared/contracts/memory 和 shared/ports memory port - 将 /api/v1/memory/items* HTTP 管理面切到 memory zrpc,gateway 只保留鉴权、限流、幂等、参数绑定和响应透传 - 新增 memory Retrieve RPC,并将 agent 主链路 memory reader 切到 memory zrpc 读取 - 补充 agent memory RPC reader 适配器,保留注入侧 observer / metrics 观测能力 - 保留旧 backend/memory 核心实现作为迁移期复用与回退面,cmd/memory 内部继续复用既有 Module / ReadService 逻辑 - 补充 memory.rpc 示例配置,更新单体 outbox 发布边界与 memory handler 注释口径
182 lines
8.1 KiB
Go
182 lines
8.1 KiB
Go
package pb
|
|
|
|
import (
|
|
context "context"
|
|
|
|
grpc "google.golang.org/grpc"
|
|
codes "google.golang.org/grpc/codes"
|
|
status "google.golang.org/grpc/status"
|
|
)
|
|
|
|
const (
|
|
Memory_Ping_FullMethodName = "/smartflow.memory.Memory/Ping"
|
|
Memory_Retrieve_FullMethodName = "/smartflow.memory.Memory/Retrieve"
|
|
Memory_ListItems_FullMethodName = "/smartflow.memory.Memory/ListItems"
|
|
Memory_GetItem_FullMethodName = "/smartflow.memory.Memory/GetItem"
|
|
Memory_CreateItem_FullMethodName = "/smartflow.memory.Memory/CreateItem"
|
|
Memory_UpdateItem_FullMethodName = "/smartflow.memory.Memory/UpdateItem"
|
|
Memory_DeleteItem_FullMethodName = "/smartflow.memory.Memory/DeleteItem"
|
|
Memory_RestoreItem_FullMethodName = "/smartflow.memory.Memory/RestoreItem"
|
|
)
|
|
|
|
type MemoryClient interface {
|
|
Ping(ctx context.Context, in *StatusResponse, opts ...grpc.CallOption) (*StatusResponse, error)
|
|
Retrieve(ctx context.Context, in *JSONRequest, opts ...grpc.CallOption) (*JSONResponse, error)
|
|
ListItems(ctx context.Context, in *JSONRequest, opts ...grpc.CallOption) (*JSONResponse, error)
|
|
GetItem(ctx context.Context, in *JSONRequest, opts ...grpc.CallOption) (*JSONResponse, error)
|
|
CreateItem(ctx context.Context, in *JSONRequest, opts ...grpc.CallOption) (*JSONResponse, error)
|
|
UpdateItem(ctx context.Context, in *JSONRequest, opts ...grpc.CallOption) (*JSONResponse, error)
|
|
DeleteItem(ctx context.Context, in *JSONRequest, opts ...grpc.CallOption) (*JSONResponse, error)
|
|
RestoreItem(ctx context.Context, in *JSONRequest, opts ...grpc.CallOption) (*JSONResponse, error)
|
|
}
|
|
|
|
type memoryClient struct {
|
|
cc grpc.ClientConnInterface
|
|
}
|
|
|
|
func NewMemoryClient(cc grpc.ClientConnInterface) MemoryClient {
|
|
return &memoryClient{cc}
|
|
}
|
|
|
|
func (c *memoryClient) Ping(ctx context.Context, in *StatusResponse, opts ...grpc.CallOption) (*StatusResponse, error) {
|
|
out := new(StatusResponse)
|
|
err := c.cc.Invoke(ctx, Memory_Ping_FullMethodName, in, out, opts...)
|
|
return out, err
|
|
}
|
|
|
|
func (c *memoryClient) Retrieve(ctx context.Context, in *JSONRequest, opts ...grpc.CallOption) (*JSONResponse, error) {
|
|
out := new(JSONResponse)
|
|
err := c.cc.Invoke(ctx, Memory_Retrieve_FullMethodName, in, out, opts...)
|
|
return out, err
|
|
}
|
|
|
|
func (c *memoryClient) ListItems(ctx context.Context, in *JSONRequest, opts ...grpc.CallOption) (*JSONResponse, error) {
|
|
out := new(JSONResponse)
|
|
err := c.cc.Invoke(ctx, Memory_ListItems_FullMethodName, in, out, opts...)
|
|
return out, err
|
|
}
|
|
|
|
func (c *memoryClient) GetItem(ctx context.Context, in *JSONRequest, opts ...grpc.CallOption) (*JSONResponse, error) {
|
|
out := new(JSONResponse)
|
|
err := c.cc.Invoke(ctx, Memory_GetItem_FullMethodName, in, out, opts...)
|
|
return out, err
|
|
}
|
|
|
|
func (c *memoryClient) CreateItem(ctx context.Context, in *JSONRequest, opts ...grpc.CallOption) (*JSONResponse, error) {
|
|
out := new(JSONResponse)
|
|
err := c.cc.Invoke(ctx, Memory_CreateItem_FullMethodName, in, out, opts...)
|
|
return out, err
|
|
}
|
|
|
|
func (c *memoryClient) UpdateItem(ctx context.Context, in *JSONRequest, opts ...grpc.CallOption) (*JSONResponse, error) {
|
|
out := new(JSONResponse)
|
|
err := c.cc.Invoke(ctx, Memory_UpdateItem_FullMethodName, in, out, opts...)
|
|
return out, err
|
|
}
|
|
|
|
func (c *memoryClient) DeleteItem(ctx context.Context, in *JSONRequest, opts ...grpc.CallOption) (*JSONResponse, error) {
|
|
out := new(JSONResponse)
|
|
err := c.cc.Invoke(ctx, Memory_DeleteItem_FullMethodName, in, out, opts...)
|
|
return out, err
|
|
}
|
|
|
|
func (c *memoryClient) RestoreItem(ctx context.Context, in *JSONRequest, opts ...grpc.CallOption) (*JSONResponse, error) {
|
|
out := new(JSONResponse)
|
|
err := c.cc.Invoke(ctx, Memory_RestoreItem_FullMethodName, in, out, opts...)
|
|
return out, err
|
|
}
|
|
|
|
type MemoryServer interface {
|
|
Ping(context.Context, *StatusResponse) (*StatusResponse, error)
|
|
Retrieve(context.Context, *JSONRequest) (*JSONResponse, error)
|
|
ListItems(context.Context, *JSONRequest) (*JSONResponse, error)
|
|
GetItem(context.Context, *JSONRequest) (*JSONResponse, error)
|
|
CreateItem(context.Context, *JSONRequest) (*JSONResponse, error)
|
|
UpdateItem(context.Context, *JSONRequest) (*JSONResponse, error)
|
|
DeleteItem(context.Context, *JSONRequest) (*JSONResponse, error)
|
|
RestoreItem(context.Context, *JSONRequest) (*JSONResponse, error)
|
|
}
|
|
|
|
type UnimplementedMemoryServer struct{}
|
|
|
|
func (UnimplementedMemoryServer) Ping(context.Context, *StatusResponse) (*StatusResponse, error) {
|
|
return nil, status.Errorf(codes.Unimplemented, "method Ping not implemented")
|
|
}
|
|
func (UnimplementedMemoryServer) Retrieve(context.Context, *JSONRequest) (*JSONResponse, error) {
|
|
return nil, status.Errorf(codes.Unimplemented, "method Retrieve not implemented")
|
|
}
|
|
func (UnimplementedMemoryServer) ListItems(context.Context, *JSONRequest) (*JSONResponse, error) {
|
|
return nil, status.Errorf(codes.Unimplemented, "method ListItems not implemented")
|
|
}
|
|
func (UnimplementedMemoryServer) GetItem(context.Context, *JSONRequest) (*JSONResponse, error) {
|
|
return nil, status.Errorf(codes.Unimplemented, "method GetItem not implemented")
|
|
}
|
|
func (UnimplementedMemoryServer) CreateItem(context.Context, *JSONRequest) (*JSONResponse, error) {
|
|
return nil, status.Errorf(codes.Unimplemented, "method CreateItem not implemented")
|
|
}
|
|
func (UnimplementedMemoryServer) UpdateItem(context.Context, *JSONRequest) (*JSONResponse, error) {
|
|
return nil, status.Errorf(codes.Unimplemented, "method UpdateItem not implemented")
|
|
}
|
|
func (UnimplementedMemoryServer) DeleteItem(context.Context, *JSONRequest) (*JSONResponse, error) {
|
|
return nil, status.Errorf(codes.Unimplemented, "method DeleteItem not implemented")
|
|
}
|
|
func (UnimplementedMemoryServer) RestoreItem(context.Context, *JSONRequest) (*JSONResponse, error) {
|
|
return nil, status.Errorf(codes.Unimplemented, "method RestoreItem not implemented")
|
|
}
|
|
|
|
func RegisterMemoryServer(s grpc.ServiceRegistrar, srv MemoryServer) {
|
|
s.RegisterService(&Memory_ServiceDesc, srv)
|
|
}
|
|
|
|
func _Memory_Ping_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
|
in := new(StatusResponse)
|
|
if err := dec(in); err != nil {
|
|
return nil, err
|
|
}
|
|
if interceptor == nil {
|
|
return srv.(MemoryServer).Ping(ctx, in)
|
|
}
|
|
info := &grpc.UnaryServerInfo{
|
|
Server: srv,
|
|
FullMethod: Memory_Ping_FullMethodName,
|
|
}
|
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
|
return srv.(MemoryServer).Ping(ctx, req.(*StatusResponse))
|
|
}
|
|
return interceptor(ctx, in, info, handler)
|
|
}
|
|
|
|
func _Memory_JSON_Handler(fullMethod string, invoke func(MemoryServer, context.Context, *JSONRequest) (*JSONResponse, error)) grpc.MethodHandler {
|
|
return func(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
|
in := new(JSONRequest)
|
|
if err := dec(in); err != nil {
|
|
return nil, err
|
|
}
|
|
if interceptor == nil {
|
|
return invoke(srv.(MemoryServer), ctx, in)
|
|
}
|
|
info := &grpc.UnaryServerInfo{Server: srv, FullMethod: fullMethod}
|
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
|
return invoke(srv.(MemoryServer), ctx, req.(*JSONRequest))
|
|
}
|
|
return interceptor(ctx, in, info, handler)
|
|
}
|
|
}
|
|
|
|
var Memory_ServiceDesc = grpc.ServiceDesc{
|
|
ServiceName: "smartflow.memory.Memory",
|
|
HandlerType: (*MemoryServer)(nil),
|
|
Methods: []grpc.MethodDesc{
|
|
{MethodName: "Ping", Handler: _Memory_Ping_Handler},
|
|
{MethodName: "Retrieve", Handler: _Memory_JSON_Handler(Memory_Retrieve_FullMethodName, MemoryServer.Retrieve)},
|
|
{MethodName: "ListItems", Handler: _Memory_JSON_Handler(Memory_ListItems_FullMethodName, MemoryServer.ListItems)},
|
|
{MethodName: "GetItem", Handler: _Memory_JSON_Handler(Memory_GetItem_FullMethodName, MemoryServer.GetItem)},
|
|
{MethodName: "CreateItem", Handler: _Memory_JSON_Handler(Memory_CreateItem_FullMethodName, MemoryServer.CreateItem)},
|
|
{MethodName: "UpdateItem", Handler: _Memory_JSON_Handler(Memory_UpdateItem_FullMethodName, MemoryServer.UpdateItem)},
|
|
{MethodName: "DeleteItem", Handler: _Memory_JSON_Handler(Memory_DeleteItem_FullMethodName, MemoryServer.DeleteItem)},
|
|
{MethodName: "RestoreItem", Handler: _Memory_JSON_Handler(Memory_RestoreItem_FullMethodName, MemoryServer.RestoreItem)},
|
|
},
|
|
Streams: []grpc.StreamDesc{},
|
|
Metadata: "services/memory/rpc/memory.proto",
|
|
}
|