diff --git a/Makefile b/Makefile index d2f2d07f..98abcc26 100644 --- a/Makefile +++ b/Makefile @@ -78,19 +78,10 @@ gen-mir: @go fmt ./auto/api/... .PHONY: gen-rpc -gen-rpc: gen-grpc gen-connect - -.PHONY: gen-grpc -gen-grpc: - @rm -rf auto/rpc - @buf generate --template buf.grpc.gen.yaml proto/grpc - @go fmt ./auto/rpc/... - -.PHONY: gen-connect -gen-connect: - @rm -rf auto/connect - @buf generate --template buf.connect.gen.yaml proto/connect - @go fmt ./auto/connect/... +gen-rpc: + @rm -rf auto/rpc auto/connect + @buf generate proto + @go fmt ./auto/rpc/... ./auto/connect/... .PHONY: proto-mod proto-mod: diff --git a/auto/connect/core/v1/corev1connect/auth.connect.go b/auto/connect/core/v1/corev1connect/auth.connect.go index 76a6bf3d..f15ea068 100644 --- a/auto/connect/core/v1/corev1connect/auth.connect.go +++ b/auto/connect/core/v1/corev1connect/auth.connect.go @@ -8,7 +8,7 @@ import ( context "context" errors "errors" connect_go "github.com/bufbuild/connect-go" - v1 "github.com/rocboss/paopao-ce/auto/connect/core/v1" + v1 "github.com/rocboss/paopao-ce/auto/rpc/core/v1" http "net/http" strings "strings" ) @@ -21,8 +21,8 @@ import ( const _ = connect_go.IsAtLeastVersion0_1_0 const ( - // AuthenticateName is the fully-qualified name of the Authenticate service. - AuthenticateName = "core.v1.Authenticate" + // 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 @@ -33,124 +33,127 @@ const ( // reflection-formatted method names, remove the leading slash and convert the remaining slash to a // period. const ( - // AuthenticatePreLoginProcedure is the fully-qualified name of the Authenticate's preLogin RPC. - AuthenticatePreLoginProcedure = "/core.v1.Authenticate/preLogin" - // AuthenticateLoginProcedure is the fully-qualified name of the Authenticate's login RPC. - AuthenticateLoginProcedure = "/core.v1.Authenticate/login" - // AuthenticateLogoutProcedure is the fully-qualified name of the Authenticate's logout RPC. - AuthenticateLogoutProcedure = "/core.v1.Authenticate/logout" + // 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" ) -// AuthenticateClient is a client for the core.v1.Authenticate service. -type AuthenticateClient interface { +// AuthenticateServiceClient is a client for the core.v1.AuthenticateService service. +type AuthenticateServiceClient interface { PreLogin(context.Context, *connect_go.Request[v1.User]) (*connect_go.Response[v1.ActionReply], error) Login(context.Context, *connect_go.Request[v1.User]) (*connect_go.Response[v1.LoginReply], error) Logout(context.Context, *connect_go.Request[v1.User]) (*connect_go.Response[v1.ActionReply], error) } -// NewAuthenticateClient constructs a client for the core.v1.Authenticate 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. +// 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 NewAuthenticateClient(httpClient connect_go.HTTPClient, baseURL string, opts ...connect_go.ClientOption) AuthenticateClient { +func NewAuthenticateServiceClient(httpClient connect_go.HTTPClient, baseURL string, opts ...connect_go.ClientOption) AuthenticateServiceClient { baseURL = strings.TrimRight(baseURL, "/") - return &authenticateClient{ + return &authenticateServiceClient{ preLogin: connect_go.NewClient[v1.User, v1.ActionReply]( httpClient, - baseURL+AuthenticatePreLoginProcedure, + baseURL+AuthenticateServicePreLoginProcedure, opts..., ), login: connect_go.NewClient[v1.User, v1.LoginReply]( httpClient, - baseURL+AuthenticateLoginProcedure, + baseURL+AuthenticateServiceLoginProcedure, opts..., ), logout: connect_go.NewClient[v1.User, v1.ActionReply]( httpClient, - baseURL+AuthenticateLogoutProcedure, + baseURL+AuthenticateServiceLogoutProcedure, opts..., ), } } -// authenticateClient implements AuthenticateClient. -type authenticateClient struct { +// authenticateServiceClient implements AuthenticateServiceClient. +type authenticateServiceClient struct { preLogin *connect_go.Client[v1.User, v1.ActionReply] login *connect_go.Client[v1.User, v1.LoginReply] logout *connect_go.Client[v1.User, v1.ActionReply] } -// PreLogin calls core.v1.Authenticate.preLogin. -func (c *authenticateClient) PreLogin(ctx context.Context, req *connect_go.Request[v1.User]) (*connect_go.Response[v1.ActionReply], error) { +// PreLogin calls core.v1.AuthenticateService.preLogin. +func (c *authenticateServiceClient) PreLogin(ctx context.Context, req *connect_go.Request[v1.User]) (*connect_go.Response[v1.ActionReply], error) { return c.preLogin.CallUnary(ctx, req) } -// Login calls core.v1.Authenticate.login. -func (c *authenticateClient) Login(ctx context.Context, req *connect_go.Request[v1.User]) (*connect_go.Response[v1.LoginReply], error) { +// Login calls core.v1.AuthenticateService.login. +func (c *authenticateServiceClient) Login(ctx context.Context, req *connect_go.Request[v1.User]) (*connect_go.Response[v1.LoginReply], error) { return c.login.CallUnary(ctx, req) } -// Logout calls core.v1.Authenticate.logout. -func (c *authenticateClient) Logout(ctx context.Context, req *connect_go.Request[v1.User]) (*connect_go.Response[v1.ActionReply], error) { +// Logout calls core.v1.AuthenticateService.logout. +func (c *authenticateServiceClient) Logout(ctx context.Context, req *connect_go.Request[v1.User]) (*connect_go.Response[v1.ActionReply], error) { return c.logout.CallUnary(ctx, req) } -// AuthenticateHandler is an implementation of the core.v1.Authenticate service. -type AuthenticateHandler interface { +// AuthenticateServiceHandler is an implementation of the core.v1.AuthenticateService service. +type AuthenticateServiceHandler interface { PreLogin(context.Context, *connect_go.Request[v1.User]) (*connect_go.Response[v1.ActionReply], error) Login(context.Context, *connect_go.Request[v1.User]) (*connect_go.Response[v1.LoginReply], error) Logout(context.Context, *connect_go.Request[v1.User]) (*connect_go.Response[v1.ActionReply], error) } -// NewAuthenticateHandler builds an HTTP handler from the service implementation. It returns the -// path on which to mount the handler and the handler itself. +// 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 NewAuthenticateHandler(svc AuthenticateHandler, opts ...connect_go.HandlerOption) (string, http.Handler) { - authenticatePreLoginHandler := connect_go.NewUnaryHandler( - AuthenticatePreLoginProcedure, +func NewAuthenticateServiceHandler(svc AuthenticateServiceHandler, opts ...connect_go.HandlerOption) (string, http.Handler) { + authenticateServicePreLoginHandler := connect_go.NewUnaryHandler( + AuthenticateServicePreLoginProcedure, svc.PreLogin, opts..., ) - authenticateLoginHandler := connect_go.NewUnaryHandler( - AuthenticateLoginProcedure, + authenticateServiceLoginHandler := connect_go.NewUnaryHandler( + AuthenticateServiceLoginProcedure, svc.Login, opts..., ) - authenticateLogoutHandler := connect_go.NewUnaryHandler( - AuthenticateLogoutProcedure, + authenticateServiceLogoutHandler := connect_go.NewUnaryHandler( + AuthenticateServiceLogoutProcedure, svc.Logout, opts..., ) - return "/core.v1.Authenticate/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + return "/core.v1.AuthenticateService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { switch r.URL.Path { - case AuthenticatePreLoginProcedure: - authenticatePreLoginHandler.ServeHTTP(w, r) - case AuthenticateLoginProcedure: - authenticateLoginHandler.ServeHTTP(w, r) - case AuthenticateLogoutProcedure: - authenticateLogoutHandler.ServeHTTP(w, r) + case AuthenticateServicePreLoginProcedure: + authenticateServicePreLoginHandler.ServeHTTP(w, r) + case AuthenticateServiceLoginProcedure: + authenticateServiceLoginHandler.ServeHTTP(w, r) + case AuthenticateServiceLogoutProcedure: + authenticateServiceLogoutHandler.ServeHTTP(w, r) default: http.NotFound(w, r) } }) } -// UnimplementedAuthenticateHandler returns CodeUnimplemented from all methods. -type UnimplementedAuthenticateHandler struct{} +// UnimplementedAuthenticateServiceHandler returns CodeUnimplemented from all methods. +type UnimplementedAuthenticateServiceHandler struct{} -func (UnimplementedAuthenticateHandler) PreLogin(context.Context, *connect_go.Request[v1.User]) (*connect_go.Response[v1.ActionReply], error) { - return nil, connect_go.NewError(connect_go.CodeUnimplemented, errors.New("core.v1.Authenticate.preLogin is not implemented")) +func (UnimplementedAuthenticateServiceHandler) PreLogin(context.Context, *connect_go.Request[v1.User]) (*connect_go.Response[v1.ActionReply], error) { + return nil, connect_go.NewError(connect_go.CodeUnimplemented, errors.New("core.v1.AuthenticateService.preLogin is not implemented")) } -func (UnimplementedAuthenticateHandler) Login(context.Context, *connect_go.Request[v1.User]) (*connect_go.Response[v1.LoginReply], error) { - return nil, connect_go.NewError(connect_go.CodeUnimplemented, errors.New("core.v1.Authenticate.login is not implemented")) +func (UnimplementedAuthenticateServiceHandler) Login(context.Context, *connect_go.Request[v1.User]) (*connect_go.Response[v1.LoginReply], error) { + return nil, connect_go.NewError(connect_go.CodeUnimplemented, errors.New("core.v1.AuthenticateService.login is not implemented")) } -func (UnimplementedAuthenticateHandler) Logout(context.Context, *connect_go.Request[v1.User]) (*connect_go.Response[v1.ActionReply], error) { - return nil, connect_go.NewError(connect_go.CodeUnimplemented, errors.New("core.v1.Authenticate.logout is not implemented")) +func (UnimplementedAuthenticateServiceHandler) Logout(context.Context, *connect_go.Request[v1.User]) (*connect_go.Response[v1.ActionReply], error) { + return nil, connect_go.NewError(connect_go.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 new file mode 100644 index 00000000..c06f8e69 --- /dev/null +++ b/auto/connect/greet/v1/greetv1connect/greet.connect.go @@ -0,0 +1,104 @@ +// Code generated by protoc-gen-connect-go. DO NOT EDIT. +// +// Source: greet/v1/greet.proto + +package greetv1connect + +import ( + context "context" + errors "errors" + connect_go "github.com/bufbuild/connect-go" + 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_go.IsAtLeastVersion0_1_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" +) + +// GreetServiceClient is a client for the greet.v1.GreetService service. +type GreetServiceClient interface { + Greet(context.Context, *connect_go.Request[v1.GreetRequest]) (*connect_go.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_go.HTTPClient, baseURL string, opts ...connect_go.ClientOption) GreetServiceClient { + baseURL = strings.TrimRight(baseURL, "/") + return &greetServiceClient{ + greet: connect_go.NewClient[v1.GreetRequest, v1.GreetResponse]( + httpClient, + baseURL+GreetServiceGreetProcedure, + opts..., + ), + } +} + +// greetServiceClient implements GreetServiceClient. +type greetServiceClient struct { + greet *connect_go.Client[v1.GreetRequest, v1.GreetResponse] +} + +// Greet calls greet.v1.GreetService.Greet. +func (c *greetServiceClient) Greet(ctx context.Context, req *connect_go.Request[v1.GreetRequest]) (*connect_go.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_go.Request[v1.GreetRequest]) (*connect_go.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_go.HandlerOption) (string, http.Handler) { + greetServiceGreetHandler := connect_go.NewUnaryHandler( + GreetServiceGreetProcedure, + svc.Greet, + 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_go.Request[v1.GreetRequest]) (*connect_go.Response[v1.GreetResponse], error) { + return nil, connect_go.NewError(connect_go.CodeUnimplemented, errors.New("greet.v1.GreetService.Greet is not implemented")) +} diff --git a/auto/connect/core/v1/auth.pb.go b/auto/rpc/core/v1/auth.pb.go similarity index 64% rename from auto/connect/core/v1/auth.pb.go rename to auto/rpc/core/v1/auth.pb.go index a73493bf..c3f6fdae 100644 --- a/auto/connect/core/v1/auth.pb.go +++ b/auto/rpc/core/v1/auth.pb.go @@ -25,7 +25,7 @@ type User struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - PhoneNum string `protobuf:"bytes,1,opt,name=phoneNum,proto3" json:"phoneNum,omitempty"` + PhoneNum string `protobuf:"bytes,1,opt,name=phone_num,json=phoneNum,proto3" json:"phone_num,omitempty"` } func (x *User) Reset() { @@ -72,8 +72,8 @@ type UserVerify struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - PhoneNum string `protobuf:"bytes,1,opt,name=phoneNum,proto3" json:"phoneNum,omitempty"` - VerificationCode string `protobuf:"bytes,2,opt,name=VerificationCode,proto3" json:"VerificationCode,omitempty"` + 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"` } func (x *UserVerify) Reset() { @@ -127,8 +127,8 @@ type LoginReply struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - StatuCode int32 `protobuf:"varint,1,opt,name=statuCode,proto3" json:"statuCode,omitempty"` - Token string `protobuf:"bytes,2,opt,name=token,proto3" json:"token,omitempty"` + 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"` } func (x *LoginReply) Reset() { @@ -163,9 +163,9 @@ func (*LoginReply) Descriptor() ([]byte, []int) { return file_core_v1_auth_proto_rawDescGZIP(), []int{2} } -func (x *LoginReply) GetStatuCode() int32 { +func (x *LoginReply) GetStatusCode() int32 { if x != nil { - return x.StatuCode + return x.StatusCode } return 0 } @@ -182,7 +182,7 @@ type ActionReply struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - StatusCode int32 `protobuf:"varint,1,opt,name=statusCode,proto3" json:"statusCode,omitempty"` + StatusCode int32 `protobuf:"varint,1,opt,name=status_code,json=statusCode,proto3" json:"status_code,omitempty"` } func (x *ActionReply) Reset() { @@ -228,41 +228,42 @@ 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, 0x22, 0x0a, - 0x04, 0x55, 0x73, 0x65, 0x72, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x4e, 0x75, - 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x4e, 0x75, - 0x6d, 0x22, 0x54, 0x0a, 0x0a, 0x55, 0x73, 0x65, 0x72, 0x56, 0x65, 0x72, 0x69, 0x66, 0x79, 0x12, - 0x1a, 0x0a, 0x08, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x4e, 0x75, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x08, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x4e, 0x75, 0x6d, 0x12, 0x2a, 0x0a, 0x10, 0x56, - 0x65, 0x72, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x43, 0x6f, 0x64, 0x65, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x10, 0x56, 0x65, 0x72, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x43, 0x6f, 0x64, 0x65, 0x22, 0x40, 0x0a, 0x0a, 0x4c, 0x6f, 0x67, 0x69, 0x6e, - 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x1c, 0x0a, 0x09, 0x73, 0x74, 0x61, 0x74, 0x75, 0x43, 0x6f, - 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x73, 0x74, 0x61, 0x74, 0x75, 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, 0x2d, 0x0a, 0x0b, 0x41, 0x63, 0x74, - 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x1e, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x74, - 0x75, 0x73, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x73, 0x74, - 0x61, 0x74, 0x75, 0x73, 0x43, 0x6f, 0x64, 0x65, 0x32, 0x9b, 0x01, 0x0a, 0x0c, 0x41, 0x75, 0x74, - 0x68, 0x65, 0x6e, 0x74, 0x69, 0x63, 0x61, 0x74, 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, + 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, 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, 0x8f, 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, 0x38, 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, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 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, + 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, } var ( @@ -285,12 +286,12 @@ var file_core_v1_auth_proto_goTypes = []interface{}{ (*ActionReply)(nil), // 3: core.v1.ActionReply } var file_core_v1_auth_proto_depIdxs = []int32{ - 0, // 0: core.v1.Authenticate.preLogin:input_type -> core.v1.User - 0, // 1: core.v1.Authenticate.login:input_type -> core.v1.User - 0, // 2: core.v1.Authenticate.logout:input_type -> core.v1.User - 3, // 3: core.v1.Authenticate.preLogin:output_type -> core.v1.ActionReply - 2, // 4: core.v1.Authenticate.login:output_type -> core.v1.LoginReply - 3, // 5: core.v1.Authenticate.logout:output_type -> core.v1.ActionReply + 0, // 0: core.v1.AuthenticateService.preLogin:input_type -> core.v1.User + 0, // 1: core.v1.AuthenticateService.login:input_type -> core.v1.User + 0, // 2: core.v1.AuthenticateService.logout:input_type -> core.v1.User + 3, // 3: core.v1.AuthenticateService.preLogin:output_type -> core.v1.ActionReply + 2, // 4: core.v1.AuthenticateService.login:output_type -> core.v1.LoginReply + 3, // 5: core.v1.AuthenticateService.logout:output_type -> core.v1.ActionReply 3, // [3:6] is the sub-list for method output_type 0, // [0:3] is the sub-list for method input_type 0, // [0:0] is the sub-list for extension type_name diff --git a/auto/rpc/core/v1/auth_grpc.pb.go b/auto/rpc/core/v1/auth_grpc.pb.go new file mode 100644 index 00000000..7cec3d85 --- /dev/null +++ b/auto/rpc/core/v1/auth_grpc.pb.go @@ -0,0 +1,183 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.3.0 +// - protoc (unknown) +// source: core/v1/auth.proto + +package corev1 + +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.32.0 or later. +const _ = grpc.SupportPackageIsVersion7 + +const ( + AuthenticateService_PreLogin_FullMethodName = "/core.v1.AuthenticateService/preLogin" + AuthenticateService_Login_FullMethodName = "/core.v1.AuthenticateService/login" + AuthenticateService_Logout_FullMethodName = "/core.v1.AuthenticateService/logout" +) + +// AuthenticateServiceClient is the client API for AuthenticateService 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. +type AuthenticateServiceClient interface { + PreLogin(ctx context.Context, in *User, opts ...grpc.CallOption) (*ActionReply, error) + Login(ctx context.Context, in *User, opts ...grpc.CallOption) (*LoginReply, error) + Logout(ctx context.Context, in *User, opts ...grpc.CallOption) (*ActionReply, error) +} + +type authenticateServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewAuthenticateServiceClient(cc grpc.ClientConnInterface) AuthenticateServiceClient { + return &authenticateServiceClient{cc} +} + +func (c *authenticateServiceClient) PreLogin(ctx context.Context, in *User, opts ...grpc.CallOption) (*ActionReply, error) { + out := new(ActionReply) + err := c.cc.Invoke(ctx, AuthenticateService_PreLogin_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *authenticateServiceClient) Login(ctx context.Context, in *User, opts ...grpc.CallOption) (*LoginReply, error) { + out := new(LoginReply) + err := c.cc.Invoke(ctx, AuthenticateService_Login_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *authenticateServiceClient) Logout(ctx context.Context, in *User, opts ...grpc.CallOption) (*ActionReply, error) { + out := new(ActionReply) + err := c.cc.Invoke(ctx, AuthenticateService_Logout_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// AuthenticateServiceServer is the server API for AuthenticateService service. +// All implementations must embed UnimplementedAuthenticateServiceServer +// for forward compatibility +type AuthenticateServiceServer interface { + PreLogin(context.Context, *User) (*ActionReply, error) + Login(context.Context, *User) (*LoginReply, error) + Logout(context.Context, *User) (*ActionReply, error) + mustEmbedUnimplementedAuthenticateServiceServer() +} + +// UnimplementedAuthenticateServiceServer must be embedded to have forward compatible implementations. +type UnimplementedAuthenticateServiceServer struct { +} + +func (UnimplementedAuthenticateServiceServer) PreLogin(context.Context, *User) (*ActionReply, error) { + return nil, status.Errorf(codes.Unimplemented, "method PreLogin not implemented") +} +func (UnimplementedAuthenticateServiceServer) Login(context.Context, *User) (*LoginReply, error) { + return nil, status.Errorf(codes.Unimplemented, "method Login not implemented") +} +func (UnimplementedAuthenticateServiceServer) Logout(context.Context, *User) (*ActionReply, error) { + return nil, status.Errorf(codes.Unimplemented, "method Logout not implemented") +} +func (UnimplementedAuthenticateServiceServer) mustEmbedUnimplementedAuthenticateServiceServer() {} + +// 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 +// result in compilation errors. +type UnsafeAuthenticateServiceServer interface { + mustEmbedUnimplementedAuthenticateServiceServer() +} + +func RegisterAuthenticateServiceServer(s grpc.ServiceRegistrar, srv AuthenticateServiceServer) { + s.RegisterService(&AuthenticateService_ServiceDesc, srv) +} + +func _AuthenticateService_PreLogin_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(User) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(AuthenticateServiceServer).PreLogin(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: AuthenticateService_PreLogin_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(AuthenticateServiceServer).PreLogin(ctx, req.(*User)) + } + return interceptor(ctx, in, info, handler) +} + +func _AuthenticateService_Login_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(User) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(AuthenticateServiceServer).Login(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: AuthenticateService_Login_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(AuthenticateServiceServer).Login(ctx, req.(*User)) + } + return interceptor(ctx, in, info, handler) +} + +func _AuthenticateService_Logout_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(User) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(AuthenticateServiceServer).Logout(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: AuthenticateService_Logout_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(AuthenticateServiceServer).Logout(ctx, req.(*User)) + } + return interceptor(ctx, in, info, handler) +} + +// AuthenticateService_ServiceDesc is the grpc.ServiceDesc for AuthenticateService service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var AuthenticateService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "core.v1.AuthenticateService", + HandlerType: (*AuthenticateServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "preLogin", + Handler: _AuthenticateService_PreLogin_Handler, + }, + { + MethodName: "login", + Handler: _AuthenticateService_Login_Handler, + }, + { + MethodName: "logout", + Handler: _AuthenticateService_Logout_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "core/v1/auth.proto", +} diff --git a/buf.connect.gen.yaml b/buf.connect.gen.yaml deleted file mode 100644 index b44819e3..00000000 --- a/buf.connect.gen.yaml +++ /dev/null @@ -1,15 +0,0 @@ -version: v1 -managed: - enabled: true - go_package_prefix: - default: github.com/rocboss/paopao-ce/auto/connect - except: - - buf.build/googleapis/googleapis -plugins: - - plugin: go - out: auto/connect - opt: paths=source_relative - - plugin: connect-go - out: auto/connect - opt: - - paths=source_relative diff --git a/buf.grpc.gen.yaml b/buf.gen.yaml similarity index 82% rename from buf.grpc.gen.yaml rename to buf.gen.yaml index bf9ba452..5de35a1f 100644 --- a/buf.grpc.gen.yaml +++ b/buf.gen.yaml @@ -14,3 +14,6 @@ plugins: opt: - paths=source_relative - require_unimplemented_servers=true + - plugin: connect-go + out: auto/connect + opt: paths=source_relative diff --git a/buf.work.yaml b/buf.work.yaml index 8c2b7cd7..1878b341 100644 --- a/buf.work.yaml +++ b/buf.work.yaml @@ -1,4 +1,3 @@ version: v1 directories: - - proto/connect - - proto/grpc + - proto diff --git a/internal/servants/triplet/auth.go b/internal/servants/triplet/auth.go index b41ee31f..17f71671 100644 --- a/internal/servants/triplet/auth.go +++ b/internal/servants/triplet/auth.go @@ -9,9 +9,9 @@ import ( ) var ( - _ api.AuthenticateHandler = (*authenticateHandler)(nil) + _ api.AuthenticateServiceHandler = (*authenticateSrv)(nil) ) -type authenticateHandler struct { - api.UnimplementedAuthenticateHandler +type authenticateSrv struct { + api.UnimplementedAuthenticateServiceHandler } diff --git a/internal/servants/triplet/triplet.go b/internal/servants/triplet/triplet.go index c756c4cc..bfc77475 100644 --- a/internal/servants/triplet/triplet.go +++ b/internal/servants/triplet/triplet.go @@ -12,5 +12,5 @@ import ( ) func RegisterAuthenticateHandler(h func(string, http.Handler), opts ...connect.HandlerOption) { - h(api.NewAuthenticateHandler(&authenticateHandler{}, opts...)) + h(api.NewAuthenticateServiceHandler(&authenticateSrv{}, opts...)) } diff --git a/internal/service/connect_service.go b/internal/service/connect_service.go index c65bb09b..82059f58 100644 --- a/internal/service/connect_service.go +++ b/internal/service/connect_service.go @@ -16,8 +16,8 @@ type baseConnectService struct { server *connectServer } -func (s *baseConnectService) registerServer(srv Service, h func(func(string, http.Handler), ...connect.HandlerOption)) { - h(s.server.register, s.server.handlerOpts...) +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) } diff --git a/proto/connect/buf.yaml b/proto/buf.yaml similarity index 100% rename from proto/connect/buf.yaml rename to proto/buf.yaml diff --git a/proto/connect/core/v1/auth.proto b/proto/core/v1/auth.proto similarity index 68% rename from proto/connect/core/v1/auth.proto rename to proto/core/v1/auth.proto index 29043ea8..f0b2cf09 100644 --- a/proto/connect/core/v1/auth.proto +++ b/proto/core/v1/auth.proto @@ -5,24 +5,24 @@ package core.v1; option go_package = "github.com/rocboss/paopao-ce/auto/connect/core/v1;corev1"; message User { - string phoneNum = 1; + string phone_num = 1; } message UserVerify { - string phoneNum = 1; - string VerificationCode = 2; + string phone_num = 1; + string verification_code = 2; } message LoginReply { - int32 statuCode = 1; + int32 status_code = 1; string token = 2; } message ActionReply { - int32 statusCode = 1; + int32 status_code = 1; } -service Authenticate { +service AuthenticateService { rpc preLogin(User) returns (ActionReply); rpc login(User) returns (LoginReply); rpc logout(User) returns (ActionReply); diff --git a/proto/grpc/greet/v1/greet.proto b/proto/greet/v1/greet.proto similarity index 100% rename from proto/grpc/greet/v1/greet.proto rename to proto/greet/v1/greet.proto diff --git a/proto/grpc/buf.yaml b/proto/grpc/buf.yaml deleted file mode 100644 index 1a519456..00000000 --- a/proto/grpc/buf.yaml +++ /dev/null @@ -1,7 +0,0 @@ -version: v1 -breaking: - use: - - FILE -lint: - use: - - DEFAULT