自动生成 protobuf 代码
This commit is contained in:
139
notification/v1/notificationv1connect/notification.connect.go
Normal file
139
notification/v1/notificationv1connect/notification.connect.go
Normal file
@@ -0,0 +1,139 @@
|
||||
// Code generated by protoc-gen-connect-go. DO NOT EDIT.
|
||||
//
|
||||
// Source: notification/v1/notification.proto
|
||||
|
||||
package notificationv1connect
|
||||
|
||||
import (
|
||||
connect "connectrpc.com/connect"
|
||||
context "context"
|
||||
errors "errors"
|
||||
v1 "git.0yue.com/shenxianhe/sdk/notification/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 (
|
||||
// NotificationServiceName is the fully-qualified name of the NotificationService service.
|
||||
NotificationServiceName = "notification.v1.NotificationService"
|
||||
)
|
||||
|
||||
// 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 (
|
||||
// NotificationServiceListSMSSignProcedure is the fully-qualified name of the NotificationService's
|
||||
// ListSMSSign RPC.
|
||||
NotificationServiceListSMSSignProcedure = "/notification.v1.NotificationService/ListSMSSign"
|
||||
// NotificationServiceSendSMSProcedure is the fully-qualified name of the NotificationService's
|
||||
// SendSMS RPC.
|
||||
NotificationServiceSendSMSProcedure = "/notification.v1.NotificationService/SendSMS"
|
||||
)
|
||||
|
||||
// NotificationServiceClient is a client for the notification.v1.NotificationService service.
|
||||
type NotificationServiceClient interface {
|
||||
ListSMSSign(context.Context, *connect.Request[v1.ListSMSSignRequest]) (*connect.Response[v1.ListSMSSignResponse], error)
|
||||
SendSMS(context.Context, *connect.Request[v1.SendSMSRequest]) (*connect.Response[v1.SendSMSResponse], error)
|
||||
}
|
||||
|
||||
// NewNotificationServiceClient constructs a client for the notification.v1.NotificationService
|
||||
// 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 NewNotificationServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) NotificationServiceClient {
|
||||
baseURL = strings.TrimRight(baseURL, "/")
|
||||
notificationServiceMethods := v1.File_notification_v1_notification_proto.Services().ByName("NotificationService").Methods()
|
||||
return ¬ificationServiceClient{
|
||||
listSMSSign: connect.NewClient[v1.ListSMSSignRequest, v1.ListSMSSignResponse](
|
||||
httpClient,
|
||||
baseURL+NotificationServiceListSMSSignProcedure,
|
||||
connect.WithSchema(notificationServiceMethods.ByName("ListSMSSign")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
sendSMS: connect.NewClient[v1.SendSMSRequest, v1.SendSMSResponse](
|
||||
httpClient,
|
||||
baseURL+NotificationServiceSendSMSProcedure,
|
||||
connect.WithSchema(notificationServiceMethods.ByName("SendSMS")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
// notificationServiceClient implements NotificationServiceClient.
|
||||
type notificationServiceClient struct {
|
||||
listSMSSign *connect.Client[v1.ListSMSSignRequest, v1.ListSMSSignResponse]
|
||||
sendSMS *connect.Client[v1.SendSMSRequest, v1.SendSMSResponse]
|
||||
}
|
||||
|
||||
// ListSMSSign calls notification.v1.NotificationService.ListSMSSign.
|
||||
func (c *notificationServiceClient) ListSMSSign(ctx context.Context, req *connect.Request[v1.ListSMSSignRequest]) (*connect.Response[v1.ListSMSSignResponse], error) {
|
||||
return c.listSMSSign.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// SendSMS calls notification.v1.NotificationService.SendSMS.
|
||||
func (c *notificationServiceClient) SendSMS(ctx context.Context, req *connect.Request[v1.SendSMSRequest]) (*connect.Response[v1.SendSMSResponse], error) {
|
||||
return c.sendSMS.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// NotificationServiceHandler is an implementation of the notification.v1.NotificationService
|
||||
// service.
|
||||
type NotificationServiceHandler interface {
|
||||
ListSMSSign(context.Context, *connect.Request[v1.ListSMSSignRequest]) (*connect.Response[v1.ListSMSSignResponse], error)
|
||||
SendSMS(context.Context, *connect.Request[v1.SendSMSRequest]) (*connect.Response[v1.SendSMSResponse], error)
|
||||
}
|
||||
|
||||
// NewNotificationServiceHandler 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 NewNotificationServiceHandler(svc NotificationServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) {
|
||||
notificationServiceMethods := v1.File_notification_v1_notification_proto.Services().ByName("NotificationService").Methods()
|
||||
notificationServiceListSMSSignHandler := connect.NewUnaryHandler(
|
||||
NotificationServiceListSMSSignProcedure,
|
||||
svc.ListSMSSign,
|
||||
connect.WithSchema(notificationServiceMethods.ByName("ListSMSSign")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
notificationServiceSendSMSHandler := connect.NewUnaryHandler(
|
||||
NotificationServiceSendSMSProcedure,
|
||||
svc.SendSMS,
|
||||
connect.WithSchema(notificationServiceMethods.ByName("SendSMS")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
return "/notification.v1.NotificationService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
switch r.URL.Path {
|
||||
case NotificationServiceListSMSSignProcedure:
|
||||
notificationServiceListSMSSignHandler.ServeHTTP(w, r)
|
||||
case NotificationServiceSendSMSProcedure:
|
||||
notificationServiceSendSMSHandler.ServeHTTP(w, r)
|
||||
default:
|
||||
http.NotFound(w, r)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// UnimplementedNotificationServiceHandler returns CodeUnimplemented from all methods.
|
||||
type UnimplementedNotificationServiceHandler struct{}
|
||||
|
||||
func (UnimplementedNotificationServiceHandler) ListSMSSign(context.Context, *connect.Request[v1.ListSMSSignRequest]) (*connect.Response[v1.ListSMSSignResponse], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("notification.v1.NotificationService.ListSMSSign is not implemented"))
|
||||
}
|
||||
|
||||
func (UnimplementedNotificationServiceHandler) SendSMS(context.Context, *connect.Request[v1.SendSMSRequest]) (*connect.Response[v1.SendSMSResponse], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("notification.v1.NotificationService.SendSMS is not implemented"))
|
||||
}
|
||||
Reference in New Issue
Block a user