diff --git a/Makefile b/Makefile index 1aa96136..c66e8c97 100644 --- a/Makefile +++ b/Makefile @@ -115,10 +115,10 @@ pre-commit: fmt .PHONY: install-protobuf-plugins install-protobuf-plugins: - @go install github.com/bufbuild/buf/cmd/buf@v1.25.0 - @go install github.com/bufbuild/buf/cmd/protoc-gen-buf-breaking@v1.25.0 - @go install github.com/bufbuild/buf/cmd/protoc-gen-buf-lint@v1.25.0 - @go install github.com/bufbuild/connect-go/cmd/protoc-gen-connect-go@latest + @go install github.com/bufbuild/buf/cmd/buf@v1.28.1 + @go install github.com/bufbuild/buf/cmd/protoc-gen-buf-breaking@v1.28.1 + @go install github.com/bufbuild/buf/cmd/protoc-gen-buf-lint@v1.28.1 + @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 index f15ea068..50c3d0f8 100644 --- a/auto/connect/core/v1/corev1connect/auth.connect.go +++ b/auto/connect/core/v1/corev1connect/auth.connect.go @@ -5,9 +5,9 @@ package corev1connect import ( + connect "connectrpc.com/connect" context "context" errors "errors" - connect_go "github.com/bufbuild/connect-go" v1 "github.com/rocboss/paopao-ce/auto/rpc/core/v1" http "net/http" strings "strings" @@ -18,7 +18,7 @@ import ( // 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 _ = connect.IsAtLeastVersion1_13_0 const ( // AuthenticateServiceName is the fully-qualified name of the AuthenticateService service. @@ -44,11 +44,19 @@ const ( 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_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) + 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 @@ -58,54 +66,57 @@ type AuthenticateServiceClient interface { // // 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_go.HTTPClient, baseURL string, opts ...connect_go.ClientOption) AuthenticateServiceClient { +func NewAuthenticateServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) AuthenticateServiceClient { baseURL = strings.TrimRight(baseURL, "/") return &authenticateServiceClient{ - preLogin: connect_go.NewClient[v1.User, v1.ActionReply]( + preLogin: connect.NewClient[v1.User, v1.ActionReply]( httpClient, baseURL+AuthenticateServicePreLoginProcedure, - opts..., + connect.WithSchema(authenticateServicePreLoginMethodDescriptor), + connect.WithClientOptions(opts...), ), - login: connect_go.NewClient[v1.User, v1.LoginReply]( + login: connect.NewClient[v1.User, v1.LoginReply]( httpClient, baseURL+AuthenticateServiceLoginProcedure, - opts..., + connect.WithSchema(authenticateServiceLoginMethodDescriptor), + connect.WithClientOptions(opts...), ), - logout: connect_go.NewClient[v1.User, v1.ActionReply]( + logout: connect.NewClient[v1.User, v1.ActionReply]( httpClient, baseURL+AuthenticateServiceLogoutProcedure, - opts..., + connect.WithSchema(authenticateServiceLogoutMethodDescriptor), + connect.WithClientOptions(opts...), ), } } // 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 *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_go.Request[v1.User]) (*connect_go.Response[v1.ActionReply], error) { +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_go.Request[v1.User]) (*connect_go.Response[v1.LoginReply], error) { +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_go.Request[v1.User]) (*connect_go.Response[v1.ActionReply], error) { +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_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) + 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 @@ -113,21 +124,24 @@ type AuthenticateServiceHandler interface { // // 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_go.HandlerOption) (string, http.Handler) { - authenticateServicePreLoginHandler := connect_go.NewUnaryHandler( +func NewAuthenticateServiceHandler(svc AuthenticateServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) { + authenticateServicePreLoginHandler := connect.NewUnaryHandler( AuthenticateServicePreLoginProcedure, svc.PreLogin, - opts..., + connect.WithSchema(authenticateServicePreLoginMethodDescriptor), + connect.WithHandlerOptions(opts...), ) - authenticateServiceLoginHandler := connect_go.NewUnaryHandler( + authenticateServiceLoginHandler := connect.NewUnaryHandler( AuthenticateServiceLoginProcedure, svc.Login, - opts..., + connect.WithSchema(authenticateServiceLoginMethodDescriptor), + connect.WithHandlerOptions(opts...), ) - authenticateServiceLogoutHandler := connect_go.NewUnaryHandler( + authenticateServiceLogoutHandler := connect.NewUnaryHandler( AuthenticateServiceLogoutProcedure, svc.Logout, - opts..., + connect.WithSchema(authenticateServiceLogoutMethodDescriptor), + connect.WithHandlerOptions(opts...), ) return "/core.v1.AuthenticateService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { switch r.URL.Path { @@ -146,14 +160,14 @@ func NewAuthenticateServiceHandler(svc AuthenticateServiceHandler, opts ...conne // UnimplementedAuthenticateServiceHandler returns CodeUnimplemented from all methods. type UnimplementedAuthenticateServiceHandler struct{} -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 (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_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 (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_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")) +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 index c06f8e69..59d26952 100644 --- a/auto/connect/greet/v1/greetv1connect/greet.connect.go +++ b/auto/connect/greet/v1/greetv1connect/greet.connect.go @@ -5,9 +5,9 @@ package greetv1connect import ( + connect "connectrpc.com/connect" 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" @@ -18,7 +18,7 @@ import ( // 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 _ = connect.IsAtLeastVersion1_13_0 const ( // GreetServiceName is the fully-qualified name of the GreetService service. @@ -37,9 +37,15 @@ const ( 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_go.Request[v1.GreetRequest]) (*connect_go.Response[v1.GreetResponse], error) + 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 @@ -49,30 +55,31 @@ type GreetServiceClient interface { // // 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 { +func NewGreetServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) GreetServiceClient { baseURL = strings.TrimRight(baseURL, "/") return &greetServiceClient{ - greet: connect_go.NewClient[v1.GreetRequest, v1.GreetResponse]( + greet: connect.NewClient[v1.GreetRequest, v1.GreetResponse]( httpClient, baseURL+GreetServiceGreetProcedure, - opts..., + connect.WithSchema(greetServiceGreetMethodDescriptor), + connect.WithClientOptions(opts...), ), } } // greetServiceClient implements GreetServiceClient. type greetServiceClient struct { - greet *connect_go.Client[v1.GreetRequest, v1.GreetResponse] + greet *connect.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) { +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_go.Request[v1.GreetRequest]) (*connect_go.Response[v1.GreetResponse], error) + Greet(context.Context, *connect.Request[v1.GreetRequest]) (*connect.Response[v1.GreetResponse], error) } // NewGreetServiceHandler builds an HTTP handler from the service implementation. It returns the @@ -80,11 +87,12 @@ type GreetServiceHandler interface { // // 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( +func NewGreetServiceHandler(svc GreetServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) { + greetServiceGreetHandler := connect.NewUnaryHandler( GreetServiceGreetProcedure, svc.Greet, - opts..., + connect.WithSchema(greetServiceGreetMethodDescriptor), + connect.WithHandlerOptions(opts...), ) return "/greet.v1.GreetService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { switch r.URL.Path { @@ -99,6 +107,6 @@ func NewGreetServiceHandler(svc GreetServiceHandler, opts ...connect_go.HandlerO // 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")) +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 c3f6fdae..d319130c 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.31.0 +// protoc-gen-go v1.32.0 // protoc (unknown) // source: core/v1/auth.proto diff --git a/auto/rpc/greet/v1/greet.pb.go b/auto/rpc/greet/v1/greet.pb.go index ca79b86e..cd0e7fa0 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.31.0 +// protoc-gen-go v1.32.0 // protoc (unknown) // source: greet/v1/greet.proto diff --git a/go.mod b/go.mod index 5f88f46a..56893a0e 100644 --- a/go.mod +++ b/go.mod @@ -3,6 +3,7 @@ module github.com/rocboss/paopao-ce go 1.20 require ( + connectrpc.com/connect v1.14.0 github.com/Masterminds/semver/v3 v3.2.1 github.com/RoaringBitmap/roaring v1.7.0 github.com/afocus/captcha v0.0.0-20191010092841-4bd1f21c8868 @@ -10,7 +11,6 @@ require ( github.com/alimy/tryst v0.10.1 github.com/aliyun/aliyun-oss-go-sdk v3.0.1+incompatible github.com/allegro/bigcache/v3 v3.1.0 - github.com/bufbuild/connect-go v1.10.0 github.com/bytedance/sonic v1.10.2 github.com/cockroachdb/errors v1.11.1 github.com/disintegration/imaging v1.6.2 diff --git a/go.sum b/go.sum index d38c0523..043a7168 100644 --- a/go.sum +++ b/go.sum @@ -1,3 +1,5 @@ +connectrpc.com/connect v1.14.0 h1:PDS+J7uoz5Oui2VEOMcfz6Qft7opQM9hPiKvtGC01pA= +connectrpc.com/connect v1.14.0/go.mod h1:uoAq5bmhhn43TwhaKdGKN/bZcGtzPW1v+ngDTn5u+8s= github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 h1:L/gRVlceqvL25UVaW/CKtUDjefjrs0SPonmDGUVOYP0= github.com/Masterminds/semver/v3 v3.2.1 h1:RN9w6+7QoMeJVGyfmbcgs28Br8cvmnucEXnY0rYXWg0= github.com/Masterminds/semver/v3 v3.2.1/go.mod h1:qvl/7zhW3nngYb5+80sSMF+FG2BjYrf8m9wsX0PNOMQ= @@ -22,8 +24,6 @@ github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/bits-and-blooms/bitset v1.12.0 h1:U/q1fAF7xXRhFCrhROzIfffYnu+dlS38vCZtmFVPHmA= github.com/bits-and-blooms/bitset v1.12.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8= -github.com/bufbuild/connect-go v1.10.0 h1:QAJ3G9A1OYQW2Jbk3DeoJbkCxuKArrvZgDt47mjdTbg= -github.com/bufbuild/connect-go v1.10.0/go.mod h1:CAIePUgkDR5pAFaylSMtNK45ANQjp9JvpluG20rhpV8= github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM= github.com/bytedance/sonic v1.10.0-rc/go.mod h1:ElCzW+ufi8qKqNW0FY314xriJhyJhuoJ3gFZdAHF7NM= github.com/bytedance/sonic v1.10.2 h1:GQebETVBxYB7JGWJtLBi07OVzWwt+8dWA00gEVW2ZFE= diff --git a/internal/servants/servants.go b/internal/servants/servants.go index 39d26d42..5d56b7e5 100644 --- a/internal/servants/servants.go +++ b/internal/servants/servants.go @@ -7,8 +7,8 @@ package servants import ( "net/http" + "connectrpc.com/connect" "github.com/alimy/tryst/cfg" - "github.com/bufbuild/connect-go" "github.com/gin-gonic/gin" "github.com/rocboss/paopao-ce/internal/servants/admin" "github.com/rocboss/paopao-ce/internal/servants/bot" diff --git a/internal/servants/triplet/triplet.go b/internal/servants/triplet/triplet.go index bfc77475..2f698bbc 100644 --- a/internal/servants/triplet/triplet.go +++ b/internal/servants/triplet/triplet.go @@ -7,7 +7,7 @@ package triplet import ( "net/http" - "github.com/bufbuild/connect-go" + "connectrpc.com/connect" api "github.com/rocboss/paopao-ce/auto/connect/core/v1/corev1connect" ) diff --git a/internal/service/connect_server.go b/internal/service/connect_server.go index b5a19b6a..f4578aee 100644 --- a/internal/service/connect_server.go +++ b/internal/service/connect_server.go @@ -8,7 +8,7 @@ import ( "context" "net/http" - "github.com/bufbuild/connect-go" + "connectrpc.com/connect" hx "github.com/rocboss/paopao-ce/pkg/http" ) diff --git a/internal/service/connect_service.go b/internal/service/connect_service.go index 82059f58..525755fe 100644 --- a/internal/service/connect_service.go +++ b/internal/service/connect_service.go @@ -7,7 +7,7 @@ package service import ( "net/http" - "github.com/bufbuild/connect-go" + "connectrpc.com/connect" ) type baseConnectService struct {