refactor: 重构trustlog-sdk目录结构到trustlog/go-trustlog

- 将所有trustlog-sdk文件移动到trustlog/go-trustlog/目录
- 更新README中所有import路径从trustlog-sdk改为go-trustlog
- 更新cookiecutter配置文件中的项目名称
- 更新根目录.lefthook.yml以引用新位置的配置
- 添加go.sum文件到版本控制
- 删除过时的示例文件

这次重构与trustlog-server保持一致的目录结构,
为未来支持多语言SDK(Python、Java等)预留空间。
This commit is contained in:
ryan
2025-12-22 13:37:57 +08:00
commit d313449c5c
87 changed files with 20622 additions and 0 deletions

View File

@@ -0,0 +1,172 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.5.1
// - protoc v3.21.12
// source: record.proto
package pb
import (
context "context"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
)
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
// Requires gRPC-Go v1.64.0 or later.
const _ = grpc.SupportPackageIsVersion9
const (
RecordValidationService_ListRecords_FullMethodName = "/record.RecordValidationService/ListRecords"
RecordValidationService_ValidateRecord_FullMethodName = "/record.RecordValidationService/ValidateRecord"
)
// RecordValidationServiceClient is the client API for RecordValidationService service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
//
// ======================== gRPC 服务定义 ========================
type RecordValidationServiceClient interface {
// 分页查询记录列表
ListRecords(ctx context.Context, in *ListRecordReq, opts ...grpc.CallOption) (*ListRecordRes, error)
// 单个记录验证,服务端流式返回验证进度与结果
ValidateRecord(ctx context.Context, in *RecordValidationReq, opts ...grpc.CallOption) (grpc.ServerStreamingClient[RecordValidationStreamRes], error)
}
type recordValidationServiceClient struct {
cc grpc.ClientConnInterface
}
func NewRecordValidationServiceClient(cc grpc.ClientConnInterface) RecordValidationServiceClient {
return &recordValidationServiceClient{cc}
}
func (c *recordValidationServiceClient) ListRecords(ctx context.Context, in *ListRecordReq, opts ...grpc.CallOption) (*ListRecordRes, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(ListRecordRes)
err := c.cc.Invoke(ctx, RecordValidationService_ListRecords_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *recordValidationServiceClient) ValidateRecord(ctx context.Context, in *RecordValidationReq, opts ...grpc.CallOption) (grpc.ServerStreamingClient[RecordValidationStreamRes], error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
stream, err := c.cc.NewStream(ctx, &RecordValidationService_ServiceDesc.Streams[0], RecordValidationService_ValidateRecord_FullMethodName, cOpts...)
if err != nil {
return nil, err
}
x := &grpc.GenericClientStream[RecordValidationReq, RecordValidationStreamRes]{ClientStream: stream}
if err := x.ClientStream.SendMsg(in); err != nil {
return nil, err
}
if err := x.ClientStream.CloseSend(); err != nil {
return nil, err
}
return x, nil
}
// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
type RecordValidationService_ValidateRecordClient = grpc.ServerStreamingClient[RecordValidationStreamRes]
// RecordValidationServiceServer is the server API for RecordValidationService service.
// All implementations must embed UnimplementedRecordValidationServiceServer
// for forward compatibility.
//
// ======================== gRPC 服务定义 ========================
type RecordValidationServiceServer interface {
// 分页查询记录列表
ListRecords(context.Context, *ListRecordReq) (*ListRecordRes, error)
// 单个记录验证,服务端流式返回验证进度与结果
ValidateRecord(*RecordValidationReq, grpc.ServerStreamingServer[RecordValidationStreamRes]) error
mustEmbedUnimplementedRecordValidationServiceServer()
}
// UnimplementedRecordValidationServiceServer must be embedded to have
// forward compatible implementations.
//
// NOTE: this should be embedded by value instead of pointer to avoid a nil
// pointer dereference when methods are called.
type UnimplementedRecordValidationServiceServer struct{}
func (UnimplementedRecordValidationServiceServer) ListRecords(context.Context, *ListRecordReq) (*ListRecordRes, error) {
return nil, status.Errorf(codes.Unimplemented, "method ListRecords not implemented")
}
func (UnimplementedRecordValidationServiceServer) ValidateRecord(*RecordValidationReq, grpc.ServerStreamingServer[RecordValidationStreamRes]) error {
return status.Errorf(codes.Unimplemented, "method ValidateRecord not implemented")
}
func (UnimplementedRecordValidationServiceServer) mustEmbedUnimplementedRecordValidationServiceServer() {
}
func (UnimplementedRecordValidationServiceServer) testEmbeddedByValue() {}
// UnsafeRecordValidationServiceServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to RecordValidationServiceServer will
// result in compilation errors.
type UnsafeRecordValidationServiceServer interface {
mustEmbedUnimplementedRecordValidationServiceServer()
}
func RegisterRecordValidationServiceServer(s grpc.ServiceRegistrar, srv RecordValidationServiceServer) {
// If the following call pancis, it indicates UnimplementedRecordValidationServiceServer was
// embedded by pointer and is nil. This will cause panics if an
// unimplemented method is ever invoked, so we test this at initialization
// time to prevent it from happening at runtime later due to I/O.
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
t.testEmbeddedByValue()
}
s.RegisterService(&RecordValidationService_ServiceDesc, srv)
}
func _RecordValidationService_ListRecords_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ListRecordReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(RecordValidationServiceServer).ListRecords(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: RecordValidationService_ListRecords_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(RecordValidationServiceServer).ListRecords(ctx, req.(*ListRecordReq))
}
return interceptor(ctx, in, info, handler)
}
func _RecordValidationService_ValidateRecord_Handler(srv interface{}, stream grpc.ServerStream) error {
m := new(RecordValidationReq)
if err := stream.RecvMsg(m); err != nil {
return err
}
return srv.(RecordValidationServiceServer).ValidateRecord(m, &grpc.GenericServerStream[RecordValidationReq, RecordValidationStreamRes]{ServerStream: stream})
}
// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
type RecordValidationService_ValidateRecordServer = grpc.ServerStreamingServer[RecordValidationStreamRes]
// RecordValidationService_ServiceDesc is the grpc.ServiceDesc for RecordValidationService service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var RecordValidationService_ServiceDesc = grpc.ServiceDesc{
ServiceName: "record.RecordValidationService",
HandlerType: (*RecordValidationServiceServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "ListRecords",
Handler: _RecordValidationService_ListRecords_Handler,
},
},
Streams: []grpc.StreamDesc{
{
StreamName: "ValidateRecord",
Handler: _RecordValidationService_ValidateRecord_Handler,
ServerStreams: true,
},
},
Metadata: "record.proto",
}