自动生成 protobuf 代码
This commit is contained in:
281
account/v1/accountv1connect/account.connect.go
Normal file
281
account/v1/accountv1connect/account.connect.go
Normal file
@@ -0,0 +1,281 @@
|
||||
// Code generated by protoc-gen-connect-go. DO NOT EDIT.
|
||||
//
|
||||
// Source: account/v1/account.proto
|
||||
|
||||
package accountv1connect
|
||||
|
||||
import (
|
||||
connect "connectrpc.com/connect"
|
||||
context "context"
|
||||
errors "errors"
|
||||
v1 "git.0yue.com/shenxianhe/sdk/account/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 (
|
||||
// AccountServiceName is the fully-qualified name of the AccountService service.
|
||||
AccountServiceName = "account.v1.AccountService"
|
||||
)
|
||||
|
||||
// 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 (
|
||||
// AccountServiceSendCredentialProcedure is the fully-qualified name of the AccountService's
|
||||
// SendCredential RPC.
|
||||
AccountServiceSendCredentialProcedure = "/account.v1.AccountService/SendCredential"
|
||||
// AccountServiceAuthProcedure is the fully-qualified name of the AccountService's Auth RPC.
|
||||
AccountServiceAuthProcedure = "/account.v1.AccountService/Auth"
|
||||
// AccountServiceSetPasswordProcedure is the fully-qualified name of the AccountService's
|
||||
// SetPassword RPC.
|
||||
AccountServiceSetPasswordProcedure = "/account.v1.AccountService/SetPassword"
|
||||
// AccountServiceSetNameProcedure is the fully-qualified name of the AccountService's SetName RPC.
|
||||
AccountServiceSetNameProcedure = "/account.v1.AccountService/SetName"
|
||||
// AccountServiceGetAvatarUploadURLProcedure is the fully-qualified name of the AccountService's
|
||||
// GetAvatarUploadURL RPC.
|
||||
AccountServiceGetAvatarUploadURLProcedure = "/account.v1.AccountService/GetAvatarUploadURL"
|
||||
// AccountServiceSetAvatarProcedure is the fully-qualified name of the AccountService's SetAvatar
|
||||
// RPC.
|
||||
AccountServiceSetAvatarProcedure = "/account.v1.AccountService/SetAvatar"
|
||||
// AccountServiceGetUserInfoProcedure is the fully-qualified name of the AccountService's
|
||||
// GetUserInfo RPC.
|
||||
AccountServiceGetUserInfoProcedure = "/account.v1.AccountService/GetUserInfo"
|
||||
)
|
||||
|
||||
// AccountServiceClient is a client for the account.v1.AccountService service.
|
||||
type AccountServiceClient interface {
|
||||
SendCredential(context.Context, *connect.Request[v1.SendCredentialRequest]) (*connect.Response[v1.SendCredentialResponse], error)
|
||||
Auth(context.Context, *connect.Request[v1.AuthRequest]) (*connect.Response[v1.AuthResponse], error)
|
||||
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)
|
||||
GetUserInfo(context.Context, *connect.Request[v1.GetUserInfoRequest]) (*connect.Response[v1.GetUserInfoResponse], error)
|
||||
}
|
||||
|
||||
// NewAccountServiceClient constructs a client for the account.v1.AccountService 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 NewAccountServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) AccountServiceClient {
|
||||
baseURL = strings.TrimRight(baseURL, "/")
|
||||
accountServiceMethods := v1.File_account_v1_account_proto.Services().ByName("AccountService").Methods()
|
||||
return &accountServiceClient{
|
||||
sendCredential: connect.NewClient[v1.SendCredentialRequest, v1.SendCredentialResponse](
|
||||
httpClient,
|
||||
baseURL+AccountServiceSendCredentialProcedure,
|
||||
connect.WithSchema(accountServiceMethods.ByName("SendCredential")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
auth: connect.NewClient[v1.AuthRequest, v1.AuthResponse](
|
||||
httpClient,
|
||||
baseURL+AccountServiceAuthProcedure,
|
||||
connect.WithSchema(accountServiceMethods.ByName("Auth")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
setPassword: connect.NewClient[v1.SetPasswordRequest, v1.SetPasswordResponse](
|
||||
httpClient,
|
||||
baseURL+AccountServiceSetPasswordProcedure,
|
||||
connect.WithSchema(accountServiceMethods.ByName("SetPassword")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
setName: connect.NewClient[v1.SetNameRequest, v1.SetNameResponse](
|
||||
httpClient,
|
||||
baseURL+AccountServiceSetNameProcedure,
|
||||
connect.WithSchema(accountServiceMethods.ByName("SetName")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
getAvatarUploadURL: connect.NewClient[v1.GetAvatarUploadURLRequest, v1.GetAvatarUploadURLResponse](
|
||||
httpClient,
|
||||
baseURL+AccountServiceGetAvatarUploadURLProcedure,
|
||||
connect.WithSchema(accountServiceMethods.ByName("GetAvatarUploadURL")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
setAvatar: connect.NewClient[v1.SetAvatarRequest, v1.SetAvatarResponse](
|
||||
httpClient,
|
||||
baseURL+AccountServiceSetAvatarProcedure,
|
||||
connect.WithSchema(accountServiceMethods.ByName("SetAvatar")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
getUserInfo: connect.NewClient[v1.GetUserInfoRequest, v1.GetUserInfoResponse](
|
||||
httpClient,
|
||||
baseURL+AccountServiceGetUserInfoProcedure,
|
||||
connect.WithSchema(accountServiceMethods.ByName("GetUserInfo")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
// accountServiceClient implements AccountServiceClient.
|
||||
type accountServiceClient struct {
|
||||
sendCredential *connect.Client[v1.SendCredentialRequest, v1.SendCredentialResponse]
|
||||
auth *connect.Client[v1.AuthRequest, v1.AuthResponse]
|
||||
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]
|
||||
getUserInfo *connect.Client[v1.GetUserInfoRequest, v1.GetUserInfoResponse]
|
||||
}
|
||||
|
||||
// SendCredential calls account.v1.AccountService.SendCredential.
|
||||
func (c *accountServiceClient) SendCredential(ctx context.Context, req *connect.Request[v1.SendCredentialRequest]) (*connect.Response[v1.SendCredentialResponse], error) {
|
||||
return c.sendCredential.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// Auth calls account.v1.AccountService.Auth.
|
||||
func (c *accountServiceClient) Auth(ctx context.Context, req *connect.Request[v1.AuthRequest]) (*connect.Response[v1.AuthResponse], error) {
|
||||
return c.auth.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// SetPassword calls account.v1.AccountService.SetPassword.
|
||||
func (c *accountServiceClient) SetPassword(ctx context.Context, req *connect.Request[v1.SetPasswordRequest]) (*connect.Response[v1.SetPasswordResponse], error) {
|
||||
return c.setPassword.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// SetName calls account.v1.AccountService.SetName.
|
||||
func (c *accountServiceClient) SetName(ctx context.Context, req *connect.Request[v1.SetNameRequest]) (*connect.Response[v1.SetNameResponse], error) {
|
||||
return c.setName.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// GetAvatarUploadURL calls account.v1.AccountService.GetAvatarUploadURL.
|
||||
func (c *accountServiceClient) GetAvatarUploadURL(ctx context.Context, req *connect.Request[v1.GetAvatarUploadURLRequest]) (*connect.Response[v1.GetAvatarUploadURLResponse], error) {
|
||||
return c.getAvatarUploadURL.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// SetAvatar calls account.v1.AccountService.SetAvatar.
|
||||
func (c *accountServiceClient) SetAvatar(ctx context.Context, req *connect.Request[v1.SetAvatarRequest]) (*connect.Response[v1.SetAvatarResponse], error) {
|
||||
return c.setAvatar.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// GetUserInfo calls account.v1.AccountService.GetUserInfo.
|
||||
func (c *accountServiceClient) GetUserInfo(ctx context.Context, req *connect.Request[v1.GetUserInfoRequest]) (*connect.Response[v1.GetUserInfoResponse], error) {
|
||||
return c.getUserInfo.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// AccountServiceHandler is an implementation of the account.v1.AccountService service.
|
||||
type AccountServiceHandler interface {
|
||||
SendCredential(context.Context, *connect.Request[v1.SendCredentialRequest]) (*connect.Response[v1.SendCredentialResponse], error)
|
||||
Auth(context.Context, *connect.Request[v1.AuthRequest]) (*connect.Response[v1.AuthResponse], error)
|
||||
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)
|
||||
GetUserInfo(context.Context, *connect.Request[v1.GetUserInfoRequest]) (*connect.Response[v1.GetUserInfoResponse], error)
|
||||
}
|
||||
|
||||
// NewAccountServiceHandler 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 NewAccountServiceHandler(svc AccountServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) {
|
||||
accountServiceMethods := v1.File_account_v1_account_proto.Services().ByName("AccountService").Methods()
|
||||
accountServiceSendCredentialHandler := connect.NewUnaryHandler(
|
||||
AccountServiceSendCredentialProcedure,
|
||||
svc.SendCredential,
|
||||
connect.WithSchema(accountServiceMethods.ByName("SendCredential")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
accountServiceAuthHandler := connect.NewUnaryHandler(
|
||||
AccountServiceAuthProcedure,
|
||||
svc.Auth,
|
||||
connect.WithSchema(accountServiceMethods.ByName("Auth")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
accountServiceSetPasswordHandler := connect.NewUnaryHandler(
|
||||
AccountServiceSetPasswordProcedure,
|
||||
svc.SetPassword,
|
||||
connect.WithSchema(accountServiceMethods.ByName("SetPassword")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
accountServiceSetNameHandler := connect.NewUnaryHandler(
|
||||
AccountServiceSetNameProcedure,
|
||||
svc.SetName,
|
||||
connect.WithSchema(accountServiceMethods.ByName("SetName")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
accountServiceGetAvatarUploadURLHandler := connect.NewUnaryHandler(
|
||||
AccountServiceGetAvatarUploadURLProcedure,
|
||||
svc.GetAvatarUploadURL,
|
||||
connect.WithSchema(accountServiceMethods.ByName("GetAvatarUploadURL")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
accountServiceSetAvatarHandler := connect.NewUnaryHandler(
|
||||
AccountServiceSetAvatarProcedure,
|
||||
svc.SetAvatar,
|
||||
connect.WithSchema(accountServiceMethods.ByName("SetAvatar")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
accountServiceGetUserInfoHandler := connect.NewUnaryHandler(
|
||||
AccountServiceGetUserInfoProcedure,
|
||||
svc.GetUserInfo,
|
||||
connect.WithSchema(accountServiceMethods.ByName("GetUserInfo")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
return "/account.v1.AccountService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
switch r.URL.Path {
|
||||
case AccountServiceSendCredentialProcedure:
|
||||
accountServiceSendCredentialHandler.ServeHTTP(w, r)
|
||||
case AccountServiceAuthProcedure:
|
||||
accountServiceAuthHandler.ServeHTTP(w, r)
|
||||
case AccountServiceSetPasswordProcedure:
|
||||
accountServiceSetPasswordHandler.ServeHTTP(w, r)
|
||||
case AccountServiceSetNameProcedure:
|
||||
accountServiceSetNameHandler.ServeHTTP(w, r)
|
||||
case AccountServiceGetAvatarUploadURLProcedure:
|
||||
accountServiceGetAvatarUploadURLHandler.ServeHTTP(w, r)
|
||||
case AccountServiceSetAvatarProcedure:
|
||||
accountServiceSetAvatarHandler.ServeHTTP(w, r)
|
||||
case AccountServiceGetUserInfoProcedure:
|
||||
accountServiceGetUserInfoHandler.ServeHTTP(w, r)
|
||||
default:
|
||||
http.NotFound(w, r)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// UnimplementedAccountServiceHandler returns CodeUnimplemented from all methods.
|
||||
type UnimplementedAccountServiceHandler struct{}
|
||||
|
||||
func (UnimplementedAccountServiceHandler) SendCredential(context.Context, *connect.Request[v1.SendCredentialRequest]) (*connect.Response[v1.SendCredentialResponse], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("account.v1.AccountService.SendCredential is not implemented"))
|
||||
}
|
||||
|
||||
func (UnimplementedAccountServiceHandler) Auth(context.Context, *connect.Request[v1.AuthRequest]) (*connect.Response[v1.AuthResponse], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("account.v1.AccountService.Auth is not implemented"))
|
||||
}
|
||||
|
||||
func (UnimplementedAccountServiceHandler) SetPassword(context.Context, *connect.Request[v1.SetPasswordRequest]) (*connect.Response[v1.SetPasswordResponse], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("account.v1.AccountService.SetPassword is not implemented"))
|
||||
}
|
||||
|
||||
func (UnimplementedAccountServiceHandler) SetName(context.Context, *connect.Request[v1.SetNameRequest]) (*connect.Response[v1.SetNameResponse], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("account.v1.AccountService.SetName is not implemented"))
|
||||
}
|
||||
|
||||
func (UnimplementedAccountServiceHandler) GetAvatarUploadURL(context.Context, *connect.Request[v1.GetAvatarUploadURLRequest]) (*connect.Response[v1.GetAvatarUploadURLResponse], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("account.v1.AccountService.GetAvatarUploadURL is not implemented"))
|
||||
}
|
||||
|
||||
func (UnimplementedAccountServiceHandler) SetAvatar(context.Context, *connect.Request[v1.SetAvatarRequest]) (*connect.Response[v1.SetAvatarResponse], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("account.v1.AccountService.SetAvatar is not implemented"))
|
||||
}
|
||||
|
||||
func (UnimplementedAccountServiceHandler) GetUserInfo(context.Context, *connect.Request[v1.GetUserInfoRequest]) (*connect.Response[v1.GetUserInfoResponse], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("account.v1.AccountService.GetUserInfo is not implemented"))
|
||||
}
|
||||
Reference in New Issue
Block a user