From 822ad3856ba923516cc8fc71d8f223ceb5543904 Mon Sep 17 00:00:00 2001 From: alimy Date: Tue, 15 Apr 2025 19:40:27 +0800 Subject: [PATCH] remove connect style service/server base code --- Makefile | 5 +- .../core/v1/corev1connect/auth.connect.go | 173 --------------- .../greet/v1/greetv1connect/greet.connect.go | 112 ---------- auto/rpc/core/v1/auth.pb.go | 197 ++++++------------ auto/rpc/core/v1/auth_grpc.pb.go | 34 ++- auto/rpc/greet/v1/greet.pb.go | 107 +++------- auto/rpc/greet/v1/greet_grpc.pb.go | 28 ++- buf.gen.yaml | 3 - go.mod | 1 - go.sum | 2 - internal/servants/servants.go | 9 - internal/servants/triplet/auth.go | 17 -- internal/servants/triplet/triplet.go | 16 -- internal/service/connect_server.go | 67 ------ internal/service/connect_service.go | 32 --- internal/service/server.go | 8 +- internal/service/triplet.go | 51 ----- 17 files changed, 138 insertions(+), 724 deletions(-) delete mode 100644 auto/connect/core/v1/corev1connect/auth.connect.go delete mode 100644 auto/connect/greet/v1/greetv1connect/greet.connect.go delete mode 100644 internal/servants/triplet/auth.go delete mode 100644 internal/servants/triplet/triplet.go delete mode 100644 internal/service/connect_server.go delete mode 100644 internal/service/connect_service.go delete mode 100644 internal/service/triplet.go diff --git a/Makefile b/Makefile index 54750941..5bdaf0d5 100644 --- a/Makefile +++ b/Makefile @@ -88,9 +88,9 @@ gen-mir: .PHONY: gen-rpc gen-rpc: - @rm -rf auto/rpc auto/connect + @rm -rf auto/rpc @buf generate proto - @go fmt ./auto/rpc/... ./auto/connect/... + @go fmt ./auto/rpc/... .PHONY: proto-mod proto-mod: @@ -126,7 +126,6 @@ install-protobuf-plugins: @go install github.com/bufbuild/buf/cmd/buf@latest @go install github.com/bufbuild/buf/cmd/protoc-gen-buf-breaking@latest @go install github.com/bufbuild/buf/cmd/protoc-gen-buf-lint@latest - @go install connectrpc.com/connect/cmd/protoc-gen-connect-go@latest @go install github.com/fullstorydev/grpcurl/cmd/grpcurl@latest @go install google.golang.org/protobuf/cmd/protoc-gen-go@latest @go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest diff --git a/auto/connect/core/v1/corev1connect/auth.connect.go b/auto/connect/core/v1/corev1connect/auth.connect.go deleted file mode 100644 index 50c3d0f8..00000000 --- a/auto/connect/core/v1/corev1connect/auth.connect.go +++ /dev/null @@ -1,173 +0,0 @@ -// Code generated by protoc-gen-connect-go. DO NOT EDIT. -// -// Source: core/v1/auth.proto - -package corev1connect - -import ( - connect "connectrpc.com/connect" - context "context" - errors "errors" - v1 "github.com/rocboss/paopao-ce/auto/rpc/core/v1" - http "net/http" - strings "strings" -) - -// This is a compile-time assertion to ensure that this generated file and the connect package are -// compatible. If you get a compiler error that this constant is not defined, this code was -// generated with a version of connect newer than the one compiled into your binary. You can fix the -// problem by either regenerating this code with an older version of connect or updating the connect -// version compiled into your binary. -const _ = connect.IsAtLeastVersion1_13_0 - -const ( - // AuthenticateServiceName is the fully-qualified name of the AuthenticateService service. - AuthenticateServiceName = "core.v1.AuthenticateService" -) - -// These constants are the fully-qualified names of the RPCs defined in this package. They're -// exposed at runtime as Spec.Procedure and as the final two segments of the HTTP route. -// -// Note that these are different from the fully-qualified method names used by -// google.golang.org/protobuf/reflect/protoreflect. To convert from these constants to -// reflection-formatted method names, remove the leading slash and convert the remaining slash to a -// period. -const ( - // AuthenticateServicePreLoginProcedure is the fully-qualified name of the AuthenticateService's - // preLogin RPC. - AuthenticateServicePreLoginProcedure = "/core.v1.AuthenticateService/preLogin" - // AuthenticateServiceLoginProcedure is the fully-qualified name of the AuthenticateService's login - // RPC. - AuthenticateServiceLoginProcedure = "/core.v1.AuthenticateService/login" - // AuthenticateServiceLogoutProcedure is the fully-qualified name of the AuthenticateService's - // logout RPC. - AuthenticateServiceLogoutProcedure = "/core.v1.AuthenticateService/logout" -) - -// These variables are the protoreflect.Descriptor objects for the RPCs defined in this package. -var ( - authenticateServiceServiceDescriptor = v1.File_core_v1_auth_proto.Services().ByName("AuthenticateService") - authenticateServicePreLoginMethodDescriptor = authenticateServiceServiceDescriptor.Methods().ByName("preLogin") - authenticateServiceLoginMethodDescriptor = authenticateServiceServiceDescriptor.Methods().ByName("login") - authenticateServiceLogoutMethodDescriptor = authenticateServiceServiceDescriptor.Methods().ByName("logout") -) - -// AuthenticateServiceClient is a client for the core.v1.AuthenticateService service. -type AuthenticateServiceClient interface { - PreLogin(context.Context, *connect.Request[v1.User]) (*connect.Response[v1.ActionReply], error) - Login(context.Context, *connect.Request[v1.User]) (*connect.Response[v1.LoginReply], error) - Logout(context.Context, *connect.Request[v1.User]) (*connect.Response[v1.ActionReply], error) -} - -// NewAuthenticateServiceClient constructs a client for the core.v1.AuthenticateService service. By -// default, it uses the Connect protocol with the binary Protobuf Codec, asks for gzipped responses, -// and sends uncompressed requests. To use the gRPC or gRPC-Web protocols, supply the -// connect.WithGRPC() or connect.WithGRPCWeb() options. -// -// The URL supplied here should be the base URL for the Connect or gRPC server (for example, -// http://api.acme.com or https://acme.com/grpc). -func NewAuthenticateServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) AuthenticateServiceClient { - baseURL = strings.TrimRight(baseURL, "/") - return &authenticateServiceClient{ - preLogin: connect.NewClient[v1.User, v1.ActionReply]( - httpClient, - baseURL+AuthenticateServicePreLoginProcedure, - connect.WithSchema(authenticateServicePreLoginMethodDescriptor), - connect.WithClientOptions(opts...), - ), - login: connect.NewClient[v1.User, v1.LoginReply]( - httpClient, - baseURL+AuthenticateServiceLoginProcedure, - connect.WithSchema(authenticateServiceLoginMethodDescriptor), - connect.WithClientOptions(opts...), - ), - logout: connect.NewClient[v1.User, v1.ActionReply]( - httpClient, - baseURL+AuthenticateServiceLogoutProcedure, - connect.WithSchema(authenticateServiceLogoutMethodDescriptor), - connect.WithClientOptions(opts...), - ), - } -} - -// authenticateServiceClient implements AuthenticateServiceClient. -type authenticateServiceClient struct { - preLogin *connect.Client[v1.User, v1.ActionReply] - login *connect.Client[v1.User, v1.LoginReply] - logout *connect.Client[v1.User, v1.ActionReply] -} - -// PreLogin calls core.v1.AuthenticateService.preLogin. -func (c *authenticateServiceClient) PreLogin(ctx context.Context, req *connect.Request[v1.User]) (*connect.Response[v1.ActionReply], error) { - return c.preLogin.CallUnary(ctx, req) -} - -// Login calls core.v1.AuthenticateService.login. -func (c *authenticateServiceClient) Login(ctx context.Context, req *connect.Request[v1.User]) (*connect.Response[v1.LoginReply], error) { - return c.login.CallUnary(ctx, req) -} - -// Logout calls core.v1.AuthenticateService.logout. -func (c *authenticateServiceClient) Logout(ctx context.Context, req *connect.Request[v1.User]) (*connect.Response[v1.ActionReply], error) { - return c.logout.CallUnary(ctx, req) -} - -// AuthenticateServiceHandler is an implementation of the core.v1.AuthenticateService service. -type AuthenticateServiceHandler interface { - PreLogin(context.Context, *connect.Request[v1.User]) (*connect.Response[v1.ActionReply], error) - Login(context.Context, *connect.Request[v1.User]) (*connect.Response[v1.LoginReply], error) - Logout(context.Context, *connect.Request[v1.User]) (*connect.Response[v1.ActionReply], error) -} - -// NewAuthenticateServiceHandler builds an HTTP handler from the service implementation. It returns -// the path on which to mount the handler and the handler itself. -// -// By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf -// and JSON codecs. They also support gzip compression. -func NewAuthenticateServiceHandler(svc AuthenticateServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) { - authenticateServicePreLoginHandler := connect.NewUnaryHandler( - AuthenticateServicePreLoginProcedure, - svc.PreLogin, - connect.WithSchema(authenticateServicePreLoginMethodDescriptor), - connect.WithHandlerOptions(opts...), - ) - authenticateServiceLoginHandler := connect.NewUnaryHandler( - AuthenticateServiceLoginProcedure, - svc.Login, - connect.WithSchema(authenticateServiceLoginMethodDescriptor), - connect.WithHandlerOptions(opts...), - ) - authenticateServiceLogoutHandler := connect.NewUnaryHandler( - AuthenticateServiceLogoutProcedure, - svc.Logout, - connect.WithSchema(authenticateServiceLogoutMethodDescriptor), - connect.WithHandlerOptions(opts...), - ) - return "/core.v1.AuthenticateService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - switch r.URL.Path { - case AuthenticateServicePreLoginProcedure: - authenticateServicePreLoginHandler.ServeHTTP(w, r) - case AuthenticateServiceLoginProcedure: - authenticateServiceLoginHandler.ServeHTTP(w, r) - case AuthenticateServiceLogoutProcedure: - authenticateServiceLogoutHandler.ServeHTTP(w, r) - default: - http.NotFound(w, r) - } - }) -} - -// UnimplementedAuthenticateServiceHandler returns CodeUnimplemented from all methods. -type UnimplementedAuthenticateServiceHandler struct{} - -func (UnimplementedAuthenticateServiceHandler) PreLogin(context.Context, *connect.Request[v1.User]) (*connect.Response[v1.ActionReply], error) { - return nil, connect.NewError(connect.CodeUnimplemented, errors.New("core.v1.AuthenticateService.preLogin is not implemented")) -} - -func (UnimplementedAuthenticateServiceHandler) Login(context.Context, *connect.Request[v1.User]) (*connect.Response[v1.LoginReply], error) { - return nil, connect.NewError(connect.CodeUnimplemented, errors.New("core.v1.AuthenticateService.login is not implemented")) -} - -func (UnimplementedAuthenticateServiceHandler) Logout(context.Context, *connect.Request[v1.User]) (*connect.Response[v1.ActionReply], error) { - return nil, connect.NewError(connect.CodeUnimplemented, errors.New("core.v1.AuthenticateService.logout is not implemented")) -} diff --git a/auto/connect/greet/v1/greetv1connect/greet.connect.go b/auto/connect/greet/v1/greetv1connect/greet.connect.go deleted file mode 100644 index 59d26952..00000000 --- a/auto/connect/greet/v1/greetv1connect/greet.connect.go +++ /dev/null @@ -1,112 +0,0 @@ -// Code generated by protoc-gen-connect-go. DO NOT EDIT. -// -// Source: greet/v1/greet.proto - -package greetv1connect - -import ( - connect "connectrpc.com/connect" - context "context" - errors "errors" - v1 "github.com/rocboss/paopao-ce/auto/rpc/greet/v1" - http "net/http" - strings "strings" -) - -// This is a compile-time assertion to ensure that this generated file and the connect package are -// compatible. If you get a compiler error that this constant is not defined, this code was -// generated with a version of connect newer than the one compiled into your binary. You can fix the -// problem by either regenerating this code with an older version of connect or updating the connect -// version compiled into your binary. -const _ = connect.IsAtLeastVersion1_13_0 - -const ( - // GreetServiceName is the fully-qualified name of the GreetService service. - GreetServiceName = "greet.v1.GreetService" -) - -// These constants are the fully-qualified names of the RPCs defined in this package. They're -// exposed at runtime as Spec.Procedure and as the final two segments of the HTTP route. -// -// Note that these are different from the fully-qualified method names used by -// google.golang.org/protobuf/reflect/protoreflect. To convert from these constants to -// reflection-formatted method names, remove the leading slash and convert the remaining slash to a -// period. -const ( - // GreetServiceGreetProcedure is the fully-qualified name of the GreetService's Greet RPC. - GreetServiceGreetProcedure = "/greet.v1.GreetService/Greet" -) - -// These variables are the protoreflect.Descriptor objects for the RPCs defined in this package. -var ( - greetServiceServiceDescriptor = v1.File_greet_v1_greet_proto.Services().ByName("GreetService") - greetServiceGreetMethodDescriptor = greetServiceServiceDescriptor.Methods().ByName("Greet") -) - -// GreetServiceClient is a client for the greet.v1.GreetService service. -type GreetServiceClient interface { - Greet(context.Context, *connect.Request[v1.GreetRequest]) (*connect.Response[v1.GreetResponse], error) -} - -// NewGreetServiceClient constructs a client for the greet.v1.GreetService service. By default, it -// uses the Connect protocol with the binary Protobuf Codec, asks for gzipped responses, and sends -// uncompressed requests. To use the gRPC or gRPC-Web protocols, supply the connect.WithGRPC() or -// connect.WithGRPCWeb() options. -// -// The URL supplied here should be the base URL for the Connect or gRPC server (for example, -// http://api.acme.com or https://acme.com/grpc). -func NewGreetServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) GreetServiceClient { - baseURL = strings.TrimRight(baseURL, "/") - return &greetServiceClient{ - greet: connect.NewClient[v1.GreetRequest, v1.GreetResponse]( - httpClient, - baseURL+GreetServiceGreetProcedure, - connect.WithSchema(greetServiceGreetMethodDescriptor), - connect.WithClientOptions(opts...), - ), - } -} - -// greetServiceClient implements GreetServiceClient. -type greetServiceClient struct { - greet *connect.Client[v1.GreetRequest, v1.GreetResponse] -} - -// Greet calls greet.v1.GreetService.Greet. -func (c *greetServiceClient) Greet(ctx context.Context, req *connect.Request[v1.GreetRequest]) (*connect.Response[v1.GreetResponse], error) { - return c.greet.CallUnary(ctx, req) -} - -// GreetServiceHandler is an implementation of the greet.v1.GreetService service. -type GreetServiceHandler interface { - Greet(context.Context, *connect.Request[v1.GreetRequest]) (*connect.Response[v1.GreetResponse], error) -} - -// NewGreetServiceHandler builds an HTTP handler from the service implementation. It returns the -// path on which to mount the handler and the handler itself. -// -// By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf -// and JSON codecs. They also support gzip compression. -func NewGreetServiceHandler(svc GreetServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) { - greetServiceGreetHandler := connect.NewUnaryHandler( - GreetServiceGreetProcedure, - svc.Greet, - connect.WithSchema(greetServiceGreetMethodDescriptor), - connect.WithHandlerOptions(opts...), - ) - return "/greet.v1.GreetService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - switch r.URL.Path { - case GreetServiceGreetProcedure: - greetServiceGreetHandler.ServeHTTP(w, r) - default: - http.NotFound(w, r) - } - }) -} - -// UnimplementedGreetServiceHandler returns CodeUnimplemented from all methods. -type UnimplementedGreetServiceHandler struct{} - -func (UnimplementedGreetServiceHandler) Greet(context.Context, *connect.Request[v1.GreetRequest]) (*connect.Response[v1.GreetResponse], error) { - return nil, connect.NewError(connect.CodeUnimplemented, errors.New("greet.v1.GreetService.Greet is not implemented")) -} diff --git a/auto/rpc/core/v1/auth.pb.go b/auto/rpc/core/v1/auth.pb.go index d319130c..b5779cc4 100644 --- a/auto/rpc/core/v1/auth.pb.go +++ b/auto/rpc/core/v1/auth.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.32.0 +// protoc-gen-go v1.36.6 // protoc (unknown) // source: core/v1/auth.proto @@ -11,6 +11,7 @@ import ( protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" + unsafe "unsafe" ) const ( @@ -21,20 +22,17 @@ const ( ) type User struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + PhoneNum string `protobuf:"bytes,1,opt,name=phone_num,json=phoneNum,proto3" json:"phone_num,omitempty"` unknownFields protoimpl.UnknownFields - - PhoneNum string `protobuf:"bytes,1,opt,name=phone_num,json=phoneNum,proto3" json:"phone_num,omitempty"` + sizeCache protoimpl.SizeCache } func (x *User) Reset() { *x = User{} - if protoimpl.UnsafeEnabled { - mi := &file_core_v1_auth_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_core_v1_auth_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *User) String() string { @@ -45,7 +43,7 @@ func (*User) ProtoMessage() {} func (x *User) ProtoReflect() protoreflect.Message { mi := &file_core_v1_auth_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -68,21 +66,18 @@ func (x *User) GetPhoneNum() string { } type UserVerify struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - PhoneNum string `protobuf:"bytes,1,opt,name=phone_num,json=phoneNum,proto3" json:"phone_num,omitempty"` - VerificationCode string `protobuf:"bytes,2,opt,name=verification_code,json=verificationCode,proto3" json:"verification_code,omitempty"` + state protoimpl.MessageState `protogen:"open.v1"` + PhoneNum string `protobuf:"bytes,1,opt,name=phone_num,json=phoneNum,proto3" json:"phone_num,omitempty"` + VerificationCode string `protobuf:"bytes,2,opt,name=verification_code,json=verificationCode,proto3" json:"verification_code,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *UserVerify) Reset() { *x = UserVerify{} - if protoimpl.UnsafeEnabled { - mi := &file_core_v1_auth_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_core_v1_auth_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *UserVerify) String() string { @@ -93,7 +88,7 @@ func (*UserVerify) ProtoMessage() {} func (x *UserVerify) ProtoReflect() protoreflect.Message { mi := &file_core_v1_auth_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -123,21 +118,18 @@ func (x *UserVerify) GetVerificationCode() string { } type LoginReply struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + StatusCode int32 `protobuf:"varint,1,opt,name=status_code,json=statusCode,proto3" json:"status_code,omitempty"` + Token string `protobuf:"bytes,2,opt,name=token,proto3" json:"token,omitempty"` unknownFields protoimpl.UnknownFields - - StatusCode int32 `protobuf:"varint,1,opt,name=status_code,json=statusCode,proto3" json:"status_code,omitempty"` - Token string `protobuf:"bytes,2,opt,name=token,proto3" json:"token,omitempty"` + sizeCache protoimpl.SizeCache } func (x *LoginReply) Reset() { *x = LoginReply{} - if protoimpl.UnsafeEnabled { - mi := &file_core_v1_auth_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_core_v1_auth_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *LoginReply) String() string { @@ -148,7 +140,7 @@ func (*LoginReply) ProtoMessage() {} func (x *LoginReply) ProtoReflect() protoreflect.Message { mi := &file_core_v1_auth_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -178,20 +170,17 @@ func (x *LoginReply) GetToken() string { } type ActionReply struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + StatusCode int32 `protobuf:"varint,1,opt,name=status_code,json=statusCode,proto3" json:"status_code,omitempty"` unknownFields protoimpl.UnknownFields - - StatusCode int32 `protobuf:"varint,1,opt,name=status_code,json=statusCode,proto3" json:"status_code,omitempty"` + sizeCache protoimpl.SizeCache } func (x *ActionReply) Reset() { *x = ActionReply{} - if protoimpl.UnsafeEnabled { - mi := &file_core_v1_auth_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_core_v1_auth_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ActionReply) String() string { @@ -202,7 +191,7 @@ func (*ActionReply) ProtoMessage() {} func (x *ActionReply) ProtoReflect() protoreflect.Message { mi := &file_core_v1_auth_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -226,60 +215,43 @@ func (x *ActionReply) GetStatusCode() int32 { var File_core_v1_auth_proto protoreflect.FileDescriptor -var file_core_v1_auth_proto_rawDesc = []byte{ - 0x0a, 0x12, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x76, 0x31, 0x2f, 0x61, 0x75, 0x74, 0x68, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x07, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x22, 0x23, 0x0a, - 0x04, 0x55, 0x73, 0x65, 0x72, 0x12, 0x1b, 0x0a, 0x09, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x5f, 0x6e, - 0x75, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x4e, - 0x75, 0x6d, 0x22, 0x56, 0x0a, 0x0a, 0x55, 0x73, 0x65, 0x72, 0x56, 0x65, 0x72, 0x69, 0x66, 0x79, - 0x12, 0x1b, 0x0a, 0x09, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x5f, 0x6e, 0x75, 0x6d, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x4e, 0x75, 0x6d, 0x12, 0x2b, 0x0a, - 0x11, 0x76, 0x65, 0x72, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x63, 0x6f, - 0x64, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x10, 0x76, 0x65, 0x72, 0x69, 0x66, 0x69, - 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x43, 0x6f, 0x64, 0x65, 0x22, 0x43, 0x0a, 0x0a, 0x4c, 0x6f, - 0x67, 0x69, 0x6e, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x74, 0x61, 0x74, - 0x75, 0x73, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x73, - 0x74, 0x61, 0x74, 0x75, 0x73, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x6f, 0x6b, - 0x65, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x22, - 0x2e, 0x0a, 0x0b, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x1f, - 0x0a, 0x0b, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x05, 0x52, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x43, 0x6f, 0x64, 0x65, 0x32, - 0xa2, 0x01, 0x0a, 0x13, 0x41, 0x75, 0x74, 0x68, 0x65, 0x6e, 0x74, 0x69, 0x63, 0x61, 0x74, 0x65, - 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x2f, 0x0a, 0x08, 0x70, 0x72, 0x65, 0x4c, 0x6f, - 0x67, 0x69, 0x6e, 0x12, 0x0d, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x73, - 0x65, 0x72, 0x1a, 0x14, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x63, 0x74, - 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x2b, 0x0a, 0x05, 0x6c, 0x6f, 0x67, 0x69, - 0x6e, 0x12, 0x0d, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, - 0x1a, 0x13, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x6f, 0x67, 0x69, 0x6e, - 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x2d, 0x0a, 0x06, 0x6c, 0x6f, 0x67, 0x6f, 0x75, 0x74, 0x12, - 0x0d, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x1a, 0x14, - 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, - 0x65, 0x70, 0x6c, 0x79, 0x42, 0x8b, 0x01, 0x0a, 0x0b, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x72, - 0x65, 0x2e, 0x76, 0x31, 0x42, 0x09, 0x41, 0x75, 0x74, 0x68, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, - 0x01, 0x5a, 0x34, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x72, 0x6f, - 0x63, 0x62, 0x6f, 0x73, 0x73, 0x2f, 0x70, 0x61, 0x6f, 0x70, 0x61, 0x6f, 0x2d, 0x63, 0x65, 0x2f, - 0x61, 0x75, 0x74, 0x6f, 0x2f, 0x72, 0x70, 0x63, 0x2f, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x76, 0x31, - 0x3b, 0x63, 0x6f, 0x72, 0x65, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x58, 0x58, 0xaa, 0x02, 0x07, - 0x43, 0x6f, 0x72, 0x65, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x07, 0x43, 0x6f, 0x72, 0x65, 0x5c, 0x56, - 0x31, 0xe2, 0x02, 0x13, 0x43, 0x6f, 0x72, 0x65, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, - 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x08, 0x43, 0x6f, 0x72, 0x65, 0x3a, 0x3a, - 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} +const file_core_v1_auth_proto_rawDesc = "" + + "\n" + + "\x12core/v1/auth.proto\x12\acore.v1\"#\n" + + "\x04User\x12\x1b\n" + + "\tphone_num\x18\x01 \x01(\tR\bphoneNum\"V\n" + + "\n" + + "UserVerify\x12\x1b\n" + + "\tphone_num\x18\x01 \x01(\tR\bphoneNum\x12+\n" + + "\x11verification_code\x18\x02 \x01(\tR\x10verificationCode\"C\n" + + "\n" + + "LoginReply\x12\x1f\n" + + "\vstatus_code\x18\x01 \x01(\x05R\n" + + "statusCode\x12\x14\n" + + "\x05token\x18\x02 \x01(\tR\x05token\".\n" + + "\vActionReply\x12\x1f\n" + + "\vstatus_code\x18\x01 \x01(\x05R\n" + + "statusCode2\xa2\x01\n" + + "\x13AuthenticateService\x12/\n" + + "\bpreLogin\x12\r.core.v1.User\x1a\x14.core.v1.ActionReply\x12+\n" + + "\x05login\x12\r.core.v1.User\x1a\x13.core.v1.LoginReply\x12-\n" + + "\x06logout\x12\r.core.v1.User\x1a\x14.core.v1.ActionReplyB\x8b\x01\n" + + "\vcom.core.v1B\tAuthProtoP\x01Z4github.com/rocboss/paopao-ce/auto/rpc/core/v1;corev1\xa2\x02\x03CXX\xaa\x02\aCore.V1\xca\x02\aCore\\V1\xe2\x02\x13Core\\V1\\GPBMetadata\xea\x02\bCore::V1b\x06proto3" var ( file_core_v1_auth_proto_rawDescOnce sync.Once - file_core_v1_auth_proto_rawDescData = file_core_v1_auth_proto_rawDesc + file_core_v1_auth_proto_rawDescData []byte ) func file_core_v1_auth_proto_rawDescGZIP() []byte { file_core_v1_auth_proto_rawDescOnce.Do(func() { - file_core_v1_auth_proto_rawDescData = protoimpl.X.CompressGZIP(file_core_v1_auth_proto_rawDescData) + file_core_v1_auth_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_core_v1_auth_proto_rawDesc), len(file_core_v1_auth_proto_rawDesc))) }) return file_core_v1_auth_proto_rawDescData } var file_core_v1_auth_proto_msgTypes = make([]protoimpl.MessageInfo, 4) -var file_core_v1_auth_proto_goTypes = []interface{}{ +var file_core_v1_auth_proto_goTypes = []any{ (*User)(nil), // 0: core.v1.User (*UserVerify)(nil), // 1: core.v1.UserVerify (*LoginReply)(nil), // 2: core.v1.LoginReply @@ -304,61 +276,11 @@ func file_core_v1_auth_proto_init() { if File_core_v1_auth_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_core_v1_auth_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*User); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_core_v1_auth_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*UserVerify); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_core_v1_auth_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*LoginReply); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_core_v1_auth_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ActionReply); 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_core_v1_auth_proto_rawDesc, + RawDescriptor: unsafe.Slice(unsafe.StringData(file_core_v1_auth_proto_rawDesc), len(file_core_v1_auth_proto_rawDesc)), NumEnums: 0, NumMessages: 4, NumExtensions: 0, @@ -369,7 +291,6 @@ func file_core_v1_auth_proto_init() { MessageInfos: file_core_v1_auth_proto_msgTypes, }.Build() File_core_v1_auth_proto = out.File - file_core_v1_auth_proto_rawDesc = nil file_core_v1_auth_proto_goTypes = nil file_core_v1_auth_proto_depIdxs = nil } diff --git a/auto/rpc/core/v1/auth_grpc.pb.go b/auto/rpc/core/v1/auth_grpc.pb.go index 7cec3d85..ea3b07bf 100644 --- a/auto/rpc/core/v1/auth_grpc.pb.go +++ b/auto/rpc/core/v1/auth_grpc.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: -// - protoc-gen-go-grpc v1.3.0 +// - protoc-gen-go-grpc v1.5.1 // - protoc (unknown) // source: core/v1/auth.proto @@ -15,8 +15,8 @@ import ( // 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.32.0 or later. -const _ = grpc.SupportPackageIsVersion7 +// Requires gRPC-Go v1.64.0 or later. +const _ = grpc.SupportPackageIsVersion9 const ( AuthenticateService_PreLogin_FullMethodName = "/core.v1.AuthenticateService/preLogin" @@ -42,8 +42,9 @@ func NewAuthenticateServiceClient(cc grpc.ClientConnInterface) AuthenticateServi } func (c *authenticateServiceClient) PreLogin(ctx context.Context, in *User, opts ...grpc.CallOption) (*ActionReply, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(ActionReply) - err := c.cc.Invoke(ctx, AuthenticateService_PreLogin_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, AuthenticateService_PreLogin_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -51,8 +52,9 @@ func (c *authenticateServiceClient) PreLogin(ctx context.Context, in *User, opts } func (c *authenticateServiceClient) Login(ctx context.Context, in *User, opts ...grpc.CallOption) (*LoginReply, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(LoginReply) - err := c.cc.Invoke(ctx, AuthenticateService_Login_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, AuthenticateService_Login_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -60,8 +62,9 @@ func (c *authenticateServiceClient) Login(ctx context.Context, in *User, opts .. } func (c *authenticateServiceClient) Logout(ctx context.Context, in *User, opts ...grpc.CallOption) (*ActionReply, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(ActionReply) - err := c.cc.Invoke(ctx, AuthenticateService_Logout_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, AuthenticateService_Logout_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -70,7 +73,7 @@ func (c *authenticateServiceClient) Logout(ctx context.Context, in *User, opts . // AuthenticateServiceServer is the server API for AuthenticateService service. // All implementations must embed UnimplementedAuthenticateServiceServer -// for forward compatibility +// for forward compatibility. type AuthenticateServiceServer interface { PreLogin(context.Context, *User) (*ActionReply, error) Login(context.Context, *User) (*LoginReply, error) @@ -78,9 +81,12 @@ type AuthenticateServiceServer interface { mustEmbedUnimplementedAuthenticateServiceServer() } -// UnimplementedAuthenticateServiceServer must be embedded to have forward compatible implementations. -type UnimplementedAuthenticateServiceServer struct { -} +// UnimplementedAuthenticateServiceServer 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 UnimplementedAuthenticateServiceServer struct{} func (UnimplementedAuthenticateServiceServer) PreLogin(context.Context, *User) (*ActionReply, error) { return nil, status.Errorf(codes.Unimplemented, "method PreLogin not implemented") @@ -92,6 +98,7 @@ func (UnimplementedAuthenticateServiceServer) Logout(context.Context, *User) (*A return nil, status.Errorf(codes.Unimplemented, "method Logout not implemented") } func (UnimplementedAuthenticateServiceServer) mustEmbedUnimplementedAuthenticateServiceServer() {} +func (UnimplementedAuthenticateServiceServer) testEmbeddedByValue() {} // UnsafeAuthenticateServiceServer may be embedded to opt out of forward compatibility for this service. // Use of this interface is not recommended, as added methods to AuthenticateServiceServer will @@ -101,6 +108,13 @@ type UnsafeAuthenticateServiceServer interface { } func RegisterAuthenticateServiceServer(s grpc.ServiceRegistrar, srv AuthenticateServiceServer) { + // If the following call pancis, it indicates UnimplementedAuthenticateServiceServer 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(&AuthenticateService_ServiceDesc, srv) } diff --git a/auto/rpc/greet/v1/greet.pb.go b/auto/rpc/greet/v1/greet.pb.go index cd0e7fa0..ed3d3cce 100644 --- a/auto/rpc/greet/v1/greet.pb.go +++ b/auto/rpc/greet/v1/greet.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.32.0 +// protoc-gen-go v1.36.6 // protoc (unknown) // source: greet/v1/greet.proto @@ -11,6 +11,7 @@ import ( protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" + unsafe "unsafe" ) const ( @@ -21,20 +22,17 @@ const ( ) type GreetRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` unknownFields protoimpl.UnknownFields - - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + sizeCache protoimpl.SizeCache } func (x *GreetRequest) Reset() { *x = GreetRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_greet_v1_greet_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_greet_v1_greet_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *GreetRequest) String() string { @@ -45,7 +43,7 @@ func (*GreetRequest) ProtoMessage() {} func (x *GreetRequest) ProtoReflect() protoreflect.Message { mi := &file_greet_v1_greet_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -68,20 +66,17 @@ func (x *GreetRequest) GetName() string { } type GreetResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Greeting string `protobuf:"bytes,1,opt,name=greeting,proto3" json:"greeting,omitempty"` unknownFields protoimpl.UnknownFields - - Greeting string `protobuf:"bytes,1,opt,name=greeting,proto3" json:"greeting,omitempty"` + sizeCache protoimpl.SizeCache } func (x *GreetResponse) Reset() { *x = GreetResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_greet_v1_greet_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_greet_v1_greet_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *GreetResponse) String() string { @@ -92,7 +87,7 @@ func (*GreetResponse) ProtoMessage() {} func (x *GreetResponse) ProtoReflect() protoreflect.Message { mi := &file_greet_v1_greet_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -116,45 +111,32 @@ func (x *GreetResponse) GetGreeting() string { var File_greet_v1_greet_proto protoreflect.FileDescriptor -var file_greet_v1_greet_proto_rawDesc = []byte{ - 0x0a, 0x14, 0x67, 0x72, 0x65, 0x65, 0x74, 0x2f, 0x76, 0x31, 0x2f, 0x67, 0x72, 0x65, 0x65, 0x74, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x08, 0x67, 0x72, 0x65, 0x65, 0x74, 0x2e, 0x76, 0x31, - 0x22, 0x22, 0x0a, 0x0c, 0x47, 0x72, 0x65, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, - 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x2b, 0x0a, 0x0d, 0x47, 0x72, 0x65, 0x65, 0x74, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x67, 0x72, 0x65, 0x65, 0x74, 0x69, 0x6e, - 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x67, 0x72, 0x65, 0x65, 0x74, 0x69, 0x6e, - 0x67, 0x32, 0x4a, 0x0a, 0x0c, 0x47, 0x72, 0x65, 0x65, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x12, 0x3a, 0x0a, 0x05, 0x47, 0x72, 0x65, 0x65, 0x74, 0x12, 0x16, 0x2e, 0x67, 0x72, 0x65, - 0x65, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x72, 0x65, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x67, 0x72, 0x65, 0x65, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x72, - 0x65, 0x65, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x93, 0x01, - 0x0a, 0x0c, 0x63, 0x6f, 0x6d, 0x2e, 0x67, 0x72, 0x65, 0x65, 0x74, 0x2e, 0x76, 0x31, 0x42, 0x0a, - 0x47, 0x72, 0x65, 0x65, 0x74, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x36, 0x67, 0x69, - 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x72, 0x6f, 0x63, 0x62, 0x6f, 0x73, 0x73, - 0x2f, 0x70, 0x61, 0x6f, 0x70, 0x61, 0x6f, 0x2d, 0x63, 0x65, 0x2f, 0x61, 0x75, 0x74, 0x6f, 0x2f, - 0x72, 0x70, 0x63, 0x2f, 0x67, 0x72, 0x65, 0x65, 0x74, 0x2f, 0x76, 0x31, 0x3b, 0x67, 0x72, 0x65, - 0x65, 0x74, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x47, 0x58, 0x58, 0xaa, 0x02, 0x08, 0x47, 0x72, 0x65, - 0x65, 0x74, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x08, 0x47, 0x72, 0x65, 0x65, 0x74, 0x5c, 0x56, 0x31, - 0xe2, 0x02, 0x14, 0x47, 0x72, 0x65, 0x65, 0x74, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, - 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x09, 0x47, 0x72, 0x65, 0x65, 0x74, 0x3a, - 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} +const file_greet_v1_greet_proto_rawDesc = "" + + "\n" + + "\x14greet/v1/greet.proto\x12\bgreet.v1\"\"\n" + + "\fGreetRequest\x12\x12\n" + + "\x04name\x18\x01 \x01(\tR\x04name\"+\n" + + "\rGreetResponse\x12\x1a\n" + + "\bgreeting\x18\x01 \x01(\tR\bgreeting2J\n" + + "\fGreetService\x12:\n" + + "\x05Greet\x12\x16.greet.v1.GreetRequest\x1a\x17.greet.v1.GreetResponse\"\x00B\x93\x01\n" + + "\fcom.greet.v1B\n" + + "GreetProtoP\x01Z6github.com/rocboss/paopao-ce/auto/rpc/greet/v1;greetv1\xa2\x02\x03GXX\xaa\x02\bGreet.V1\xca\x02\bGreet\\V1\xe2\x02\x14Greet\\V1\\GPBMetadata\xea\x02\tGreet::V1b\x06proto3" var ( file_greet_v1_greet_proto_rawDescOnce sync.Once - file_greet_v1_greet_proto_rawDescData = file_greet_v1_greet_proto_rawDesc + file_greet_v1_greet_proto_rawDescData []byte ) func file_greet_v1_greet_proto_rawDescGZIP() []byte { file_greet_v1_greet_proto_rawDescOnce.Do(func() { - file_greet_v1_greet_proto_rawDescData = protoimpl.X.CompressGZIP(file_greet_v1_greet_proto_rawDescData) + file_greet_v1_greet_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_greet_v1_greet_proto_rawDesc), len(file_greet_v1_greet_proto_rawDesc))) }) return file_greet_v1_greet_proto_rawDescData } var file_greet_v1_greet_proto_msgTypes = make([]protoimpl.MessageInfo, 2) -var file_greet_v1_greet_proto_goTypes = []interface{}{ +var file_greet_v1_greet_proto_goTypes = []any{ (*GreetRequest)(nil), // 0: greet.v1.GreetRequest (*GreetResponse)(nil), // 1: greet.v1.GreetResponse } @@ -173,37 +155,11 @@ func file_greet_v1_greet_proto_init() { if File_greet_v1_greet_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_greet_v1_greet_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GreetRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_greet_v1_greet_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*GreetResponse); 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_greet_v1_greet_proto_rawDesc, + RawDescriptor: unsafe.Slice(unsafe.StringData(file_greet_v1_greet_proto_rawDesc), len(file_greet_v1_greet_proto_rawDesc)), NumEnums: 0, NumMessages: 2, NumExtensions: 0, @@ -214,7 +170,6 @@ func file_greet_v1_greet_proto_init() { MessageInfos: file_greet_v1_greet_proto_msgTypes, }.Build() File_greet_v1_greet_proto = out.File - file_greet_v1_greet_proto_rawDesc = nil file_greet_v1_greet_proto_goTypes = nil file_greet_v1_greet_proto_depIdxs = nil } diff --git a/auto/rpc/greet/v1/greet_grpc.pb.go b/auto/rpc/greet/v1/greet_grpc.pb.go index f1667a54..be277a6b 100644 --- a/auto/rpc/greet/v1/greet_grpc.pb.go +++ b/auto/rpc/greet/v1/greet_grpc.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: -// - protoc-gen-go-grpc v1.3.0 +// - protoc-gen-go-grpc v1.5.1 // - protoc (unknown) // source: greet/v1/greet.proto @@ -15,8 +15,8 @@ import ( // 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.32.0 or later. -const _ = grpc.SupportPackageIsVersion7 +// Requires gRPC-Go v1.64.0 or later. +const _ = grpc.SupportPackageIsVersion9 const ( GreetService_Greet_FullMethodName = "/greet.v1.GreetService/Greet" @@ -38,8 +38,9 @@ func NewGreetServiceClient(cc grpc.ClientConnInterface) GreetServiceClient { } func (c *greetServiceClient) Greet(ctx context.Context, in *GreetRequest, opts ...grpc.CallOption) (*GreetResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(GreetResponse) - err := c.cc.Invoke(ctx, GreetService_Greet_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, GreetService_Greet_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -48,20 +49,24 @@ func (c *greetServiceClient) Greet(ctx context.Context, in *GreetRequest, opts . // GreetServiceServer is the server API for GreetService service. // All implementations must embed UnimplementedGreetServiceServer -// for forward compatibility +// for forward compatibility. type GreetServiceServer interface { Greet(context.Context, *GreetRequest) (*GreetResponse, error) mustEmbedUnimplementedGreetServiceServer() } -// UnimplementedGreetServiceServer must be embedded to have forward compatible implementations. -type UnimplementedGreetServiceServer struct { -} +// UnimplementedGreetServiceServer 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 UnimplementedGreetServiceServer struct{} func (UnimplementedGreetServiceServer) Greet(context.Context, *GreetRequest) (*GreetResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Greet not implemented") } func (UnimplementedGreetServiceServer) mustEmbedUnimplementedGreetServiceServer() {} +func (UnimplementedGreetServiceServer) testEmbeddedByValue() {} // UnsafeGreetServiceServer may be embedded to opt out of forward compatibility for this service. // Use of this interface is not recommended, as added methods to GreetServiceServer will @@ -71,6 +76,13 @@ type UnsafeGreetServiceServer interface { } func RegisterGreetServiceServer(s grpc.ServiceRegistrar, srv GreetServiceServer) { + // If the following call pancis, it indicates UnimplementedGreetServiceServer 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(&GreetService_ServiceDesc, srv) } diff --git a/buf.gen.yaml b/buf.gen.yaml index 5de35a1f..bf9ba452 100644 --- a/buf.gen.yaml +++ b/buf.gen.yaml @@ -14,6 +14,3 @@ plugins: opt: - paths=source_relative - require_unimplemented_servers=true - - plugin: connect-go - out: auto/connect - opt: paths=source_relative diff --git a/go.mod b/go.mod index 7f9578d6..7ec71701 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,6 @@ module github.com/rocboss/paopao-ce go 1.23.0 require ( - connectrpc.com/connect v1.18.1 github.com/Masterminds/semver/v3 v3.2.1 github.com/RoaringBitmap/roaring v1.9.4 github.com/afocus/captcha v0.0.0-20191010092841-4bd1f21c8868 diff --git a/go.sum b/go.sum index 6840bb43..8981a9ab 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,3 @@ -connectrpc.com/connect v1.18.1 h1:PAg7CjSAGvscaf6YZKUefjoih5Z/qYkyaTrBW8xvYPw= -connectrpc.com/connect v1.18.1/go.mod h1:0292hj1rnx8oFrStN7cB4jjVBeqs+Yx5yDIC2prWDO8= github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 h1:L/gRVlceqvL25UVaW/CKtUDjefjrs0SPonmDGUVOYP0= github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= github.com/Masterminds/semver/v3 v3.2.1 h1:RN9w6+7QoMeJVGyfmbcgs28Br8cvmnucEXnY0rYXWg0= diff --git a/internal/servants/servants.go b/internal/servants/servants.go index 5d56b7e5..50a747cf 100644 --- a/internal/servants/servants.go +++ b/internal/servants/servants.go @@ -5,9 +5,6 @@ package servants import ( - "net/http" - - "connectrpc.com/connect" "github.com/alimy/tryst/cfg" "github.com/gin-gonic/gin" "github.com/rocboss/paopao-ce/internal/servants/admin" @@ -17,7 +14,6 @@ import ( "github.com/rocboss/paopao-ce/internal/servants/mobile" "github.com/rocboss/paopao-ce/internal/servants/space" "github.com/rocboss/paopao-ce/internal/servants/statick" - "github.com/rocboss/paopao-ce/internal/servants/triplet" "github.com/rocboss/paopao-ce/internal/servants/web" "google.golang.org/grpc" ) @@ -67,8 +63,3 @@ func RegisterFrontendWebServants(e *gin.Engine) { func RegisterMobileServants(s *grpc.Server) { mobile.RegisterServants(s) } - -// RegisterTripletServants register all the servants to Connect -func RegisterTripletServants(h func(string, http.Handler), opts ...connect.HandlerOption) { - triplet.RegisterAuthenticateHandler(h, opts...) -} diff --git a/internal/servants/triplet/auth.go b/internal/servants/triplet/auth.go deleted file mode 100644 index 17f71671..00000000 --- a/internal/servants/triplet/auth.go +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2023 ROC. All rights reserved. -// Use of this source code is governed by a MIT style -// license that can be found in the LICENSE file. - -package triplet - -import ( - api "github.com/rocboss/paopao-ce/auto/connect/core/v1/corev1connect" -) - -var ( - _ api.AuthenticateServiceHandler = (*authenticateSrv)(nil) -) - -type authenticateSrv struct { - api.UnimplementedAuthenticateServiceHandler -} diff --git a/internal/servants/triplet/triplet.go b/internal/servants/triplet/triplet.go deleted file mode 100644 index 2f698bbc..00000000 --- a/internal/servants/triplet/triplet.go +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2023 ROC. All rights reserved. -// Use of this source code is governed by a MIT style -// license that can be found in the LICENSE file. - -package triplet - -import ( - "net/http" - - "connectrpc.com/connect" - api "github.com/rocboss/paopao-ce/auto/connect/core/v1/corev1connect" -) - -func RegisterAuthenticateHandler(h func(string, http.Handler), opts ...connect.HandlerOption) { - h(api.NewAuthenticateServiceHandler(&authenticateSrv{}, opts...)) -} diff --git a/internal/service/connect_server.go b/internal/service/connect_server.go deleted file mode 100644 index f4578aee..00000000 --- a/internal/service/connect_server.go +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2023 ROC. All rights reserved. -// Use of this source code is governed by a MIT style -// license that can be found in the LICENSE file. - -package service - -import ( - "context" - "net/http" - - "connectrpc.com/connect" - hx "github.com/rocboss/paopao-ce/pkg/http" -) - -var ( - _ server = (*connectServer)(nil) -) - -// connectServer wraper for connect -type connectServer struct { - *baseServer - - isTLS bool - certFile string - keyFile string - handlerOpts []connect.HandlerOption - server *http.Server - mux connectMux -} - -type connectMux interface { - http.Handler - Handle(string, http.Handler) -} - -func (s *connectServer) start() error { - s.server.Handler = s.mux - if s.isTLS { - return s.server.ListenAndServeTLS(s.certFile, s.keyFile) - } else { - return s.server.ListenAndServe() - } -} - -func (s *connectServer) stop() error { - return s.server.Shutdown(context.Background()) -} - -func (s *connectServer) register(path string, handler http.Handler) { - s.mux.Handle(path, handler) -} - -func defaultConnectServer(addr string) (s *connectServer) { - s = &connectServer{ - baseServer: newBaseServe(), - server: &http.Server{ - Addr: addr, - }, - mux: &http.ServeMux{}, - } - // TODO: custom value from config - var useConnectMux bool - if useConnectMux { - s.mux = hx.NewConnectMux() - } - return -} diff --git a/internal/service/connect_service.go b/internal/service/connect_service.go deleted file mode 100644 index 525755fe..00000000 --- a/internal/service/connect_service.go +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2023 ROC. All rights reserved. -// Use of this source code is governed by a MIT style -// license that can be found in the LICENSE file. - -package service - -import ( - "net/http" - - "connectrpc.com/connect" -) - -type baseConnectService struct { - baseService - - server *connectServer -} - -func (s *baseConnectService) registerServer(srv Service, h func(func(string, http.Handler), ...connect.HandlerOption), opts ...connect.HandlerOption) { - h(s.server.register, append(opts, s.server.handlerOpts...)...) - s.server.addService(srv) -} - -func (s *baseConnectService) OnStart() error { - // do nothing default - return nil -} - -func (s *baseConnectService) OnStop() error { - // do nothing default - return nil -} diff --git a/internal/service/server.go b/internal/service/server.go index 8d25f6dd..eb009d9c 100644 --- a/internal/service/server.go +++ b/internal/service/server.go @@ -15,9 +15,8 @@ import ( ) var ( - httpServers = newServerPool[*httpServer]() - grpcServers = newServerPool[*grpcServer]() - connectServers = newServerPool[*connectServer]() + httpServers = newServerPool[*httpServer]() + grpcServers = newServerPool[*grpcServer]() ) const ( @@ -117,7 +116,6 @@ func checkServices() (int, int) { var ss []Service ss = append(ss, httpServers.allServices()...) ss = append(ss, grpcServers.allServices()...) - ss = append(ss, connectServers.allServices()...) return len(ss), maxSidSize(ss) } @@ -176,7 +174,6 @@ func Start(wg *conc.WaitGroup) { // start servers httpServers.startServer(wg, maxSidSize) grpcServers.startServer(wg, maxSidSize) - connectServers.startServer(wg, maxSidSize) } // Stop stop all servers @@ -188,5 +185,4 @@ func Stop() { // stop servers httpServers.stopServer(maxSidSize) grpcServers.stopServer(maxSidSize) - connectServers.stopServer(maxSidSize) } diff --git a/internal/service/triplet.go b/internal/service/triplet.go deleted file mode 100644 index 596892f2..00000000 --- a/internal/service/triplet.go +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2023 ROC. All rights reserved. -// Use of this source code is governed by a MIT style -// license that can be found in the LICENSE file. - -package service - -import ( - "fmt" - - "github.com/Masterminds/semver/v3" - "github.com/fatih/color" - "github.com/rocboss/paopao-ce/internal/servants" -) - -var ( - _ Service = (*tripletService)(nil) -) - -// tripletService just a demo service for Connect -type tripletService struct { - *baseConnectService -} - -func (s *tripletService) Name() string { - return "TripletService" -} - -func (s *tripletService) Version() *semver.Version { - return semver.MustParse("v0.1.0") -} - -func (s *tripletService) OnInit() error { - s.registerServer(s, servants.RegisterTripletServants) - return nil -} - -func (s *tripletService) String() string { - return fmt.Sprintf("listen on %s\n", color.GreenString("http://localhost:8080")) -} - -func newTripletService() Service { - server := connectServers.from(":8080", func() *connectServer { - // TODO: do something for conenct server initialize - return defaultConnectServer(":8080") - }) - return &tripletService{ - baseConnectService: &baseConnectService{ - server: server, - }, - } -}