mirror of https://github.com/rocboss/paopao-ce
commit
a1662e326b
@ -0,0 +1,156 @@
|
||||
// Code generated by protoc-gen-connect-go. DO NOT EDIT.
|
||||
//
|
||||
// Source: core/v1/auth.proto
|
||||
|
||||
package corev1connect
|
||||
|
||||
import (
|
||||
context "context"
|
||||
errors "errors"
|
||||
connect_go "github.com/bufbuild/connect-go"
|
||||
v1 "github.com/rocboss/paopao-ce/auto/connect/core/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 (
|
||||
// AuthenticateName is the fully-qualified name of the Authenticate service.
|
||||
AuthenticateName = "core.v1.Authenticate"
|
||||
)
|
||||
|
||||
// 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 (
|
||||
// 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"
|
||||
)
|
||||
|
||||
// AuthenticateClient is a client for the core.v1.Authenticate service.
|
||||
type AuthenticateClient 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.
|
||||
//
|
||||
// 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 {
|
||||
baseURL = strings.TrimRight(baseURL, "/")
|
||||
return &authenticateClient{
|
||||
preLogin: connect_go.NewClient[v1.User, v1.ActionReply](
|
||||
httpClient,
|
||||
baseURL+AuthenticatePreLoginProcedure,
|
||||
opts...,
|
||||
),
|
||||
login: connect_go.NewClient[v1.User, v1.LoginReply](
|
||||
httpClient,
|
||||
baseURL+AuthenticateLoginProcedure,
|
||||
opts...,
|
||||
),
|
||||
logout: connect_go.NewClient[v1.User, v1.ActionReply](
|
||||
httpClient,
|
||||
baseURL+AuthenticateLogoutProcedure,
|
||||
opts...,
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
// authenticateClient implements AuthenticateClient.
|
||||
type authenticateClient 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) {
|
||||
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) {
|
||||
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) {
|
||||
return c.logout.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// AuthenticateHandler is an implementation of the core.v1.Authenticate service.
|
||||
type AuthenticateHandler 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.
|
||||
//
|
||||
// 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,
|
||||
svc.PreLogin,
|
||||
opts...,
|
||||
)
|
||||
authenticateLoginHandler := connect_go.NewUnaryHandler(
|
||||
AuthenticateLoginProcedure,
|
||||
svc.Login,
|
||||
opts...,
|
||||
)
|
||||
authenticateLogoutHandler := connect_go.NewUnaryHandler(
|
||||
AuthenticateLogoutProcedure,
|
||||
svc.Logout,
|
||||
opts...,
|
||||
)
|
||||
return "/core.v1.Authenticate/", 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)
|
||||
default:
|
||||
http.NotFound(w, r)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// UnimplementedAuthenticateHandler returns CodeUnimplemented from all methods.
|
||||
type UnimplementedAuthenticateHandler 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 (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 (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"))
|
||||
}
|
@ -0,0 +1,220 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.31.0
|
||||
// protoc (unknown)
|
||||
// source: greet/v1/greet.proto
|
||||
|
||||
package greetv1
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
)
|
||||
|
||||
const (
|
||||
// Verify that this generated code is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
type GreetRequest struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
|
||||
}
|
||||
|
||||
func (x *GreetRequest) Reset() {
|
||||
*x = GreetRequest{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_greet_v1_greet_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *GreetRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*GreetRequest) ProtoMessage() {}
|
||||
|
||||
func (x *GreetRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_greet_v1_greet_proto_msgTypes[0]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use GreetRequest.ProtoReflect.Descriptor instead.
|
||||
func (*GreetRequest) Descriptor() ([]byte, []int) {
|
||||
return file_greet_v1_greet_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *GreetRequest) GetName() string {
|
||||
if x != nil {
|
||||
return x.Name
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type GreetResponse struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Greeting string `protobuf:"bytes,1,opt,name=greeting,proto3" json:"greeting,omitempty"`
|
||||
}
|
||||
|
||||
func (x *GreetResponse) Reset() {
|
||||
*x = GreetResponse{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_greet_v1_greet_proto_msgTypes[1]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *GreetResponse) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*GreetResponse) ProtoMessage() {}
|
||||
|
||||
func (x *GreetResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_greet_v1_greet_proto_msgTypes[1]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use GreetResponse.ProtoReflect.Descriptor instead.
|
||||
func (*GreetResponse) Descriptor() ([]byte, []int) {
|
||||
return file_greet_v1_greet_proto_rawDescGZIP(), []int{1}
|
||||
}
|
||||
|
||||
func (x *GreetResponse) GetGreeting() string {
|
||||
if x != nil {
|
||||
return x.Greeting
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
var File_greet_v1_greet_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_greet_v1_greet_proto_rawDesc = []byte{
|
||||
0x0a, 0x14, 0x67, 0x72, 0x65, 0x65, 0x74, 0x2f, 0x76, 0x31, 0x2f, 0x67, 0x72, 0x65, 0x65, 0x74,
|
||||
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x08, 0x67, 0x72, 0x65, 0x65, 0x74, 0x2e, 0x76, 0x31,
|
||||
0x22, 0x22, 0x0a, 0x0c, 0x47, 0x72, 0x65, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
|
||||
0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04,
|
||||
0x6e, 0x61, 0x6d, 0x65, 0x22, 0x2b, 0x0a, 0x0d, 0x47, 0x72, 0x65, 0x65, 0x74, 0x52, 0x65, 0x73,
|
||||
0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x67, 0x72, 0x65, 0x65, 0x74, 0x69, 0x6e,
|
||||
0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x67, 0x72, 0x65, 0x65, 0x74, 0x69, 0x6e,
|
||||
0x67, 0x32, 0x4a, 0x0a, 0x0c, 0x47, 0x72, 0x65, 0x65, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63,
|
||||
0x65, 0x12, 0x3a, 0x0a, 0x05, 0x47, 0x72, 0x65, 0x65, 0x74, 0x12, 0x16, 0x2e, 0x67, 0x72, 0x65,
|
||||
0x65, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x72, 0x65, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65,
|
||||
0x73, 0x74, 0x1a, 0x17, 0x2e, 0x67, 0x72, 0x65, 0x65, 0x74, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x72,
|
||||
0x65, 0x65, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x93, 0x01,
|
||||
0x0a, 0x0c, 0x63, 0x6f, 0x6d, 0x2e, 0x67, 0x72, 0x65, 0x65, 0x74, 0x2e, 0x76, 0x31, 0x42, 0x0a,
|
||||
0x47, 0x72, 0x65, 0x65, 0x74, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x36, 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, 0x67, 0x72, 0x65, 0x65, 0x74, 0x2f, 0x76, 0x31, 0x3b, 0x67, 0x72, 0x65,
|
||||
0x65, 0x74, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x47, 0x58, 0x58, 0xaa, 0x02, 0x08, 0x47, 0x72, 0x65,
|
||||
0x65, 0x74, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x08, 0x47, 0x72, 0x65, 0x65, 0x74, 0x5c, 0x56, 0x31,
|
||||
0xe2, 0x02, 0x14, 0x47, 0x72, 0x65, 0x65, 0x74, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d,
|
||||
0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x09, 0x47, 0x72, 0x65, 0x65, 0x74, 0x3a,
|
||||
0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
file_greet_v1_greet_proto_rawDescOnce sync.Once
|
||||
file_greet_v1_greet_proto_rawDescData = file_greet_v1_greet_proto_rawDesc
|
||||
)
|
||||
|
||||
func file_greet_v1_greet_proto_rawDescGZIP() []byte {
|
||||
file_greet_v1_greet_proto_rawDescOnce.Do(func() {
|
||||
file_greet_v1_greet_proto_rawDescData = protoimpl.X.CompressGZIP(file_greet_v1_greet_proto_rawDescData)
|
||||
})
|
||||
return file_greet_v1_greet_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_greet_v1_greet_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
|
||||
var file_greet_v1_greet_proto_goTypes = []interface{}{
|
||||
(*GreetRequest)(nil), // 0: greet.v1.GreetRequest
|
||||
(*GreetResponse)(nil), // 1: greet.v1.GreetResponse
|
||||
}
|
||||
var file_greet_v1_greet_proto_depIdxs = []int32{
|
||||
0, // 0: greet.v1.GreetService.Greet:input_type -> greet.v1.GreetRequest
|
||||
1, // 1: greet.v1.GreetService.Greet:output_type -> greet.v1.GreetResponse
|
||||
1, // [1:2] is the sub-list for method output_type
|
||||
0, // [0:1] is the sub-list for method input_type
|
||||
0, // [0:0] is the sub-list for extension type_name
|
||||
0, // [0:0] is the sub-list for extension extendee
|
||||
0, // [0:0] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_greet_v1_greet_proto_init() }
|
||||
func file_greet_v1_greet_proto_init() {
|
||||
if File_greet_v1_greet_proto != nil {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_greet_v1_greet_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*GreetRequest); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_greet_v1_greet_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*GreetResponse); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_greet_v1_greet_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 2,
|
||||
NumExtensions: 0,
|
||||
NumServices: 1,
|
||||
},
|
||||
GoTypes: file_greet_v1_greet_proto_goTypes,
|
||||
DependencyIndexes: file_greet_v1_greet_proto_depIdxs,
|
||||
MessageInfos: file_greet_v1_greet_proto_msgTypes,
|
||||
}.Build()
|
||||
File_greet_v1_greet_proto = out.File
|
||||
file_greet_v1_greet_proto_rawDesc = nil
|
||||
file_greet_v1_greet_proto_goTypes = nil
|
||||
file_greet_v1_greet_proto_depIdxs = nil
|
||||
}
|
@ -0,0 +1,109 @@
|
||||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-grpc v1.3.0
|
||||
// - protoc (unknown)
|
||||
// source: greet/v1/greet.proto
|
||||
|
||||
package greetv1
|
||||
|
||||
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 (
|
||||
GreetService_Greet_FullMethodName = "/greet.v1.GreetService/Greet"
|
||||
)
|
||||
|
||||
// GreetServiceClient is the client API for GreetService 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 GreetServiceClient interface {
|
||||
Greet(ctx context.Context, in *GreetRequest, opts ...grpc.CallOption) (*GreetResponse, error)
|
||||
}
|
||||
|
||||
type greetServiceClient struct {
|
||||
cc grpc.ClientConnInterface
|
||||
}
|
||||
|
||||
func NewGreetServiceClient(cc grpc.ClientConnInterface) GreetServiceClient {
|
||||
return &greetServiceClient{cc}
|
||||
}
|
||||
|
||||
func (c *greetServiceClient) Greet(ctx context.Context, in *GreetRequest, opts ...grpc.CallOption) (*GreetResponse, error) {
|
||||
out := new(GreetResponse)
|
||||
err := c.cc.Invoke(ctx, GreetService_Greet_FullMethodName, in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// GreetServiceServer is the server API for GreetService service.
|
||||
// All implementations must embed UnimplementedGreetServiceServer
|
||||
// for forward compatibility
|
||||
type GreetServiceServer interface {
|
||||
Greet(context.Context, *GreetRequest) (*GreetResponse, error)
|
||||
mustEmbedUnimplementedGreetServiceServer()
|
||||
}
|
||||
|
||||
// UnimplementedGreetServiceServer must be embedded to have forward compatible implementations.
|
||||
type UnimplementedGreetServiceServer struct {
|
||||
}
|
||||
|
||||
func (UnimplementedGreetServiceServer) Greet(context.Context, *GreetRequest) (*GreetResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Greet not implemented")
|
||||
}
|
||||
func (UnimplementedGreetServiceServer) mustEmbedUnimplementedGreetServiceServer() {}
|
||||
|
||||
// UnsafeGreetServiceServer may be embedded to opt out of forward compatibility for this service.
|
||||
// Use of this interface is not recommended, as added methods to GreetServiceServer will
|
||||
// result in compilation errors.
|
||||
type UnsafeGreetServiceServer interface {
|
||||
mustEmbedUnimplementedGreetServiceServer()
|
||||
}
|
||||
|
||||
func RegisterGreetServiceServer(s grpc.ServiceRegistrar, srv GreetServiceServer) {
|
||||
s.RegisterService(&GreetService_ServiceDesc, srv)
|
||||
}
|
||||
|
||||
func _GreetService_Greet_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(GreetRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(GreetServiceServer).Greet(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: GreetService_Greet_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(GreetServiceServer).Greet(ctx, req.(*GreetRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
// GreetService_ServiceDesc is the grpc.ServiceDesc for GreetService service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
var GreetService_ServiceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "greet.v1.GreetService",
|
||||
HandlerType: (*GreetServiceServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "Greet",
|
||||
Handler: _GreetService_Greet_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "greet/v1/greet.proto",
|
||||
}
|
@ -1,183 +0,0 @@
|
||||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-grpc v1.3.0
|
||||
// - protoc (unknown)
|
||||
// source: v1/auth.proto
|
||||
|
||||
package v1
|
||||
|
||||
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 (
|
||||
Authenticate_PreLogin_FullMethodName = "/auth.Authenticate/preLogin"
|
||||
Authenticate_Login_FullMethodName = "/auth.Authenticate/login"
|
||||
Authenticate_Logout_FullMethodName = "/auth.Authenticate/logout"
|
||||
)
|
||||
|
||||
// AuthenticateClient is the client API for Authenticate 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 AuthenticateClient 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 authenticateClient struct {
|
||||
cc grpc.ClientConnInterface
|
||||
}
|
||||
|
||||
func NewAuthenticateClient(cc grpc.ClientConnInterface) AuthenticateClient {
|
||||
return &authenticateClient{cc}
|
||||
}
|
||||
|
||||
func (c *authenticateClient) PreLogin(ctx context.Context, in *User, opts ...grpc.CallOption) (*ActionReply, error) {
|
||||
out := new(ActionReply)
|
||||
err := c.cc.Invoke(ctx, Authenticate_PreLogin_FullMethodName, in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *authenticateClient) Login(ctx context.Context, in *User, opts ...grpc.CallOption) (*LoginReply, error) {
|
||||
out := new(LoginReply)
|
||||
err := c.cc.Invoke(ctx, Authenticate_Login_FullMethodName, in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *authenticateClient) Logout(ctx context.Context, in *User, opts ...grpc.CallOption) (*ActionReply, error) {
|
||||
out := new(ActionReply)
|
||||
err := c.cc.Invoke(ctx, Authenticate_Logout_FullMethodName, in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// AuthenticateServer is the server API for Authenticate service.
|
||||
// All implementations must embed UnimplementedAuthenticateServer
|
||||
// for forward compatibility
|
||||
type AuthenticateServer interface {
|
||||
PreLogin(context.Context, *User) (*ActionReply, error)
|
||||
Login(context.Context, *User) (*LoginReply, error)
|
||||
Logout(context.Context, *User) (*ActionReply, error)
|
||||
mustEmbedUnimplementedAuthenticateServer()
|
||||
}
|
||||
|
||||
// UnimplementedAuthenticateServer must be embedded to have forward compatible implementations.
|
||||
type UnimplementedAuthenticateServer struct {
|
||||
}
|
||||
|
||||
func (UnimplementedAuthenticateServer) PreLogin(context.Context, *User) (*ActionReply, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method PreLogin not implemented")
|
||||
}
|
||||
func (UnimplementedAuthenticateServer) Login(context.Context, *User) (*LoginReply, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Login not implemented")
|
||||
}
|
||||
func (UnimplementedAuthenticateServer) Logout(context.Context, *User) (*ActionReply, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Logout not implemented")
|
||||
}
|
||||
func (UnimplementedAuthenticateServer) mustEmbedUnimplementedAuthenticateServer() {}
|
||||
|
||||
// UnsafeAuthenticateServer may be embedded to opt out of forward compatibility for this service.
|
||||
// Use of this interface is not recommended, as added methods to AuthenticateServer will
|
||||
// result in compilation errors.
|
||||
type UnsafeAuthenticateServer interface {
|
||||
mustEmbedUnimplementedAuthenticateServer()
|
||||
}
|
||||
|
||||
func RegisterAuthenticateServer(s grpc.ServiceRegistrar, srv AuthenticateServer) {
|
||||
s.RegisterService(&Authenticate_ServiceDesc, srv)
|
||||
}
|
||||
|
||||
func _Authenticate_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.(AuthenticateServer).PreLogin(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: Authenticate_PreLogin_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(AuthenticateServer).PreLogin(ctx, req.(*User))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Authenticate_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.(AuthenticateServer).Login(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: Authenticate_Login_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(AuthenticateServer).Login(ctx, req.(*User))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Authenticate_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.(AuthenticateServer).Logout(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: Authenticate_Logout_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(AuthenticateServer).Logout(ctx, req.(*User))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
// Authenticate_ServiceDesc is the grpc.ServiceDesc for Authenticate service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
var Authenticate_ServiceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "auth.Authenticate",
|
||||
HandlerType: (*AuthenticateServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "preLogin",
|
||||
Handler: _Authenticate_PreLogin_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "login",
|
||||
Handler: _Authenticate_Login_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "logout",
|
||||
Handler: _Authenticate_Logout_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "v1/auth.proto",
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
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
|
@ -1,3 +1,4 @@
|
||||
version: v1
|
||||
directories:
|
||||
- proto
|
||||
- proto/connect
|
||||
- proto/grpc
|
||||
|
@ -1,21 +0,0 @@
|
||||
// Copyright 2022 ROC. All rights reserved.
|
||||
// Use of this source code is governed by a MIT style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package mobile
|
||||
|
||||
import (
|
||||
api "github.com/rocboss/paopao-ce/auto/rpc/v1"
|
||||
)
|
||||
|
||||
var (
|
||||
_ api.AuthenticateServer = (*authenticateServant)(nil)
|
||||
)
|
||||
|
||||
type authenticateServant struct {
|
||||
api.UnimplementedAuthenticateServer
|
||||
}
|
||||
|
||||
func newAuthenticateServer() *authenticateServant {
|
||||
return &authenticateServant{}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
// Copyright 2022 ROC. All rights reserved.
|
||||
// Use of this source code is governed by a MIT style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package mobile
|
||||
|
||||
import (
|
||||
api "github.com/rocboss/paopao-ce/auto/rpc/greet/v1"
|
||||
)
|
||||
|
||||
var (
|
||||
_ api.GreetServiceServer = (*greetServiceSrv)(nil)
|
||||
)
|
||||
|
||||
type greetServiceSrv struct {
|
||||
api.UnimplementedGreetServiceServer
|
||||
}
|
||||
|
||||
func newGreetServiceServer() *greetServiceSrv {
|
||||
return &greetServiceSrv{}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
// Copyright 2023 ROC. All rights reserved.
|
||||
// Use of this source code is governed by a MIT style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package triplet
|
||||
|
||||
import (
|
||||
api "github.com/rocboss/paopao-ce/auto/connect/core/v1/corev1connect"
|
||||
)
|
||||
|
||||
var (
|
||||
_ api.AuthenticateHandler = (*authenticateHandler)(nil)
|
||||
)
|
||||
|
||||
type authenticateHandler struct {
|
||||
api.UnimplementedAuthenticateHandler
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
// Copyright 2023 ROC. All rights reserved.
|
||||
// Use of this source code is governed by a MIT style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package triplet
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/bufbuild/connect-go"
|
||||
api "github.com/rocboss/paopao-ce/auto/connect/core/v1/corev1connect"
|
||||
)
|
||||
|
||||
func RegisterAuthenticateHandler(h func(string, http.Handler), opts ...connect.HandlerOption) {
|
||||
h(api.NewAuthenticateHandler(&authenticateHandler{}, opts...))
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
// Copyright 2023 ROC. All rights reserved.
|
||||
// Use of this source code is governed by a MIT style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
"github.com/bufbuild/connect-go"
|
||||
)
|
||||
|
||||
var (
|
||||
_ server = (*connectServer)(nil)
|
||||
)
|
||||
|
||||
// connectServer wraper for connect
|
||||
type connectServer struct {
|
||||
*baseServer
|
||||
|
||||
isTLS bool
|
||||
certFile string
|
||||
keyFile string
|
||||
handlerOpts []connect.HandlerOption
|
||||
server *http.Server
|
||||
mux *http.ServeMux
|
||||
}
|
||||
|
||||
func (s *connectServer) start() error {
|
||||
s.server.Handler = s.mux
|
||||
if s.isTLS {
|
||||
return s.server.ListenAndServeTLS(s.certFile, s.keyFile)
|
||||
} else {
|
||||
return s.server.ListenAndServe()
|
||||
}
|
||||
}
|
||||
|
||||
func (s *connectServer) stop() error {
|
||||
return s.server.Shutdown(context.Background())
|
||||
}
|
||||
|
||||
func (s *connectServer) register(path string, handler http.Handler) {
|
||||
s.mux.Handle(path, handler)
|
||||
}
|
||||
|
||||
func defaultConnectServer(addr string) *connectServer {
|
||||
return &connectServer{
|
||||
baseServer: newBaseServe(),
|
||||
server: &http.Server{
|
||||
Addr: addr,
|
||||
},
|
||||
mux: &http.ServeMux{},
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
// Copyright 2023 ROC. All rights reserved.
|
||||
// Use of this source code is governed by a MIT style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package service
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/bufbuild/connect-go"
|
||||
)
|
||||
|
||||
type baseConnectService struct {
|
||||
baseService
|
||||
|
||||
server *connectServer
|
||||
}
|
||||
|
||||
func (s *baseConnectService) registerServer(srv Service, h func(func(string, http.Handler), ...connect.HandlerOption)) {
|
||||
h(s.server.register, s.server.handlerOpts...)
|
||||
s.server.addService(srv)
|
||||
}
|
||||
|
||||
func (s *baseConnectService) OnStart() error {
|
||||
// do nothing default
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *baseConnectService) OnStop() error {
|
||||
// do nothing default
|
||||
return nil
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
// Copyright 2023 ROC. All rights reserved.
|
||||
// Use of this source code is governed by a MIT style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package service
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/Masterminds/semver/v3"
|
||||
"github.com/fatih/color"
|
||||
"github.com/rocboss/paopao-ce/internal/servants"
|
||||
)
|
||||
|
||||
var (
|
||||
_ Service = (*tripletService)(nil)
|
||||
)
|
||||
|
||||
// tripletService just a demo service for Connect
|
||||
type tripletService struct {
|
||||
*baseConnectService
|
||||
}
|
||||
|
||||
func (s *tripletService) Name() string {
|
||||
return "TripletService"
|
||||
}
|
||||
|
||||
func (s *tripletService) Version() *semver.Version {
|
||||
return semver.MustParse("v0.1.0")
|
||||
}
|
||||
|
||||
func (s *tripletService) OnInit() error {
|
||||
s.registerServer(s, servants.RegisterTripletServants)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *tripletService) String() string {
|
||||
return fmt.Sprintf("listen on %s\n", color.GreenString("http://localhost:8080"))
|
||||
}
|
||||
|
||||
func newTripletService() Service {
|
||||
server := connectServers.from(":8080", func() *connectServer {
|
||||
// TODO: do something for conenct server initialize
|
||||
return defaultConnectServer(":8080")
|
||||
})
|
||||
return &tripletService{
|
||||
baseConnectService: &baseConnectService{
|
||||
server: server,
|
||||
},
|
||||
}
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
# Generated by buf. DO NOT EDIT.
|
||||
version: v1
|
||||
deps:
|
||||
- remote: buf.build
|
||||
owner: googleapis
|
||||
repository: googleapis
|
||||
commit: c0ec788bbbb747fca594a1e2347edd4e
|
@ -1,10 +1,9 @@
|
||||
version: v1
|
||||
lint:
|
||||
use:
|
||||
- DEFAULT
|
||||
breaking:
|
||||
use:
|
||||
- FILE
|
||||
|
||||
lint:
|
||||
use:
|
||||
- DEFAULT
|
||||
deps:
|
||||
- buf.build/googleapis/googleapis
|
@ -1,8 +1,8 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package auth;
|
||||
package core.v1;
|
||||
|
||||
option go_package = "github.com/rocboss/paopao-ce/auto/rpc/v1";
|
||||
option go_package = "github.com/rocboss/paopao-ce/auto/connect/core/v1;corev1";
|
||||
|
||||
message User {
|
||||
string phoneNum = 1;
|
@ -0,0 +1,7 @@
|
||||
version: v1
|
||||
breaking:
|
||||
use:
|
||||
- FILE
|
||||
lint:
|
||||
use:
|
||||
- DEFAULT
|
@ -0,0 +1,17 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package greet.v1;
|
||||
|
||||
option go_package = "github.com/rocboss/paopao-ce/auto/rpc/greet/v1;greetv1";
|
||||
|
||||
message GreetRequest {
|
||||
string name = 1;
|
||||
}
|
||||
|
||||
message GreetResponse {
|
||||
string greeting = 1;
|
||||
}
|
||||
|
||||
service GreetService {
|
||||
rpc Greet(GreetRequest) returns (GreetResponse) {}
|
||||
}
|
Loading…
Reference in new issue