slaventius 2 years ago
parent a559ad0160
commit cf6662fa6e
  1. 46
      api/proto/auth.proto
  2. 36
      cmd/main.go
  3. 1
      go.mod
  4. 2
      go.sum
  5. 32
      internal/config/config.go
  6. 65
      internal/transport/grpc/grpc.go
  7. 414
      pkg/api/auth.pb.go
  8. 177
      pkg/api/auth_grpc.pb.go

@ -0,0 +1,46 @@
syntax="proto3";
package auth;
option go_package = "./";
// go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
// go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
// go get google.golang.org/grpc
// protoc -I=api/proto --go_out=pkg/api --go_opt=paths=source_relative --go-grpc_out=pkg/api --go-grpc_opt=paths=source_relative api/proto/account.proto
// Логин пользователя
message LoginRequest {
string Login = 1;
string Password = 2;
}
message LoginResponse {
int32 ID = 1;
}
// Регистрация пользователя
message RegistrationRequest {
string Login = 1;
string Email = 2;
}
message RegistrationResponse {
string Code = 1;
string Email = 2;
}
// Подтверждение пользователя
message ConfirmationRequest {
string Code = 1;
}
message ConfirmationResponse {
int32 ID = 1;
}
// ...
service AuthDB {
rpc Login(LoginRequest) returns (LoginResponse){}
rpc Registration(RegistrationRequest) returns(RegistrationResponse){}
rpc Confirmation(ConfirmationRequest) returns(ConfirmationResponse){}
}

@ -1,34 +1,34 @@
package main
import (
"context"
"fmt"
"log"
"net"
"test3k/authDB/internal/config"
server "test3k/authDB/internal/transport/grpc"
api "test3k/authDB/pkg/api"
kafka "github.com/segmentio/kafka-go"
"google.golang.org/grpc"
)
func main() {
ctx := context.Background()
consumer := kafka.NewReader(kafka.ReaderConfig{
Brokers: []string{"localhost:9092"},
Topic: "topic-A",
Partition: 0,
MinBytes: 10e3, // 10KB
MaxBytes: 10e6, // 10MB
})
defer consumer.Close()
s := grpc.NewServer()
srv := server.NewGRPCServer()
config := config.NewConfig()
//
// consumer.SetOffset(42)
api.RegisterAuthDBServer(s, srv)
//
for {
m, err := consumer.ReadMessage(ctx)
if err != nil {
log.Fatal(err)
}
connStr := fmt.Sprintf(":%d", config.App.Port)
lis, era := net.Listen("tcp", connStr)
if era != nil {
log.Fatal(era)
}
fmt.Printf("message at offset %d: %s = %s\n", m.Offset, string(m.Key), string(m.Value))
//
eru := s.Serve(lis)
if eru != nil {
log.Fatal(eru)
}
}

@ -5,6 +5,7 @@ go 1.19
require github.com/segmentio/kafka-go v0.4.38
require (
github.com/kelseyhightower/envconfig v1.4.0 // indirect
github.com/klauspost/compress v1.15.9 // indirect
github.com/pierrec/lz4/v4 v4.1.15 // indirect
)

@ -1,6 +1,8 @@
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/kelseyhightower/envconfig v1.4.0 h1:Im6hONhd3pLkfDFsbRgu68RDNkGF1r3dvMUtDTo2cv8=
github.com/kelseyhightower/envconfig v1.4.0/go.mod h1:cccZRl6mQpaq41TPp5QxidR+Sa3axMbJDNb//FQX6Gg=
github.com/klauspost/compress v1.15.9 h1:wKRjX6JRtDdrE9qwa4b/Cip7ACOshUI4smpCQanqjSY=
github.com/klauspost/compress v1.15.9/go.mod h1:PhcZ0MbTNciWF3rruxRgKxI5NkcHHrHUDtV4Yw2GlzU=
github.com/pierrec/lz4/v4 v4.1.15 h1:MO0/ucJhngq7299dKLwIMtgTfbkoSPF6AoMYDd8Q4q0=

@ -0,0 +1,32 @@
package config
import (
"log"
"github.com/kelseyhightower/envconfig"
)
// type DbConfig struct {
// Host string `envconfig:"DB_HOST"`
// Port int `envconfig:"DB_PORT"`
// }
type AppConfig struct {
Port int `envconfig:"APP_PORT"`
}
// ...
type Config struct {
// Db DbConfig
App AppConfig
}
func NewConfig() *Config {
c := Config{}
err := envconfig.Process("", &c)
if err != nil {
log.Fatal(err.Error())
}
return &c
}

@ -0,0 +1,65 @@
package grpc
import (
"context"
"fmt"
"log"
"sync"
api "test3k/authDB/pkg/api"
kafka "github.com/segmentio/kafka-go"
)
type user struct {
Code string
Login string
Password string
}
type GRPCServer struct {
mu sync.Mutex
users map[string]user
api.UnimplementedAuthDBServer
}
func NewGRPCServer() *GRPCServer {
return &GRPCServer{
mu: sync.Mutex{},
users: make(map[string]user),
}
}
func (s *GRPCServer) Login(context.Context, *api.LoginRequest) (*api.LoginResponse, error) {
return nil, nil
}
func (s *GRPCServer) Registration(context.Context, *api.RegistrationRequest) (*api.RegistrationResponse, error) {
ctx := context.Background()
consumer := kafka.NewReader(kafka.ReaderConfig{
Brokers: []string{"localhost:9092"},
Topic: "topic-A",
Partition: 0,
MinBytes: 10e3, // 10KB
MaxBytes: 10e6, // 10MB
})
defer consumer.Close()
//
// consumer.SetOffset(42)
//
for {
m, err := consumer.ReadMessage(ctx)
if err != nil {
log.Fatal(err)
}
fmt.Printf("message at offset %d: %s = %s\n", m.Offset, string(m.Key), string(m.Value))
}
return nil, nil
}
func (s *GRPCServer) Confirmation(context.Context, *api.ConfirmationRequest) (*api.ConfirmationResponse, error) {
return nil, nil
}

@ -0,0 +1,414 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.28.1
// protoc v3.6.1
// source: auth.proto
package __
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 LoginRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
}
func (x *LoginRequest) Reset() {
*x = LoginRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_auth_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *LoginRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*LoginRequest) ProtoMessage() {}
func (x *LoginRequest) ProtoReflect() protoreflect.Message {
mi := &file_auth_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 LoginRequest.ProtoReflect.Descriptor instead.
func (*LoginRequest) Descriptor() ([]byte, []int) {
return file_auth_proto_rawDescGZIP(), []int{0}
}
type LoginResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
}
func (x *LoginResponse) Reset() {
*x = LoginResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_auth_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *LoginResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*LoginResponse) ProtoMessage() {}
func (x *LoginResponse) ProtoReflect() protoreflect.Message {
mi := &file_auth_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 LoginResponse.ProtoReflect.Descriptor instead.
func (*LoginResponse) Descriptor() ([]byte, []int) {
return file_auth_proto_rawDescGZIP(), []int{1}
}
// Регистрация пользователя
type RegistrationRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
}
func (x *RegistrationRequest) Reset() {
*x = RegistrationRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_auth_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *RegistrationRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*RegistrationRequest) ProtoMessage() {}
func (x *RegistrationRequest) ProtoReflect() protoreflect.Message {
mi := &file_auth_proto_msgTypes[2]
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 RegistrationRequest.ProtoReflect.Descriptor instead.
func (*RegistrationRequest) Descriptor() ([]byte, []int) {
return file_auth_proto_rawDescGZIP(), []int{2}
}
type RegistrationResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
}
func (x *RegistrationResponse) Reset() {
*x = RegistrationResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_auth_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *RegistrationResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*RegistrationResponse) ProtoMessage() {}
func (x *RegistrationResponse) ProtoReflect() protoreflect.Message {
mi := &file_auth_proto_msgTypes[3]
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 RegistrationResponse.ProtoReflect.Descriptor instead.
func (*RegistrationResponse) Descriptor() ([]byte, []int) {
return file_auth_proto_rawDescGZIP(), []int{3}
}
// Подтверждение пользователя
type ConfirmationRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
}
func (x *ConfirmationRequest) Reset() {
*x = ConfirmationRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_auth_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *ConfirmationRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ConfirmationRequest) ProtoMessage() {}
func (x *ConfirmationRequest) ProtoReflect() protoreflect.Message {
mi := &file_auth_proto_msgTypes[4]
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 ConfirmationRequest.ProtoReflect.Descriptor instead.
func (*ConfirmationRequest) Descriptor() ([]byte, []int) {
return file_auth_proto_rawDescGZIP(), []int{4}
}
type ConfirmationResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
}
func (x *ConfirmationResponse) Reset() {
*x = ConfirmationResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_auth_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *ConfirmationResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ConfirmationResponse) ProtoMessage() {}
func (x *ConfirmationResponse) ProtoReflect() protoreflect.Message {
mi := &file_auth_proto_msgTypes[5]
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 ConfirmationResponse.ProtoReflect.Descriptor instead.
func (*ConfirmationResponse) Descriptor() ([]byte, []int) {
return file_auth_proto_rawDescGZIP(), []int{5}
}
var File_auth_proto protoreflect.FileDescriptor
var file_auth_proto_rawDesc = []byte{
0x0a, 0x0a, 0x61, 0x75, 0x74, 0x68, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x04, 0x61, 0x75,
0x74, 0x68, 0x22, 0x0e, 0x0a, 0x0c, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65,
0x73, 0x74, 0x22, 0x0f, 0x0a, 0x0d, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f,
0x6e, 0x73, 0x65, 0x22, 0x15, 0x0a, 0x13, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x61, 0x74,
0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x16, 0x0a, 0x14, 0x52, 0x65,
0x67, 0x69, 0x73, 0x74, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e,
0x73, 0x65, 0x22, 0x15, 0x0a, 0x13, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x72, 0x6d, 0x61, 0x74, 0x69,
0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x16, 0x0a, 0x14, 0x43, 0x6f, 0x6e,
0x66, 0x69, 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
0x65, 0x32, 0xce, 0x01, 0x0a, 0x06, 0x41, 0x75, 0x74, 0x68, 0x44, 0x42, 0x12, 0x32, 0x0a, 0x05,
0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x12, 0x12, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x2e, 0x4c, 0x6f, 0x67,
0x69, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x13, 0x2e, 0x61, 0x75, 0x74, 0x68,
0x2e, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00,
0x12, 0x47, 0x0a, 0x0c, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e,
0x12, 0x19, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x61,
0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x61, 0x75,
0x74, 0x68, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52,
0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x47, 0x0a, 0x0c, 0x43, 0x6f, 0x6e,
0x66, 0x69, 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x19, 0x2e, 0x61, 0x75, 0x74, 0x68,
0x2e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71,
0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x2e, 0x43, 0x6f, 0x6e, 0x66,
0x69, 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
0x22, 0x00, 0x42, 0x04, 0x5a, 0x02, 0x2e, 0x2f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
file_auth_proto_rawDescOnce sync.Once
file_auth_proto_rawDescData = file_auth_proto_rawDesc
)
func file_auth_proto_rawDescGZIP() []byte {
file_auth_proto_rawDescOnce.Do(func() {
file_auth_proto_rawDescData = protoimpl.X.CompressGZIP(file_auth_proto_rawDescData)
})
return file_auth_proto_rawDescData
}
var file_auth_proto_msgTypes = make([]protoimpl.MessageInfo, 6)
var file_auth_proto_goTypes = []interface{}{
(*LoginRequest)(nil), // 0: auth.LoginRequest
(*LoginResponse)(nil), // 1: auth.LoginResponse
(*RegistrationRequest)(nil), // 2: auth.RegistrationRequest
(*RegistrationResponse)(nil), // 3: auth.RegistrationResponse
(*ConfirmationRequest)(nil), // 4: auth.ConfirmationRequest
(*ConfirmationResponse)(nil), // 5: auth.ConfirmationResponse
}
var file_auth_proto_depIdxs = []int32{
0, // 0: auth.AuthDB.Login:input_type -> auth.LoginRequest
2, // 1: auth.AuthDB.Registration:input_type -> auth.RegistrationRequest
4, // 2: auth.AuthDB.Confirmation:input_type -> auth.ConfirmationRequest
1, // 3: auth.AuthDB.Login:output_type -> auth.LoginResponse
3, // 4: auth.AuthDB.Registration:output_type -> auth.RegistrationResponse
5, // 5: auth.AuthDB.Confirmation:output_type -> auth.ConfirmationResponse
3, // [3:6] is the sub-list for method output_type
0, // [0:3] 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_auth_proto_init() }
func file_auth_proto_init() {
if File_auth_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_auth_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*LoginRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_auth_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*LoginResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_auth_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*RegistrationRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_auth_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*RegistrationResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_auth_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ConfirmationRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_auth_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ConfirmationResponse); 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_auth_proto_rawDesc,
NumEnums: 0,
NumMessages: 6,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_auth_proto_goTypes,
DependencyIndexes: file_auth_proto_depIdxs,
MessageInfos: file_auth_proto_msgTypes,
}.Build()
File_auth_proto = out.File
file_auth_proto_rawDesc = nil
file_auth_proto_goTypes = nil
file_auth_proto_depIdxs = nil
}

@ -0,0 +1,177 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.2.0
// - protoc v3.6.1
// source: auth.proto
package __
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
// AuthDBClient is the client API for AuthDB 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 AuthDBClient interface {
Login(ctx context.Context, in *LoginRequest, opts ...grpc.CallOption) (*LoginResponse, error)
Registration(ctx context.Context, in *RegistrationRequest, opts ...grpc.CallOption) (*RegistrationResponse, error)
Confirmation(ctx context.Context, in *ConfirmationRequest, opts ...grpc.CallOption) (*ConfirmationResponse, error)
}
type authDBClient struct {
cc grpc.ClientConnInterface
}
func NewAuthDBClient(cc grpc.ClientConnInterface) AuthDBClient {
return &authDBClient{cc}
}
func (c *authDBClient) Login(ctx context.Context, in *LoginRequest, opts ...grpc.CallOption) (*LoginResponse, error) {
out := new(LoginResponse)
err := c.cc.Invoke(ctx, "/auth.AuthDB/Login", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *authDBClient) Registration(ctx context.Context, in *RegistrationRequest, opts ...grpc.CallOption) (*RegistrationResponse, error) {
out := new(RegistrationResponse)
err := c.cc.Invoke(ctx, "/auth.AuthDB/Registration", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *authDBClient) Confirmation(ctx context.Context, in *ConfirmationRequest, opts ...grpc.CallOption) (*ConfirmationResponse, error) {
out := new(ConfirmationResponse)
err := c.cc.Invoke(ctx, "/auth.AuthDB/Confirmation", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// AuthDBServer is the server API for AuthDB service.
// All implementations must embed UnimplementedAuthDBServer
// for forward compatibility
type AuthDBServer interface {
Login(context.Context, *LoginRequest) (*LoginResponse, error)
Registration(context.Context, *RegistrationRequest) (*RegistrationResponse, error)
Confirmation(context.Context, *ConfirmationRequest) (*ConfirmationResponse, error)
mustEmbedUnimplementedAuthDBServer()
}
// UnimplementedAuthDBServer must be embedded to have forward compatible implementations.
type UnimplementedAuthDBServer struct {
}
func (UnimplementedAuthDBServer) Login(context.Context, *LoginRequest) (*LoginResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method Login not implemented")
}
func (UnimplementedAuthDBServer) Registration(context.Context, *RegistrationRequest) (*RegistrationResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method Registration not implemented")
}
func (UnimplementedAuthDBServer) Confirmation(context.Context, *ConfirmationRequest) (*ConfirmationResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method Confirmation not implemented")
}
func (UnimplementedAuthDBServer) mustEmbedUnimplementedAuthDBServer() {}
// UnsafeAuthDBServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to AuthDBServer will
// result in compilation errors.
type UnsafeAuthDBServer interface {
mustEmbedUnimplementedAuthDBServer()
}
func RegisterAuthDBServer(s grpc.ServiceRegistrar, srv AuthDBServer) {
s.RegisterService(&AuthDB_ServiceDesc, srv)
}
func _AuthDB_Login_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(LoginRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(AuthDBServer).Login(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/auth.AuthDB/Login",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(AuthDBServer).Login(ctx, req.(*LoginRequest))
}
return interceptor(ctx, in, info, handler)
}
func _AuthDB_Registration_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(RegistrationRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(AuthDBServer).Registration(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/auth.AuthDB/Registration",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(AuthDBServer).Registration(ctx, req.(*RegistrationRequest))
}
return interceptor(ctx, in, info, handler)
}
func _AuthDB_Confirmation_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ConfirmationRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(AuthDBServer).Confirmation(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/auth.AuthDB/Confirmation",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(AuthDBServer).Confirmation(ctx, req.(*ConfirmationRequest))
}
return interceptor(ctx, in, info, handler)
}
// AuthDB_ServiceDesc is the grpc.ServiceDesc for AuthDB service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var AuthDB_ServiceDesc = grpc.ServiceDesc{
ServiceName: "auth.AuthDB",
HandlerType: (*AuthDBServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "Login",
Handler: _AuthDB_Login_Handler,
},
{
MethodName: "Registration",
Handler: _AuthDB_Registration_Handler,
},
{
MethodName: "Confirmation",
Handler: _AuthDB_Confirmation_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "auth.proto",
}
Loading…
Cancel
Save