自动生成 protobuf 代码 (tag: v1.9.0)
This commit is contained in:
250
corestack/user/v1/userv1connect/service.connect.go
Normal file
250
corestack/user/v1/userv1connect/service.connect.go
Normal file
@@ -0,0 +1,250 @@
|
||||
// Code generated by protoc-gen-connect-go. DO NOT EDIT.
|
||||
//
|
||||
// Source: corestack/user/v1/service.proto
|
||||
|
||||
package userv1connect
|
||||
|
||||
import (
|
||||
connect "connectrpc.com/connect"
|
||||
context "context"
|
||||
errors "errors"
|
||||
v1 "git.shenxianhe.cn/shenxianhe/sdk/corestack/user/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 (
|
||||
// UserServiceName is the fully-qualified name of the UserService service.
|
||||
UserServiceName = "corestack.user.v1.UserService"
|
||||
)
|
||||
|
||||
// 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 (
|
||||
// UserServiceSetPasswordProcedure is the fully-qualified name of the UserService's SetPassword RPC.
|
||||
UserServiceSetPasswordProcedure = "/corestack.user.v1.UserService/SetPassword"
|
||||
// UserServiceSetNameProcedure is the fully-qualified name of the UserService's SetName RPC.
|
||||
UserServiceSetNameProcedure = "/corestack.user.v1.UserService/SetName"
|
||||
// UserServiceGetAvatarUploadURLProcedure is the fully-qualified name of the UserService's
|
||||
// GetAvatarUploadURL RPC.
|
||||
UserServiceGetAvatarUploadURLProcedure = "/corestack.user.v1.UserService/GetAvatarUploadURL"
|
||||
// UserServiceSetAvatarProcedure is the fully-qualified name of the UserService's SetAvatar RPC.
|
||||
UserServiceSetAvatarProcedure = "/corestack.user.v1.UserService/SetAvatar"
|
||||
// UserServiceSetDescriptionProcedure is the fully-qualified name of the UserService's
|
||||
// SetDescription RPC.
|
||||
UserServiceSetDescriptionProcedure = "/corestack.user.v1.UserService/SetDescription"
|
||||
// UserServiceGetUserInfoProcedure is the fully-qualified name of the UserService's GetUserInfo RPC.
|
||||
UserServiceGetUserInfoProcedure = "/corestack.user.v1.UserService/GetUserInfo"
|
||||
)
|
||||
|
||||
// UserServiceClient is a client for the corestack.user.v1.UserService service.
|
||||
type UserServiceClient interface {
|
||||
SetPassword(context.Context, *connect.Request[v1.SetPasswordRequest]) (*connect.Response[v1.SetPasswordResponse], error)
|
||||
SetName(context.Context, *connect.Request[v1.SetNameRequest]) (*connect.Response[v1.SetNameResponse], error)
|
||||
GetAvatarUploadURL(context.Context, *connect.Request[v1.GetAvatarUploadURLRequest]) (*connect.Response[v1.GetAvatarUploadURLResponse], error)
|
||||
SetAvatar(context.Context, *connect.Request[v1.SetAvatarRequest]) (*connect.Response[v1.SetAvatarResponse], error)
|
||||
SetDescription(context.Context, *connect.Request[v1.SetDescriptionRequest]) (*connect.Response[v1.SetDescriptionResponse], error)
|
||||
GetUserInfo(context.Context, *connect.Request[v1.GetUserInfoRequest]) (*connect.Response[v1.GetUserInfoResponse], error)
|
||||
}
|
||||
|
||||
// NewUserServiceClient constructs a client for the corestack.user.v1.UserService 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 NewUserServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) UserServiceClient {
|
||||
baseURL = strings.TrimRight(baseURL, "/")
|
||||
userServiceMethods := v1.File_corestack_user_v1_service_proto.Services().ByName("UserService").Methods()
|
||||
return &userServiceClient{
|
||||
setPassword: connect.NewClient[v1.SetPasswordRequest, v1.SetPasswordResponse](
|
||||
httpClient,
|
||||
baseURL+UserServiceSetPasswordProcedure,
|
||||
connect.WithSchema(userServiceMethods.ByName("SetPassword")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
setName: connect.NewClient[v1.SetNameRequest, v1.SetNameResponse](
|
||||
httpClient,
|
||||
baseURL+UserServiceSetNameProcedure,
|
||||
connect.WithSchema(userServiceMethods.ByName("SetName")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
getAvatarUploadURL: connect.NewClient[v1.GetAvatarUploadURLRequest, v1.GetAvatarUploadURLResponse](
|
||||
httpClient,
|
||||
baseURL+UserServiceGetAvatarUploadURLProcedure,
|
||||
connect.WithSchema(userServiceMethods.ByName("GetAvatarUploadURL")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
setAvatar: connect.NewClient[v1.SetAvatarRequest, v1.SetAvatarResponse](
|
||||
httpClient,
|
||||
baseURL+UserServiceSetAvatarProcedure,
|
||||
connect.WithSchema(userServiceMethods.ByName("SetAvatar")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
setDescription: connect.NewClient[v1.SetDescriptionRequest, v1.SetDescriptionResponse](
|
||||
httpClient,
|
||||
baseURL+UserServiceSetDescriptionProcedure,
|
||||
connect.WithSchema(userServiceMethods.ByName("SetDescription")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
getUserInfo: connect.NewClient[v1.GetUserInfoRequest, v1.GetUserInfoResponse](
|
||||
httpClient,
|
||||
baseURL+UserServiceGetUserInfoProcedure,
|
||||
connect.WithSchema(userServiceMethods.ByName("GetUserInfo")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
// userServiceClient implements UserServiceClient.
|
||||
type userServiceClient struct {
|
||||
setPassword *connect.Client[v1.SetPasswordRequest, v1.SetPasswordResponse]
|
||||
setName *connect.Client[v1.SetNameRequest, v1.SetNameResponse]
|
||||
getAvatarUploadURL *connect.Client[v1.GetAvatarUploadURLRequest, v1.GetAvatarUploadURLResponse]
|
||||
setAvatar *connect.Client[v1.SetAvatarRequest, v1.SetAvatarResponse]
|
||||
setDescription *connect.Client[v1.SetDescriptionRequest, v1.SetDescriptionResponse]
|
||||
getUserInfo *connect.Client[v1.GetUserInfoRequest, v1.GetUserInfoResponse]
|
||||
}
|
||||
|
||||
// SetPassword calls corestack.user.v1.UserService.SetPassword.
|
||||
func (c *userServiceClient) SetPassword(ctx context.Context, req *connect.Request[v1.SetPasswordRequest]) (*connect.Response[v1.SetPasswordResponse], error) {
|
||||
return c.setPassword.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// SetName calls corestack.user.v1.UserService.SetName.
|
||||
func (c *userServiceClient) SetName(ctx context.Context, req *connect.Request[v1.SetNameRequest]) (*connect.Response[v1.SetNameResponse], error) {
|
||||
return c.setName.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// GetAvatarUploadURL calls corestack.user.v1.UserService.GetAvatarUploadURL.
|
||||
func (c *userServiceClient) GetAvatarUploadURL(ctx context.Context, req *connect.Request[v1.GetAvatarUploadURLRequest]) (*connect.Response[v1.GetAvatarUploadURLResponse], error) {
|
||||
return c.getAvatarUploadURL.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// SetAvatar calls corestack.user.v1.UserService.SetAvatar.
|
||||
func (c *userServiceClient) SetAvatar(ctx context.Context, req *connect.Request[v1.SetAvatarRequest]) (*connect.Response[v1.SetAvatarResponse], error) {
|
||||
return c.setAvatar.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// SetDescription calls corestack.user.v1.UserService.SetDescription.
|
||||
func (c *userServiceClient) SetDescription(ctx context.Context, req *connect.Request[v1.SetDescriptionRequest]) (*connect.Response[v1.SetDescriptionResponse], error) {
|
||||
return c.setDescription.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// GetUserInfo calls corestack.user.v1.UserService.GetUserInfo.
|
||||
func (c *userServiceClient) GetUserInfo(ctx context.Context, req *connect.Request[v1.GetUserInfoRequest]) (*connect.Response[v1.GetUserInfoResponse], error) {
|
||||
return c.getUserInfo.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// UserServiceHandler is an implementation of the corestack.user.v1.UserService service.
|
||||
type UserServiceHandler interface {
|
||||
SetPassword(context.Context, *connect.Request[v1.SetPasswordRequest]) (*connect.Response[v1.SetPasswordResponse], error)
|
||||
SetName(context.Context, *connect.Request[v1.SetNameRequest]) (*connect.Response[v1.SetNameResponse], error)
|
||||
GetAvatarUploadURL(context.Context, *connect.Request[v1.GetAvatarUploadURLRequest]) (*connect.Response[v1.GetAvatarUploadURLResponse], error)
|
||||
SetAvatar(context.Context, *connect.Request[v1.SetAvatarRequest]) (*connect.Response[v1.SetAvatarResponse], error)
|
||||
SetDescription(context.Context, *connect.Request[v1.SetDescriptionRequest]) (*connect.Response[v1.SetDescriptionResponse], error)
|
||||
GetUserInfo(context.Context, *connect.Request[v1.GetUserInfoRequest]) (*connect.Response[v1.GetUserInfoResponse], error)
|
||||
}
|
||||
|
||||
// NewUserServiceHandler 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 NewUserServiceHandler(svc UserServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) {
|
||||
userServiceMethods := v1.File_corestack_user_v1_service_proto.Services().ByName("UserService").Methods()
|
||||
userServiceSetPasswordHandler := connect.NewUnaryHandler(
|
||||
UserServiceSetPasswordProcedure,
|
||||
svc.SetPassword,
|
||||
connect.WithSchema(userServiceMethods.ByName("SetPassword")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
userServiceSetNameHandler := connect.NewUnaryHandler(
|
||||
UserServiceSetNameProcedure,
|
||||
svc.SetName,
|
||||
connect.WithSchema(userServiceMethods.ByName("SetName")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
userServiceGetAvatarUploadURLHandler := connect.NewUnaryHandler(
|
||||
UserServiceGetAvatarUploadURLProcedure,
|
||||
svc.GetAvatarUploadURL,
|
||||
connect.WithSchema(userServiceMethods.ByName("GetAvatarUploadURL")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
userServiceSetAvatarHandler := connect.NewUnaryHandler(
|
||||
UserServiceSetAvatarProcedure,
|
||||
svc.SetAvatar,
|
||||
connect.WithSchema(userServiceMethods.ByName("SetAvatar")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
userServiceSetDescriptionHandler := connect.NewUnaryHandler(
|
||||
UserServiceSetDescriptionProcedure,
|
||||
svc.SetDescription,
|
||||
connect.WithSchema(userServiceMethods.ByName("SetDescription")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
userServiceGetUserInfoHandler := connect.NewUnaryHandler(
|
||||
UserServiceGetUserInfoProcedure,
|
||||
svc.GetUserInfo,
|
||||
connect.WithSchema(userServiceMethods.ByName("GetUserInfo")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
return "/corestack.user.v1.UserService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
switch r.URL.Path {
|
||||
case UserServiceSetPasswordProcedure:
|
||||
userServiceSetPasswordHandler.ServeHTTP(w, r)
|
||||
case UserServiceSetNameProcedure:
|
||||
userServiceSetNameHandler.ServeHTTP(w, r)
|
||||
case UserServiceGetAvatarUploadURLProcedure:
|
||||
userServiceGetAvatarUploadURLHandler.ServeHTTP(w, r)
|
||||
case UserServiceSetAvatarProcedure:
|
||||
userServiceSetAvatarHandler.ServeHTTP(w, r)
|
||||
case UserServiceSetDescriptionProcedure:
|
||||
userServiceSetDescriptionHandler.ServeHTTP(w, r)
|
||||
case UserServiceGetUserInfoProcedure:
|
||||
userServiceGetUserInfoHandler.ServeHTTP(w, r)
|
||||
default:
|
||||
http.NotFound(w, r)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// UnimplementedUserServiceHandler returns CodeUnimplemented from all methods.
|
||||
type UnimplementedUserServiceHandler struct{}
|
||||
|
||||
func (UnimplementedUserServiceHandler) SetPassword(context.Context, *connect.Request[v1.SetPasswordRequest]) (*connect.Response[v1.SetPasswordResponse], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("corestack.user.v1.UserService.SetPassword is not implemented"))
|
||||
}
|
||||
|
||||
func (UnimplementedUserServiceHandler) SetName(context.Context, *connect.Request[v1.SetNameRequest]) (*connect.Response[v1.SetNameResponse], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("corestack.user.v1.UserService.SetName is not implemented"))
|
||||
}
|
||||
|
||||
func (UnimplementedUserServiceHandler) GetAvatarUploadURL(context.Context, *connect.Request[v1.GetAvatarUploadURLRequest]) (*connect.Response[v1.GetAvatarUploadURLResponse], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("corestack.user.v1.UserService.GetAvatarUploadURL is not implemented"))
|
||||
}
|
||||
|
||||
func (UnimplementedUserServiceHandler) SetAvatar(context.Context, *connect.Request[v1.SetAvatarRequest]) (*connect.Response[v1.SetAvatarResponse], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("corestack.user.v1.UserService.SetAvatar is not implemented"))
|
||||
}
|
||||
|
||||
func (UnimplementedUserServiceHandler) SetDescription(context.Context, *connect.Request[v1.SetDescriptionRequest]) (*connect.Response[v1.SetDescriptionResponse], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("corestack.user.v1.UserService.SetDescription is not implemented"))
|
||||
}
|
||||
|
||||
func (UnimplementedUserServiceHandler) GetUserInfo(context.Context, *connect.Request[v1.GetUserInfoRequest]) (*connect.Response[v1.GetUserInfoResponse], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("corestack.user.v1.UserService.GetUserInfo is not implemented"))
|
||||
}
|
||||
Reference in New Issue
Block a user