diff --git a/internal/tests/grpc_test.go b/internal/tests/grpc_test.go deleted file mode 100644 index 1a80e5c2..00000000 --- a/internal/tests/grpc_test.go +++ /dev/null @@ -1,153 +0,0 @@ -package tests - -import ( - "context" - "encoding/json" - "github.com/TeaOSLab/EdgeAPI/internal/rpc/services" - pb "github.com/TeaOSLab/EdgeAPI/internal/tests/helloworld" - pb2 "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" - "google.golang.org/grpc" - "google.golang.org/grpc/credentials" - "google.golang.org/grpc/credentials/insecure" - "google.golang.org/grpc/metadata" - "log" - "net" - "runtime" - "strings" - "testing" - "time" -) - -type server struct { -} - -func (this *server) SayHello(ctx context.Context, request *pb.HelloRequest) (*pb.HelloReply, error) { - md, ok := metadata.FromIncomingContext(ctx) - if ok { - jsonData, _ := json.MarshalIndent(md, "", " ") - log.Print(string(jsonData)) - - _ = md - } - - return &pb.HelloReply{ - Message: "Hello, " + request.Name, - }, nil -} - -func TestTCPServer(t *testing.T) { - listener, err := net.Listen("tcp", ":8001") - if err != nil { - t.Fatal(err) - } - - s := grpc.NewServer() - pb.RegisterGreeterServer(s, &server{}) - pb2.RegisterNodeServiceServer(s, &services.NodeService{}) - - err = s.Serve(listener) - if err != nil { - t.Fatal(err) - } -} - -func TestTCPClient(t *testing.T) { - conn, err := grpc.Dial("127.0.0.1:8001", grpc.WithTransportCredentials(insecure.NewCredentials())) - if err != nil { - t.Fatal(err) - } - defer func() { - _ = conn.Close() - }() - - c := pb.NewGreeterClient(conn) - - before := time.Now() - - ctx := context.Background() - ctx = metadata.AppendToOutgoingContext(ctx, "name", "liu", "age", "20") - reply, err := c.SayHello(ctx, &pb.HelloRequest{ - Name: strings.Repeat("golang", 1), - }) - if err != nil { - t.Fatal(err) - } - t.Log(reply.Message) - t.Log(time.Since(before).Seconds()*1000, "ms") -} - -func TestTLSServer(t *testing.T) { - listener, err := net.Listen("tcp", ":8001") - if err != nil { - t.Fatal(err) - } - - tlsCred, err := credentials.NewServerTLSFromFile("test.pem", "test.key") - if err != nil { - t.Fatal(err) - } - - s := grpc.NewServer(grpc.Creds(tlsCred)) - pb.RegisterGreeterServer(s, &server{}) - err = s.Serve(listener) - if err != nil { - t.Fatal(err) - } -} - -func TestTLSClient(t *testing.T) { - tlsCred, err := credentials.NewClientTLSFromFile("test.pem", "www.hisock.cn") - if err != nil { - t.Fatal(err) - } - - conn, err := grpc.Dial("127.0.0.1:8001", grpc.WithTransportCredentials(tlsCred)) - if err != nil { - t.Fatal(err) - } - defer func() { - _ = conn.Close() - }() - - c := pb.NewGreeterClient(conn) - - before := time.Now() - - ctx := context.Background() - ctx = metadata.AppendToOutgoingContext(ctx, "name", "liu") - reply, err := c.SayHello(ctx, &pb.HelloRequest{ - Name: strings.Repeat("golang", 1), - }) - if err != nil { - t.Fatal(err) - } - t.Log(reply.Message) - t.Log(time.Since(before).Seconds()*1000, "ms") -} - -func BenchmarkClient(b *testing.B) { - runtime.GOMAXPROCS(1) - - tlsCred, err := credentials.NewClientTLSFromFile("test.pem", "www.hisock.cn") - if err != nil { - b.Fatal(err) - } - conn, err := grpc.Dial("127.0.0.1:8001", grpc.WithTransportCredentials(tlsCred)) - if err != nil { - b.Fatal(err) - } - defer func() { - _ = conn.Close() - }() - - c := pb.NewGreeterClient(conn) - - for i := 0; i < b.N; i++ { - ctx := context.Background() - ctx = metadata.AppendToOutgoingContext(ctx, "name", "liu") - reply, err := c.SayHello(ctx, &pb.HelloRequest{ - Name: "golang", - }) - _, _ = reply, err - } -} diff --git a/internal/tests/hello_service.proto b/internal/tests/hello_service.proto deleted file mode 100644 index b6dcc147..00000000 --- a/internal/tests/hello_service.proto +++ /dev/null @@ -1,45 +0,0 @@ -syntax = "proto3"; - -option go_package = "./helloworld"; - -service Greeter { - rpc SayHello (HelloRequest) returns (HelloReply) { - } -} - -message HelloRequest { - string name = 100; - int32 page_number = 101; - repeated int32 ages = 102; -} - -message HelloReply { - string message = 1; -} - -message SearchResult { - string query = 1; - int32 page_number = 2; - int32 result_per_page = 3; - - enum Corpus { - option allow_alias = true; - - UNIVERSAL = 0; - WEB = 1; - IMAGES = 2; - RUNNING = 2; - } - - Corpus corpus = 4; - SearchResponse result = 5; - map resultMap = 6; -} - -message SearchResponse { - reserved 1 to 15; - - int32 count = 16; - bool isOk = 17; - bytes padding = 18; -} \ No newline at end of file diff --git a/internal/tests/helloworld/hello_service.pb.go b/internal/tests/helloworld/hello_service.pb.go deleted file mode 100644 index 4fa0ca5a..00000000 --- a/internal/tests/helloworld/hello_service.pb.go +++ /dev/null @@ -1,584 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.25.0 -// protoc v3.12.3 -// source: hello_service.proto - -package helloworld - -import ( - context "context" - proto "github.com/golang/protobuf/proto" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -// This is a compile-time assertion that a sufficiently up-to-date version -// of the legacy proto package is being used. -const _ = proto.ProtoPackageIsVersion4 - -type SearchResult_Corpus int32 - -const ( - SearchResult_UNIVERSAL SearchResult_Corpus = 0 - SearchResult_WEB SearchResult_Corpus = 1 - SearchResult_IMAGES SearchResult_Corpus = 2 - SearchResult_RUNNING SearchResult_Corpus = 2 -) - -// Enum value maps for SearchResult_Corpus. -var ( - SearchResult_Corpus_name = map[int32]string{ - 0: "UNIVERSAL", - 1: "WEB", - 2: "IMAGES", - // Duplicate value: 2: "RUNNING", - } - SearchResult_Corpus_value = map[string]int32{ - "UNIVERSAL": 0, - "WEB": 1, - "IMAGES": 2, - "RUNNING": 2, - } -) - -func (x SearchResult_Corpus) Enum() *SearchResult_Corpus { - p := new(SearchResult_Corpus) - *p = x - return p -} - -func (x SearchResult_Corpus) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (SearchResult_Corpus) Descriptor() protoreflect.EnumDescriptor { - return file_hello_service_proto_enumTypes[0].Descriptor() -} - -func (SearchResult_Corpus) Type() protoreflect.EnumType { - return &file_hello_service_proto_enumTypes[0] -} - -func (x SearchResult_Corpus) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use SearchResult_Corpus.Descriptor instead. -func (SearchResult_Corpus) EnumDescriptor() ([]byte, []int) { - return file_hello_service_proto_rawDescGZIP(), []int{2, 0} -} - -type HelloRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Name string `protobuf:"bytes,100,opt,name=name,proto3" json:"name,omitempty"` - PageNumber int32 `protobuf:"varint,101,opt,name=page_number,json=pageNumber,proto3" json:"page_number,omitempty"` - Ages []int32 `protobuf:"varint,102,rep,packed,name=ages,proto3" json:"ages,omitempty"` -} - -func (x *HelloRequest) Reset() { - *x = HelloRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_hello_service_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *HelloRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*HelloRequest) ProtoMessage() {} - -func (x *HelloRequest) ProtoReflect() protoreflect.Message { - mi := &file_hello_service_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use HelloRequest.ProtoReflect.Descriptor instead. -func (*HelloRequest) Descriptor() ([]byte, []int) { - return file_hello_service_proto_rawDescGZIP(), []int{0} -} - -func (x *HelloRequest) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -func (x *HelloRequest) GetPageNumber() int32 { - if x != nil { - return x.PageNumber - } - return 0 -} - -func (x *HelloRequest) GetAges() []int32 { - if x != nil { - return x.Ages - } - return nil -} - -type HelloReply struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` -} - -func (x *HelloReply) Reset() { - *x = HelloReply{} - if protoimpl.UnsafeEnabled { - mi := &file_hello_service_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *HelloReply) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*HelloReply) ProtoMessage() {} - -func (x *HelloReply) ProtoReflect() protoreflect.Message { - mi := &file_hello_service_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use HelloReply.ProtoReflect.Descriptor instead. -func (*HelloReply) Descriptor() ([]byte, []int) { - return file_hello_service_proto_rawDescGZIP(), []int{1} -} - -func (x *HelloReply) GetMessage() string { - if x != nil { - return x.Message - } - return "" -} - -type SearchResult struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Query string `protobuf:"bytes,1,opt,name=query,proto3" json:"query,omitempty"` - PageNumber int32 `protobuf:"varint,2,opt,name=page_number,json=pageNumber,proto3" json:"page_number,omitempty"` - ResultPerPage int32 `protobuf:"varint,3,opt,name=result_per_page,json=resultPerPage,proto3" json:"result_per_page,omitempty"` - Corpus SearchResult_Corpus `protobuf:"varint,4,opt,name=corpus,proto3,enum=SearchResult_Corpus" json:"corpus,omitempty"` - Result *SearchResponse `protobuf:"bytes,5,opt,name=result,proto3" json:"result,omitempty"` - ResultMap map[string]*SearchResponse `protobuf:"bytes,6,rep,name=resultMap,proto3" json:"resultMap,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` -} - -func (x *SearchResult) Reset() { - *x = SearchResult{} - if protoimpl.UnsafeEnabled { - mi := &file_hello_service_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *SearchResult) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*SearchResult) ProtoMessage() {} - -func (x *SearchResult) ProtoReflect() protoreflect.Message { - mi := &file_hello_service_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use SearchResult.ProtoReflect.Descriptor instead. -func (*SearchResult) Descriptor() ([]byte, []int) { - return file_hello_service_proto_rawDescGZIP(), []int{2} -} - -func (x *SearchResult) GetQuery() string { - if x != nil { - return x.Query - } - return "" -} - -func (x *SearchResult) GetPageNumber() int32 { - if x != nil { - return x.PageNumber - } - return 0 -} - -func (x *SearchResult) GetResultPerPage() int32 { - if x != nil { - return x.ResultPerPage - } - return 0 -} - -func (x *SearchResult) GetCorpus() SearchResult_Corpus { - if x != nil { - return x.Corpus - } - return SearchResult_UNIVERSAL -} - -func (x *SearchResult) GetResult() *SearchResponse { - if x != nil { - return x.Result - } - return nil -} - -func (x *SearchResult) GetResultMap() map[string]*SearchResponse { - if x != nil { - return x.ResultMap - } - return nil -} - -type SearchResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Count int32 `protobuf:"varint,16,opt,name=count,proto3" json:"count,omitempty"` - IsOk bool `protobuf:"varint,17,opt,name=isOk,proto3" json:"isOk,omitempty"` - Padding []byte `protobuf:"bytes,18,opt,name=padding,proto3" json:"padding,omitempty"` -} - -func (x *SearchResponse) Reset() { - *x = SearchResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_hello_service_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *SearchResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*SearchResponse) ProtoMessage() {} - -func (x *SearchResponse) ProtoReflect() protoreflect.Message { - mi := &file_hello_service_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use SearchResponse.ProtoReflect.Descriptor instead. -func (*SearchResponse) Descriptor() ([]byte, []int) { - return file_hello_service_proto_rawDescGZIP(), []int{3} -} - -func (x *SearchResponse) GetCount() int32 { - if x != nil { - return x.Count - } - return 0 -} - -func (x *SearchResponse) GetIsOk() bool { - if x != nil { - return x.IsOk - } - return false -} - -func (x *SearchResponse) GetPadding() []byte { - if x != nil { - return x.Padding - } - return nil -} - -var File_hello_service_proto protoreflect.FileDescriptor - -var file_hello_service_proto_rawDesc = []byte{ - 0x0a, 0x13, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x57, 0x0a, 0x0c, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x64, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x70, 0x61, 0x67, - 0x65, 0x5f, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x65, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, - 0x70, 0x61, 0x67, 0x65, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x61, 0x67, - 0x65, 0x73, 0x18, 0x66, 0x20, 0x03, 0x28, 0x05, 0x52, 0x04, 0x61, 0x67, 0x65, 0x73, 0x22, 0x26, - 0x0a, 0x0a, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x18, 0x0a, 0x07, - 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, - 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x8e, 0x03, 0x0a, 0x0c, 0x53, 0x65, 0x61, 0x72, 0x63, - 0x68, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x71, 0x75, 0x65, 0x72, 0x79, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x71, 0x75, 0x65, 0x72, 0x79, 0x12, 0x1f, 0x0a, - 0x0b, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x05, 0x52, 0x0a, 0x70, 0x61, 0x67, 0x65, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x26, - 0x0a, 0x0f, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x5f, 0x70, 0x65, 0x72, 0x5f, 0x70, 0x61, 0x67, - 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0d, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x50, - 0x65, 0x72, 0x50, 0x61, 0x67, 0x65, 0x12, 0x2c, 0x0a, 0x06, 0x63, 0x6f, 0x72, 0x70, 0x75, 0x73, - 0x18, 0x04, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x14, 0x2e, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x52, - 0x65, 0x73, 0x75, 0x6c, 0x74, 0x2e, 0x43, 0x6f, 0x72, 0x70, 0x75, 0x73, 0x52, 0x06, 0x63, 0x6f, - 0x72, 0x70, 0x75, 0x73, 0x12, 0x27, 0x0a, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, 0x05, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x52, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x3a, 0x0a, - 0x09, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x4d, 0x61, 0x70, 0x18, 0x06, 0x20, 0x03, 0x28, 0x0b, - 0x32, 0x1c, 0x2e, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x2e, - 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x4d, 0x61, 0x70, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x09, - 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x4d, 0x61, 0x70, 0x1a, 0x4d, 0x0a, 0x0e, 0x52, 0x65, 0x73, - 0x75, 0x6c, 0x74, 0x4d, 0x61, 0x70, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, - 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x25, 0x0a, - 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x53, - 0x65, 0x61, 0x72, 0x63, 0x68, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x52, 0x05, 0x76, - 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x3d, 0x0a, 0x06, 0x43, 0x6f, 0x72, 0x70, - 0x75, 0x73, 0x12, 0x0d, 0x0a, 0x09, 0x55, 0x4e, 0x49, 0x56, 0x45, 0x52, 0x53, 0x41, 0x4c, 0x10, - 0x00, 0x12, 0x07, 0x0a, 0x03, 0x57, 0x45, 0x42, 0x10, 0x01, 0x12, 0x0a, 0x0a, 0x06, 0x49, 0x4d, - 0x41, 0x47, 0x45, 0x53, 0x10, 0x02, 0x12, 0x0b, 0x0a, 0x07, 0x52, 0x55, 0x4e, 0x4e, 0x49, 0x4e, - 0x47, 0x10, 0x02, 0x1a, 0x02, 0x10, 0x01, 0x22, 0x5a, 0x0a, 0x0e, 0x53, 0x65, 0x61, 0x72, 0x63, - 0x68, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x6f, 0x75, - 0x6e, 0x74, 0x18, 0x10, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, - 0x12, 0x0a, 0x04, 0x69, 0x73, 0x4f, 0x6b, 0x18, 0x11, 0x20, 0x01, 0x28, 0x08, 0x52, 0x04, 0x69, - 0x73, 0x4f, 0x6b, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x18, 0x12, - 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x70, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x4a, 0x04, 0x08, - 0x01, 0x10, 0x10, 0x32, 0x33, 0x0a, 0x07, 0x47, 0x72, 0x65, 0x65, 0x74, 0x65, 0x72, 0x12, 0x28, - 0x0a, 0x08, 0x53, 0x61, 0x79, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x12, 0x0d, 0x2e, 0x48, 0x65, 0x6c, - 0x6c, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0b, 0x2e, 0x48, 0x65, 0x6c, 0x6c, - 0x6f, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x42, 0x0e, 0x5a, 0x0c, 0x2e, 0x2f, 0x68, 0x65, - 0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_hello_service_proto_rawDescOnce sync.Once - file_hello_service_proto_rawDescData = file_hello_service_proto_rawDesc -) - -func file_hello_service_proto_rawDescGZIP() []byte { - file_hello_service_proto_rawDescOnce.Do(func() { - file_hello_service_proto_rawDescData = protoimpl.X.CompressGZIP(file_hello_service_proto_rawDescData) - }) - return file_hello_service_proto_rawDescData -} - -var file_hello_service_proto_enumTypes = make([]protoimpl.EnumInfo, 1) -var file_hello_service_proto_msgTypes = make([]protoimpl.MessageInfo, 5) -var file_hello_service_proto_goTypes = []interface{}{ - (SearchResult_Corpus)(0), // 0: SearchResult.Corpus - (*HelloRequest)(nil), // 1: HelloRequest - (*HelloReply)(nil), // 2: HelloReply - (*SearchResult)(nil), // 3: SearchResult - (*SearchResponse)(nil), // 4: SearchResponse - nil, // 5: SearchResult.ResultMapEntry -} -var file_hello_service_proto_depIdxs = []int32{ - 0, // 0: SearchResult.corpus:type_name -> SearchResult.Corpus - 4, // 1: SearchResult.result:type_name -> SearchResponse - 5, // 2: SearchResult.resultMap:type_name -> SearchResult.ResultMapEntry - 4, // 3: SearchResult.ResultMapEntry.value:type_name -> SearchResponse - 1, // 4: Greeter.SayHello:input_type -> HelloRequest - 2, // 5: Greeter.SayHello:output_type -> HelloReply - 5, // [5:6] is the sub-list for method output_type - 4, // [4:5] is the sub-list for method input_type - 4, // [4:4] is the sub-list for extension type_name - 4, // [4:4] is the sub-list for extension extendee - 0, // [0:4] is the sub-list for field type_name -} - -func init() { file_hello_service_proto_init() } -func file_hello_service_proto_init() { - if File_hello_service_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_hello_service_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*HelloRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_hello_service_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*HelloReply); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_hello_service_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*SearchResult); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_hello_service_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*SearchResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_hello_service_proto_rawDesc, - NumEnums: 1, - NumMessages: 5, - NumExtensions: 0, - NumServices: 1, - }, - GoTypes: file_hello_service_proto_goTypes, - DependencyIndexes: file_hello_service_proto_depIdxs, - EnumInfos: file_hello_service_proto_enumTypes, - MessageInfos: file_hello_service_proto_msgTypes, - }.Build() - File_hello_service_proto = out.File - file_hello_service_proto_rawDesc = nil - file_hello_service_proto_goTypes = nil - file_hello_service_proto_depIdxs = nil -} - -// Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConnInterface - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion6 - -// GreeterClient is the client API for Greeter service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type GreeterClient interface { - SayHello(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*HelloReply, error) -} - -type greeterClient struct { - cc grpc.ClientConnInterface -} - -func NewGreeterClient(cc grpc.ClientConnInterface) GreeterClient { - return &greeterClient{cc} -} - -func (c *greeterClient) SayHello(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*HelloReply, error) { - out := new(HelloReply) - err := c.cc.Invoke(ctx, "/Greeter/SayHello", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// GreeterServer is the server API for Greeter service. -type GreeterServer interface { - SayHello(context.Context, *HelloRequest) (*HelloReply, error) -} - -// UnimplementedGreeterServer can be embedded to have forward compatible implementations. -type UnimplementedGreeterServer struct { -} - -func (*UnimplementedGreeterServer) SayHello(context.Context, *HelloRequest) (*HelloReply, error) { - return nil, status.Errorf(codes.Unimplemented, "method SayHello not implemented") -} - -func RegisterGreeterServer(s *grpc.Server, srv GreeterServer) { - s.RegisterService(&_Greeter_serviceDesc, srv) -} - -func _Greeter_SayHello_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(HelloRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(GreeterServer).SayHello(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/Greeter/SayHello", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(GreeterServer).SayHello(ctx, req.(*HelloRequest)) - } - return interceptor(ctx, in, info, handler) -} - -var _Greeter_serviceDesc = grpc.ServiceDesc{ - ServiceName: "Greeter", - HandlerType: (*GreeterServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "SayHello", - Handler: _Greeter_SayHello_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "hello_service.proto", -} diff --git a/internal/tests/helper_test.go b/internal/tests/helper_test.go deleted file mode 100644 index 5370f3ca..00000000 --- a/internal/tests/helper_test.go +++ /dev/null @@ -1,20 +0,0 @@ -package tests - -import ( - "github.com/iwind/TeaGo/rands" - "math" - "net/url" - "testing" -) - -func TestRandString(t *testing.T) { - t.Log(rands.HexString(32)) -} - -func TestCharset(t *testing.T) { - t.Log(url.QueryEscape("中文")) -} - -func TestInt(t *testing.T) { - t.Log(math.MaxInt64) -} \ No newline at end of file diff --git a/internal/tests/test.key b/internal/tests/test.key deleted file mode 100644 index 4ef8ca19..00000000 --- a/internal/tests/test.key +++ /dev/null @@ -1,27 +0,0 @@ ------BEGIN RSA PRIVATE KEY----- -MIIEpAIBAAKCAQEAyGF004EdKgfzTOzE52+0GRLbnrT/40AcxTG2KWd4wwdANltP -zX5NmUlH3mDJQtcLS9FzFwsIUGa3vCDCFL+b9GtM5695boykzj731amVVrv86yIL -jsYk3CtFMuEEIn7qoxfYl/P/4IJOeQN6z/yodAHYGR8QRGnjqfo6ZtPOUheo6QN/ -8O2n176KsQ67lU/854oxjFZmzAgD1gnwCxVupwQkcNB7hkKW8dhEHR9oAGnEbZnJ -vPHqftwfMMDZ/0RIwIN31g17MNREC30VLEfPqIL6+a9S77yBXvTEIGSvdKetAe68 -4KJFgLw9EBeAk320buec+IW2cYVc2ZFTt+Y9kQIDAQABAoIBAQCqu17vV3Oh/GQx -hwu+pk6tjoPSFiZxWo8o9dJgNOmQQv1TUzoLvTIhCW9S6uSRLulREIUffSb4Wozy -nna/dwNKnqJIRhsRNoS1trE0O+oinMpDDh8K54lAjx3G3DLJsZn6nLbPwfajNGPo -eC6MSJq/PVMDFJSnthFlIu/f7Vg+WKf9jLhuRiBaAU/7PWMAo2XQ3e9/U0+4jbRY -bkNd3txE/o6eaVU9TpVw8j+nFQz5AAPLiprc72OobscMdThuB7SqRZSxBtJD7e6c -Pj71Uh6sJyeku9Gzhmc3dDGH3MqR82bXpDxZK0Vbee859VHITtA296zMCERfYviX -l1SNiA6BAoGBAO5Ie+nn1mnRKT9gtvOwt9uV/Fx2wz50Ff5x/w1Yc60LBOqKfUPz -Yb1FshUXsr4GIYkPtaB5aygwkc7EA6DT8bBrnfRxHet6Lvrs0eo3BCQQ0WuSkILs -vnLGrCqVUYH35tHVQeSCzZD5zKAiTxMZ8P+wkXxHPL8O4tn0Nj3uN5gzAoGBANdH -iBJ21Sh1oZJVta4U+j8Burjt857ToSCmV1aJ/AGzo+LFWnZVPqfLgjz9HTRnE995 -/hk9Bj4ph5DZnHxYXEPk1yQURMglQp1trwEOtnLTYDHltfZgxeSlp5+ThKSLSVMg -41PnZ7XRBnMsZ7H/Me4UH2O4OvRE931+Jjc22J8rAoGAf6p0QZFGTrGS4PMHcq8n -As5sRHoZB5gYxJf9KABREdCKlMMYdFSs9ESoMibdTHRqeU3iaRVEtWa4aEibDQsh -Pf2axoHonuZ6z1Qc79kELfKY0YLYTF1deI87ZSFVZ0YT9C7HPBBc5SUBXnajWT+X -4NaQTD66rD7kihQPD8VXIgMCgYAQFSf1OStzelY3uG96MdcAHgD1D9HDa8v9xG+B -540ME3+K0XOQo42qu2lfZQlpgMnbSCHTgNuWiUO3bopiP7ek2tO3vkvlJ+NyH1+T -lKXMrj3hfGe7oD8odbewFDU0lbNEopBZFFCLJLJ2qDqW8ZmpT5eIu5qr5PsYRPRV -66MDQQKBgQDlD6s/IuO4qcYUqMrCPNylrLum0sPhilKPco17rA2noPSN3ZUMuOmM -pdPr7A2fSD0DlQBerqYR9xU5IBoFy6d4ydgg2l9yEV4Kfst6Uk4Wt2gGeK4g23D9 -rF8QXWiC0WxZrVvcZGjkkC+V7+h6N2Inx7B/Tm4fx34S4gceTc96TQ== ------END RSA PRIVATE KEY----- diff --git a/internal/tests/test.pem b/internal/tests/test.pem deleted file mode 100644 index 7e3512c5..00000000 --- a/internal/tests/test.pem +++ /dev/null @@ -1,59 +0,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