diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..2e549f1 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,21 @@ +# [Задача №00000000](https://bigbosop215.kaiten.ru/space/439413/card/00000000) + +### Что было не так: +<описание проблемы/причины заведения новой фичи> +### Что было сделано: +* слой repository; +* добавлена валидация на уникальность email; +* ручка на получение подборок фильмов; +* написаны тесты и моки. +### Чек лист до ревью : +- [ ] PR разбит на логические коммиты (если нет, то нужно разбить); +- [ ] PR не содержит секретов (пароли, токены, ключи); +- [ ] PR не содержит лишних файлов (например, `.env`); +- [ ] PR не содержит коммитов, которые не относятся к задаче; + +**Перед тем, как отдать на ревью нужно убедиться, что все пункты выполнены** + + ### как вливать ветку + Если это обычная задача, то просто `squash merge` в `develop` + Если это хотфикс, то обычный `merge` в `master` и `develop` (должно быть два `pull request`). При этом в ветке должен быть один коммит + Если это релиз, то обычный `merge` и в `master` и в `develop`. Там будет несколько коммитов diff --git a/.gitignore b/.gitignore index 3b44850..f79e50f 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /validation-service/bin/ +/validation-service/.env diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..93e1072 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,40 @@ +version: '3.9' + +volumes: + postgres_volume: + redis: + +services: + validation_ms: + build: + context: ./validation-service/ + dockerfile: Dockerfile + restart: always + ports: + - 5050:5050 + networks: + - netflix + redis: + image: 'redis:latest' + command: redis-server + volumes: + - redis:/data + networks: + - netflix + db: + image: postgres:latest + environment: + - "POSTGRES_DB=netflix" + - "POSTGRES_USER=test" + - "POSTGRES_PASSWORD=test" + volumes: + - "postgres_volume:/var/lib/postgresql/data" + networks: + - netflix + + +networks: + netflix: + default: + external: + name: netflix # Не забыть создать сеть перед деплоем diff --git a/validation-service/Dockerfile b/validation-service/Dockerfile index fe3bdf2..d3f4566 100644 --- a/validation-service/Dockerfile +++ b/validation-service/Dockerfile @@ -10,9 +10,9 @@ RUN go mod download RUN go mod tidy RUN go build cmd/main.go -EXPOSE 8081 +EXPOSE 5050 -CMD [ "main" ] +CMD [ "./main" ] # /app/ # /api diff --git a/validation-service/api/validation/validation.proto b/validation-service/api/validation/validation.proto index 65f69dc..a4f3709 100644 --- a/validation-service/api/validation/validation.proto +++ b/validation-service/api/validation/validation.proto @@ -4,15 +4,14 @@ package validation; option go_package = "."; +import "google/protobuf/timestamp.proto"; + message ValidateRegistrationRequest { string email = 1; string password = 2; string password_confirm = 3; -} - -message ValidateAuthorizationRequest { - string email = 1; - string password = 2; + int32 sex = 4; + google.protobuf.Timestamp bitrhdate = 5; } message ErrorMessage { @@ -27,5 +26,4 @@ message ValidationResponse { service Validation { rpc ValidateRegistration(ValidateRegistrationRequest) returns (ValidationResponse); - rpc ValidateAuthorization(ValidateAuthorizationRequest) returns (ValidationResponse); } diff --git a/validation-service/cmd/main.go b/validation-service/cmd/main.go index fe7f767..b99fabf 100644 --- a/validation-service/cmd/main.go +++ b/validation-service/cmd/main.go @@ -1,5 +1,17 @@ package main +import ( + "log" + + "github.com/go-park-mail-ru/2024_2_GOATS/validation-service/internal/app" +) + func main() { - + a, ctx, err := app.New() + + if err != nil { + log.Fatal(err) + } + + a.Run(ctx) } diff --git a/validation-service/config/config.go b/validation-service/config/config.go new file mode 100644 index 0000000..4485748 --- /dev/null +++ b/validation-service/config/config.go @@ -0,0 +1,15 @@ +package config + +type Config struct { + Listener Listener `yaml:"listener"` +} + +type Listener struct { + Address string `yaml:"address"` + Port int `yaml:"port"` +} + +type ConfigContextKey struct { + Address string + Port int +} diff --git a/validation-service/config/config_methods.go b/validation-service/config/config_methods.go new file mode 100644 index 0000000..148925f --- /dev/null +++ b/validation-service/config/config_methods.go @@ -0,0 +1,53 @@ +package config + +import ( + "context" + "log" + "os" + "path/filepath" + + "github.com/joho/godotenv" + "gopkg.in/yaml.v3" +) + +func GetConfigFromContext(ctx context.Context) *Config { + value, ok := ctx.Value(ConfigContextKey{}).(*Config) + if !ok { + return nil + } + + return value +} + +func CreateConfigContext() (context.Context, error) { + ctx := context.Background() + config, err := readConf() + if err != nil { + return nil, err + } + + return context.WithValue(ctx, ConfigContextKey{}, config), nil +} + +func readConf() (*Config, error) { + err := godotenv.Load() + + if err != nil { + log.Fatalf("Error loading .env file", err) + } + + cfg := &Config{} + + filename, _ := filepath.Abs(os.Getenv("CFG_PATH")) + data, err := os.ReadFile(filename) + if err != nil { + return nil, err + } + + err = yaml.Unmarshal(data, cfg) + if err != nil { + return nil, err + } + + return cfg, nil +} diff --git a/validation-service/go.mod b/validation-service/go.mod index c2d46f4..b827fbc 100644 --- a/validation-service/go.mod +++ b/validation-service/go.mod @@ -1,8 +1,18 @@ -module github.com/go-park-mail-ru/2024_2_GOATS +module github.com/go-park-mail-ru/2024_2_GOATS/validation-service go 1.22.2 require ( + google.golang.org/grpc v1.65.0 + google.golang.org/protobuf v1.34.2 +) + +require ( + github.com/joho/godotenv v1.5.1 // indirect + golang.org/x/net v0.26.0 // indirect + golang.org/x/sys v0.21.0 // indirect + golang.org/x/text v0.16.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240604185151-ef581f913117 // indirect google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.5.1 // indirect - google.golang.org/protobuf v1.34.2 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/validation-service/go.sum b/validation-service/go.sum index 3fdec68..ced6d18 100644 --- a/validation-service/go.sum +++ b/validation-service/go.sum @@ -1,4 +1,21 @@ +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0= +github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= +golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ= +golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE= +golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws= +golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= +golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240604185151-ef581f913117 h1:1GBuWVLM/KMVUv1t1En5Gs+gFZCNd360GGb4sSxtrhU= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240604185151-ef581f913117/go.mod h1:EfXuqaE1J41VCDicxHzUDm+8rk+7ZdXzHV0IhO/I6s0= +google.golang.org/grpc v1.65.0 h1:bs/cUb4lp1G5iImFFd3u5ixQzweKizoZJAwBNLR42lc= +google.golang.org/grpc v1.65.0/go.mod h1:WgYC2ypjlB0EiQi6wdKixMqukr6lBc0Vo+oOgjrM5ZQ= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.5.1 h1:F29+wU6Ee6qgu9TddPgooOdaqsxTMunOoj8KA5yuS5A= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.5.1/go.mod h1:5KF+wpkbTSbGcR9zteSqZV6fqFOWBl4Yde8En8MryZA= google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/validation-service/internal/app/api/converter/converter.go b/validation-service/internal/app/api/converter/converter.go index 89f617e..3b63422 100644 --- a/validation-service/internal/app/api/converter/converter.go +++ b/validation-service/internal/app/api/converter/converter.go @@ -1 +1,27 @@ package converter + +import ( + "github.com/go-park-mail-ru/2024_2_GOATS/validation-service/internal/app/model" + desc "github.com/go-park-mail-ru/2024_2_GOATS/validation-service/internal/pb/validation" + "google.golang.org/protobuf/types/known/timestamppb" +) + +func ToUserRegisterDataFromDesc(data *desc.ValidateRegistrationRequest) *model.UserRegisterData { + birthday := data.GetBitrhdate().AsTime() + ts := timestamppb.New(birthday) + + return &model.UserRegisterData{ + Email: data.GetEmail(), + Password: data.GetPassword(), + PasswordConfirm: data.GetPasswordConfirm(), + Sex: data.GetSex(), + Birthday: int(ts.Seconds), + } +} + +func ToErrorsFromServ(data *model.ErrorResponse) *desc.ErrorMessage { + return &desc.ErrorMessage{ + Code: data.Code, + Error: data.ErrorObj.Error(), + } +} diff --git a/validation-service/internal/app/api/validation/handler.go b/validation-service/internal/app/api/validation/handler.go index abeebd1..d36b1e9 100644 --- a/validation-service/internal/app/api/validation/handler.go +++ b/validation-service/internal/app/api/validation/handler.go @@ -1 +1,25 @@ -package handler +package validation + +import ( + "context" + + "github.com/go-park-mail-ru/2024_2_GOATS/validation-service/internal/app/model" + desc "github.com/go-park-mail-ru/2024_2_GOATS/validation-service/internal/pb/validation" +) + +type ValidationService interface { + ValidateRegistration(ctx context.Context, userData *model.UserRegisterData) *model.ValidationResponse +} + +type Implementation struct { + desc.UnimplementedValidationServer + ctx context.Context + validationService ValidationService +} + +func NewImplementation(ctx context.Context, validationService ValidationService) *Implementation { + return &Implementation{ + ctx: ctx, + validationService: validationService, + } +} diff --git a/validation-service/internal/app/api/validation/validation.go b/validation-service/internal/app/api/validation/validation.go new file mode 100644 index 0000000..74c1f0b --- /dev/null +++ b/validation-service/internal/app/api/validation/validation.go @@ -0,0 +1,21 @@ +package validation + +import ( + "context" + + "github.com/go-park-mail-ru/2024_2_GOATS/validation-service/internal/app/api/converter" + desc "github.com/go-park-mail-ru/2024_2_GOATS/validation-service/internal/pb/validation" +) + +func (i *Implementation) ValidateRegistration(ctx context.Context, req *desc.ValidateRegistrationRequest) (*desc.ValidationResponse, error) { + validData := i.validationService.ValidateRegistration(i.ctx, converter.ToUserRegisterDataFromDesc(req)) + descErrors := make([]*desc.ErrorMessage, 0) + for _, errData := range validData.Errors { + descErrors = append(descErrors, converter.ToErrorsFromServ(&errData)) + } + + return &desc.ValidationResponse{ + Success: validData.Success, + Errors: descErrors, + }, nil +} diff --git a/validation-service/internal/app/app.go b/validation-service/internal/app/app.go index 1110061..970ea5e 100644 --- a/validation-service/internal/app/app.go +++ b/validation-service/internal/app/app.go @@ -1,3 +1,49 @@ -package main +package app +import ( + "context" + "fmt" + "log" + "net" + "google.golang.org/grpc" + "google.golang.org/grpc/reflection" + + "github.com/go-park-mail-ru/2024_2_GOATS/validation-service/config" + validationAPI "github.com/go-park-mail-ru/2024_2_GOATS/validation-service/internal/app/api/validation" + validationService "github.com/go-park-mail-ru/2024_2_GOATS/validation-service/internal/app/service/validation" + desc "github.com/go-park-mail-ru/2024_2_GOATS/validation-service/internal/pb/validation" +) + +type App struct { + validationService validationAPI.ValidationService +} + +func New() (*App, context.Context, error) { + ctx, err := config.CreateConfigContext() + if err != nil { + log.Fatal("Failed to read config: %v", err) + } + + return &App{ + validationService: validationService.NewService(ctx), + }, ctx, nil +} + +func (a *App) Run(ctx context.Context) { + cfg := config.GetConfigFromContext(ctx) + lis, err := net.Listen("tcp", fmt.Sprintf(":%d", cfg.Listener.Port)) + if err != nil { + log.Fatal("Failed to listen: %v", err) + } + + s := grpc.NewServer() + reflection.Register(s) + desc.RegisterValidationServer(s, validationAPI.NewImplementation(ctx, a.validationService)) + + log.Printf("Server listening at %v:%d", cfg.Listener.Address, cfg.Listener.Port) + + if err = s.Serve(lis); err != nil { + log.Fatalf("failed to serve: %v", err) + } +} diff --git a/validation-service/internal/app/errors/errors.go b/validation-service/internal/app/errors/errors.go new file mode 100644 index 0000000..ad02eb1 --- /dev/null +++ b/validation-service/internal/app/errors/errors.go @@ -0,0 +1,14 @@ +package errors + +import "errors" + +var ( + ErrInvalidEmailCode = "invalid_email" + ErrInvalidEmailText = errors.New("email is incorrect") + ErrInvalidPasswordCode = "invalid_password" + ErrInvalidPasswordText = errors.New("password is too short. The minimal len is 8") + ErrInvalidSexCode = "invalid_sex" + ErrInvalidSexText = errors.New("only male or female allowed") + ErrInvalidBirthdateCode = "invalid_birthdate" + ErrInvalidBirthdateText = errors.New("bithdate should be before current time") +) diff --git a/validation-service/internal/app/model/validation.go b/validation-service/internal/app/model/validation.go index 8b53790..d21f637 100644 --- a/validation-service/internal/app/model/validation.go +++ b/validation-service/internal/app/model/validation.go @@ -1 +1,19 @@ package model + +type UserRegisterData struct { + Email string + Password string + PasswordConfirm string + Sex int32 + Birthday int +} + +type ErrorResponse struct { + Code string + ErrorObj error +} + +type ValidationResponse struct { + Success bool + Errors []ErrorResponse +} diff --git a/validation-service/internal/app/repository/converter/converter.go b/validation-service/internal/app/repository/converter/converter.go deleted file mode 100644 index 89f617e..0000000 --- a/validation-service/internal/app/repository/converter/converter.go +++ /dev/null @@ -1 +0,0 @@ -package converter diff --git a/validation-service/internal/app/repository/repository.go b/validation-service/internal/app/repository/repository.go deleted file mode 100644 index 50a4378..0000000 --- a/validation-service/internal/app/repository/repository.go +++ /dev/null @@ -1 +0,0 @@ -package repository diff --git a/validation-service/internal/app/repository/validation/registration_validation.go b/validation-service/internal/app/repository/validation/registration_validation.go deleted file mode 100644 index 958ae1a..0000000 --- a/validation-service/internal/app/repository/validation/registration_validation.go +++ /dev/null @@ -1 +0,0 @@ -package validation diff --git a/validation-service/internal/app/service/converter/converter.go b/validation-service/internal/app/service/converter/converter.go deleted file mode 100644 index 89f617e..0000000 --- a/validation-service/internal/app/service/converter/converter.go +++ /dev/null @@ -1 +0,0 @@ -package converter diff --git a/validation-service/internal/app/service/service.go b/validation-service/internal/app/service/service.go deleted file mode 100644 index 6d43c33..0000000 --- a/validation-service/internal/app/service/service.go +++ /dev/null @@ -1 +0,0 @@ -package service diff --git a/validation-service/internal/app/service/validation/helpers/user_helper.go b/validation-service/internal/app/service/validation/helpers/user_helper.go new file mode 100644 index 0000000..eefb246 --- /dev/null +++ b/validation-service/internal/app/service/validation/helpers/user_helper.go @@ -0,0 +1,62 @@ +package helpers + +import ( + "log" + "regexp" + "slices" + "time" + + errVals "github.com/go-park-mail-ru/2024_2_GOATS/validation-service/internal/app/errors" + "google.golang.org/protobuf/types/known/timestamppb" +) + +const PasswordLength = 8 +const Male = 0 +const Female = 1 +const Other = 2 + +var ( + emailRegex = regexp.MustCompile("^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$") + sexVals = []int32{Male, Female, Other} +) + +func ValidatePassword(pass, passConf string) error { + if passConf == "" { + log.Println("password confirm is missing, but now its OK") + } + + if len(pass) < PasswordLength { + log.Println(errVals.ErrInvalidPasswordText.Error()) + return errVals.ErrInvalidPasswordText + } + + return nil +} + +func ValidateEmail(email string) error { + if !emailRegex.MatchString(email) { + log.Println(errVals.ErrInvalidEmailText.Error()) + return errVals.ErrInvalidEmailText + } + + return nil +} + +func ValidateBirthdate(birthdate int) error { + ts := timestamppb.New(time.Now()) + if int(ts.Seconds) < birthdate { + log.Println(errVals.ErrInvalidBirthdateText.Error()) + return errVals.ErrInvalidBirthdateText + } + + return nil +} + +func ValidateSex(sex int32) error { + if !slices.Contains(sexVals, sex) { + log.Println(errVals.ErrInvalidSexText.Error()) + return errVals.ErrInvalidSexText + } + + return nil +} diff --git a/validation-service/internal/app/service/validation/registartion_validation.go b/validation-service/internal/app/service/validation/registartion_validation.go deleted file mode 100644 index 958ae1a..0000000 --- a/validation-service/internal/app/service/validation/registartion_validation.go +++ /dev/null @@ -1 +0,0 @@ -package validation diff --git a/validation-service/internal/app/service/validation/validate_registration.go b/validation-service/internal/app/service/validation/validate_registration.go new file mode 100644 index 0000000..9664c28 --- /dev/null +++ b/validation-service/internal/app/service/validation/validate_registration.go @@ -0,0 +1,46 @@ +package validation + +import ( + "context" + + errVals "github.com/go-park-mail-ru/2024_2_GOATS/validation-service/internal/app/errors" + "github.com/go-park-mail-ru/2024_2_GOATS/validation-service/internal/app/model" + userHelper "github.com/go-park-mail-ru/2024_2_GOATS/validation-service/internal/app/service/validation/helpers" +) + +func (s *serv) ValidateRegistration(ctx context.Context, userData *model.UserRegisterData) *model.ValidationResponse { + success := true + errors := make([]model.ErrorResponse, 0) + + if err := userHelper.ValidatePassword(userData.Password, userData.PasswordConfirm); err != nil { + success = AddError(errVals.ErrInvalidPasswordCode, err, &errors) + } + + if err := userHelper.ValidateEmail(userData.Email); err != nil { + success = AddError(errVals.ErrInvalidEmailCode, err, &errors) + } + + if err := userHelper.ValidateBirthdate(userData.Birthday); err != nil { + success = AddError(errVals.ErrInvalidBirthdateCode, err, &errors) + } + + if err := userHelper.ValidateSex(userData.Sex); err != nil { + success = AddError(errVals.ErrInvalidSexCode, err, &errors) + } + + return &model.ValidationResponse{ + Success: success, + Errors: errors, + } +} + +func AddError(code string, err error, errors *[]model.ErrorResponse) bool { + errStruct := model.ErrorResponse{ + Code: code, + ErrorObj: err, + } + + *errors = append(*errors, errStruct) + + return false +} diff --git a/validation-service/internal/app/service/validation/validation.go b/validation-service/internal/app/service/validation/validation.go new file mode 100644 index 0000000..c14cb33 --- /dev/null +++ b/validation-service/internal/app/service/validation/validation.go @@ -0,0 +1,19 @@ +package validation + +import ( + "context" + + api "github.com/go-park-mail-ru/2024_2_GOATS/validation-service/internal/app/api/validation" +) + +var _ api.ValidationService = (*serv)(nil) + +type serv struct{ + ctx context.Context +} + +func NewService(ctx context.Context) *serv { + return &serv{ + ctx: ctx, + } +} diff --git a/validation-service/internal/config/config.go b/validation-service/internal/config/config.go deleted file mode 100644 index d912156..0000000 --- a/validation-service/internal/config/config.go +++ /dev/null @@ -1 +0,0 @@ -package config diff --git a/validation-service/internal/config/config.yml b/validation-service/internal/config/config.yml new file mode 100644 index 0000000..f07d424 --- /dev/null +++ b/validation-service/internal/config/config.yml @@ -0,0 +1,3 @@ +listener: + address: localhost + port: 5050 diff --git a/validation-service/internal/pb/validation/validation.pb.go b/validation-service/internal/pb/validation/validation.pb.go index 4b75fd6..145561e 100644 --- a/validation-service/internal/pb/validation/validation.pb.go +++ b/validation-service/internal/pb/validation/validation.pb.go @@ -9,6 +9,7 @@ package __ import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + timestamppb "google.golang.org/protobuf/types/known/timestamppb" reflect "reflect" sync "sync" ) @@ -25,9 +26,11 @@ type ValidateRegistrationRequest struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Email string `protobuf:"bytes,1,opt,name=email,proto3" json:"email,omitempty"` - Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"` - PasswordConfirm string `protobuf:"bytes,3,opt,name=password_confirm,json=passwordConfirm,proto3" json:"password_confirm,omitempty"` + Email string `protobuf:"bytes,1,opt,name=email,proto3" json:"email,omitempty"` + Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"` + PasswordConfirm string `protobuf:"bytes,3,opt,name=password_confirm,json=passwordConfirm,proto3" json:"password_confirm,omitempty"` + Sex int32 `protobuf:"varint,4,opt,name=sex,proto3" json:"sex,omitempty"` + Bitrhdate *timestamppb.Timestamp `protobuf:"bytes,5,opt,name=bitrhdate,proto3" json:"bitrhdate,omitempty"` } func (x *ValidateRegistrationRequest) Reset() { @@ -83,59 +86,18 @@ func (x *ValidateRegistrationRequest) GetPasswordConfirm() string { return "" } -type ValidateAuthorizationRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Email string `protobuf:"bytes,1,opt,name=email,proto3" json:"email,omitempty"` - Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"` -} - -func (x *ValidateAuthorizationRequest) Reset() { - *x = ValidateAuthorizationRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_validation_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ValidateAuthorizationRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ValidateAuthorizationRequest) ProtoMessage() {} - -func (x *ValidateAuthorizationRequest) ProtoReflect() protoreflect.Message { - mi := &file_validation_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 ValidateAuthorizationRequest.ProtoReflect.Descriptor instead. -func (*ValidateAuthorizationRequest) Descriptor() ([]byte, []int) { - return file_validation_proto_rawDescGZIP(), []int{1} -} - -func (x *ValidateAuthorizationRequest) GetEmail() string { +func (x *ValidateRegistrationRequest) GetSex() int32 { if x != nil { - return x.Email + return x.Sex } - return "" + return 0 } -func (x *ValidateAuthorizationRequest) GetPassword() string { +func (x *ValidateRegistrationRequest) GetBitrhdate() *timestamppb.Timestamp { if x != nil { - return x.Password + return x.Bitrhdate } - return "" + return nil } type ErrorMessage struct { @@ -150,7 +112,7 @@ type ErrorMessage struct { func (x *ErrorMessage) Reset() { *x = ErrorMessage{} if protoimpl.UnsafeEnabled { - mi := &file_validation_proto_msgTypes[2] + mi := &file_validation_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -163,7 +125,7 @@ func (x *ErrorMessage) String() string { func (*ErrorMessage) ProtoMessage() {} func (x *ErrorMessage) ProtoReflect() protoreflect.Message { - mi := &file_validation_proto_msgTypes[2] + mi := &file_validation_proto_msgTypes[1] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -176,7 +138,7 @@ func (x *ErrorMessage) ProtoReflect() protoreflect.Message { // Deprecated: Use ErrorMessage.ProtoReflect.Descriptor instead. func (*ErrorMessage) Descriptor() ([]byte, []int) { - return file_validation_proto_rawDescGZIP(), []int{2} + return file_validation_proto_rawDescGZIP(), []int{1} } func (x *ErrorMessage) GetCode() string { @@ -199,13 +161,13 @@ type ValidationResponse struct { unknownFields protoimpl.UnknownFields Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"` - Error []*ErrorMessage `protobuf:"bytes,2,rep,name=error,proto3" json:"error,omitempty"` + Errors []*ErrorMessage `protobuf:"bytes,2,rep,name=errors,proto3" json:"errors,omitempty"` } func (x *ValidationResponse) Reset() { *x = ValidationResponse{} if protoimpl.UnsafeEnabled { - mi := &file_validation_proto_msgTypes[3] + mi := &file_validation_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -218,7 +180,7 @@ func (x *ValidationResponse) String() string { func (*ValidationResponse) ProtoMessage() {} func (x *ValidationResponse) ProtoReflect() protoreflect.Message { - mi := &file_validation_proto_msgTypes[3] + mi := &file_validation_proto_msgTypes[2] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -231,7 +193,7 @@ func (x *ValidationResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use ValidationResponse.ProtoReflect.Descriptor instead. func (*ValidationResponse) Descriptor() ([]byte, []int) { - return file_validation_proto_rawDescGZIP(), []int{3} + return file_validation_proto_rawDescGZIP(), []int{2} } func (x *ValidationResponse) GetSuccess() bool { @@ -241,9 +203,9 @@ func (x *ValidationResponse) GetSuccess() bool { return false } -func (x *ValidationResponse) GetError() []*ErrorMessage { +func (x *ValidationResponse) GetErrors() []*ErrorMessage { if x != nil { - return x.Error + return x.Errors } return nil } @@ -252,45 +214,39 @@ var File_validation_proto protoreflect.FileDescriptor var file_validation_proto_rawDesc = []byte{ 0x0a, 0x10, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x12, 0x0d, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x76, - 0x31, 0x22, 0x7a, 0x0a, 0x1b, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x67, - 0x69, 0x73, 0x74, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x12, 0x14, 0x0a, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, - 0x72, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, - 0x72, 0x64, 0x12, 0x29, 0x0a, 0x10, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x5f, 0x63, - 0x6f, 0x6e, 0x66, 0x69, 0x72, 0x6d, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x70, 0x61, - 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x72, 0x6d, 0x22, 0x50, 0x0a, - 0x1c, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x41, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, - 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, - 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x6d, - 0x61, 0x69, 0x6c, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x22, - 0x38, 0x0a, 0x0c, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, - 0x12, 0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x63, - 0x6f, 0x64, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x22, 0x61, 0x0a, 0x12, 0x56, 0x61, 0x6c, - 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, - 0x18, 0x0a, 0x07, 0x73, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, - 0x52, 0x07, 0x73, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x12, 0x31, 0x0a, 0x05, 0x65, 0x72, 0x72, - 0x6f, 0x72, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x76, 0x61, 0x6c, 0x69, 0x64, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x76, 0x31, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x4d, 0x65, - 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x32, 0xde, 0x01, 0x0a, - 0x0c, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x56, 0x31, 0x12, 0x65, 0x0a, - 0x14, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x2a, 0x2e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, - 0x6f, 0x6e, 0x5f, 0x76, 0x31, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, - 0x67, 0x69, 0x73, 0x74, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x1a, 0x21, 0x2e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x76, - 0x31, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x67, 0x0a, 0x15, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, - 0x41, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x2b, 0x2e, - 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x76, 0x31, 0x2e, 0x56, 0x61, - 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x41, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x7a, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x76, 0x61, 0x6c, - 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x76, 0x31, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x03, 0x5a, - 0x01, 0x2e, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x74, 0x6f, 0x12, 0x0a, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x1a, 0x1f, + 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, + 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, + 0xc6, 0x01, 0x0a, 0x1b, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x67, 0x69, + 0x73, 0x74, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, + 0x14, 0x0a, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, + 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, + 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, + 0x64, 0x12, 0x29, 0x0a, 0x10, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x5f, 0x63, 0x6f, + 0x6e, 0x66, 0x69, 0x72, 0x6d, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x70, 0x61, 0x73, + 0x73, 0x77, 0x6f, 0x72, 0x64, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x72, 0x6d, 0x12, 0x10, 0x0a, 0x03, + 0x73, 0x65, 0x78, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x73, 0x65, 0x78, 0x12, 0x38, + 0x0a, 0x09, 0x62, 0x69, 0x74, 0x72, 0x68, 0x64, 0x61, 0x74, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x62, + 0x69, 0x74, 0x72, 0x68, 0x64, 0x61, 0x74, 0x65, 0x22, 0x38, 0x0a, 0x0c, 0x45, 0x72, 0x72, 0x6f, + 0x72, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x12, 0x14, 0x0a, 0x05, + 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x72, 0x72, + 0x6f, 0x72, 0x22, 0x60, 0x0a, 0x12, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x75, 0x63, 0x63, + 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x73, 0x75, 0x63, 0x63, 0x65, + 0x73, 0x73, 0x12, 0x30, 0x0a, 0x06, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x73, 0x18, 0x02, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, + 0x45, 0x72, 0x72, 0x6f, 0x72, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x06, 0x65, 0x72, + 0x72, 0x6f, 0x72, 0x73, 0x32, 0x6d, 0x0a, 0x0a, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x12, 0x5f, 0x0a, 0x14, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, + 0x67, 0x69, 0x73, 0x74, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x27, 0x2e, 0x76, 0x61, 0x6c, + 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, + 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x1e, 0x2e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x42, 0x03, 0x5a, 0x01, 0x2e, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -305,24 +261,23 @@ func file_validation_proto_rawDescGZIP() []byte { return file_validation_proto_rawDescData } -var file_validation_proto_msgTypes = make([]protoimpl.MessageInfo, 4) +var file_validation_proto_msgTypes = make([]protoimpl.MessageInfo, 3) var file_validation_proto_goTypes = []any{ - (*ValidateRegistrationRequest)(nil), // 0: validation_v1.ValidateRegistrationRequest - (*ValidateAuthorizationRequest)(nil), // 1: validation_v1.ValidateAuthorizationRequest - (*ErrorMessage)(nil), // 2: validation_v1.ErrorMessage - (*ValidationResponse)(nil), // 3: validation_v1.ValidationResponse + (*ValidateRegistrationRequest)(nil), // 0: validation.ValidateRegistrationRequest + (*ErrorMessage)(nil), // 1: validation.ErrorMessage + (*ValidationResponse)(nil), // 2: validation.ValidationResponse + (*timestamppb.Timestamp)(nil), // 3: google.protobuf.Timestamp } var file_validation_proto_depIdxs = []int32{ - 2, // 0: validation_v1.ValidationResponse.error:type_name -> validation_v1.ErrorMessage - 0, // 1: validation_v1.ValidationV1.ValidateRegistration:input_type -> validation_v1.ValidateRegistrationRequest - 1, // 2: validation_v1.ValidationV1.ValidateAuthorization:input_type -> validation_v1.ValidateAuthorizationRequest - 3, // 3: validation_v1.ValidationV1.ValidateRegistration:output_type -> validation_v1.ValidationResponse - 3, // 4: validation_v1.ValidationV1.ValidateAuthorization:output_type -> validation_v1.ValidationResponse - 3, // [3:5] is the sub-list for method output_type - 1, // [1:3] is the sub-list for method input_type - 1, // [1:1] is the sub-list for extension type_name - 1, // [1:1] is the sub-list for extension extendee - 0, // [0:1] is the sub-list for field type_name + 3, // 0: validation.ValidateRegistrationRequest.bitrhdate:type_name -> google.protobuf.Timestamp + 1, // 1: validation.ValidationResponse.errors:type_name -> validation.ErrorMessage + 0, // 2: validation.Validation.ValidateRegistration:input_type -> validation.ValidateRegistrationRequest + 2, // 3: validation.Validation.ValidateRegistration:output_type -> validation.ValidationResponse + 3, // [3:4] is the sub-list for method output_type + 2, // [2:3] is the sub-list for method input_type + 2, // [2:2] is the sub-list for extension type_name + 2, // [2:2] is the sub-list for extension extendee + 0, // [0:2] is the sub-list for field type_name } func init() { file_validation_proto_init() } @@ -344,18 +299,6 @@ func file_validation_proto_init() { } } file_validation_proto_msgTypes[1].Exporter = func(v any, i int) any { - switch v := v.(*ValidateAuthorizationRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_validation_proto_msgTypes[2].Exporter = func(v any, i int) any { switch v := v.(*ErrorMessage); i { case 0: return &v.state @@ -367,7 +310,7 @@ func file_validation_proto_init() { return nil } } - file_validation_proto_msgTypes[3].Exporter = func(v any, i int) any { + file_validation_proto_msgTypes[2].Exporter = func(v any, i int) any { switch v := v.(*ValidationResponse); i { case 0: return &v.state @@ -386,7 +329,7 @@ func file_validation_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_validation_proto_rawDesc, NumEnums: 0, - NumMessages: 4, + NumMessages: 3, NumExtensions: 0, NumServices: 1, }, diff --git a/validation-service/internal/pb/validation/validation_grpc.pb.go b/validation-service/internal/pb/validation/validation_grpc.pb.go index 125a7c2..c91fb08 100644 --- a/validation-service/internal/pb/validation/validation_grpc.pb.go +++ b/validation-service/internal/pb/validation/validation_grpc.pb.go @@ -19,139 +19,101 @@ import ( const _ = grpc.SupportPackageIsVersion9 const ( - ValidationV1_ValidateRegistration_FullMethodName = "/validation_v1.ValidationV1/ValidateRegistration" - ValidationV1_ValidateAuthorization_FullMethodName = "/validation_v1.ValidationV1/ValidateAuthorization" + Validation_ValidateRegistration_FullMethodName = "/validation.Validation/ValidateRegistration" ) -// ValidationV1Client is the client API for ValidationV1 service. +// ValidationClient is the client API for Validation 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 ValidationV1Client interface { +type ValidationClient interface { ValidateRegistration(ctx context.Context, in *ValidateRegistrationRequest, opts ...grpc.CallOption) (*ValidationResponse, error) - ValidateAuthorization(ctx context.Context, in *ValidateAuthorizationRequest, opts ...grpc.CallOption) (*ValidationResponse, error) } -type validationV1Client struct { +type validationClient struct { cc grpc.ClientConnInterface } -func NewValidationV1Client(cc grpc.ClientConnInterface) ValidationV1Client { - return &validationV1Client{cc} +func NewValidationClient(cc grpc.ClientConnInterface) ValidationClient { + return &validationClient{cc} } -func (c *validationV1Client) ValidateRegistration(ctx context.Context, in *ValidateRegistrationRequest, opts ...grpc.CallOption) (*ValidationResponse, error) { +func (c *validationClient) ValidateRegistration(ctx context.Context, in *ValidateRegistrationRequest, opts ...grpc.CallOption) (*ValidationResponse, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(ValidationResponse) - err := c.cc.Invoke(ctx, ValidationV1_ValidateRegistration_FullMethodName, in, out, cOpts...) + err := c.cc.Invoke(ctx, Validation_ValidateRegistration_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } -func (c *validationV1Client) ValidateAuthorization(ctx context.Context, in *ValidateAuthorizationRequest, opts ...grpc.CallOption) (*ValidationResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(ValidationResponse) - err := c.cc.Invoke(ctx, ValidationV1_ValidateAuthorization_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - -// ValidationV1Server is the server API for ValidationV1 service. -// All implementations must embed UnimplementedValidationV1Server +// ValidationServer is the server API for Validation service. +// All implementations must embed UnimplementedValidationServer // for forward compatibility. -type ValidationV1Server interface { +type ValidationServer interface { ValidateRegistration(context.Context, *ValidateRegistrationRequest) (*ValidationResponse, error) - ValidateAuthorization(context.Context, *ValidateAuthorizationRequest) (*ValidationResponse, error) - mustEmbedUnimplementedValidationV1Server() + mustEmbedUnimplementedValidationServer() } -// UnimplementedValidationV1Server must be embedded to have +// UnimplementedValidationServer must be embedded to have // forward compatible implementations. // // NOTE: this should be embedded by value instead of pointer to avoid a nil // pointer dereference when methods are called. -type UnimplementedValidationV1Server struct{} +type UnimplementedValidationServer struct{} -func (UnimplementedValidationV1Server) ValidateRegistration(context.Context, *ValidateRegistrationRequest) (*ValidationResponse, error) { +func (UnimplementedValidationServer) ValidateRegistration(context.Context, *ValidateRegistrationRequest) (*ValidationResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method ValidateRegistration not implemented") } -func (UnimplementedValidationV1Server) ValidateAuthorization(context.Context, *ValidateAuthorizationRequest) (*ValidationResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ValidateAuthorization not implemented") -} -func (UnimplementedValidationV1Server) mustEmbedUnimplementedValidationV1Server() {} -func (UnimplementedValidationV1Server) testEmbeddedByValue() {} +func (UnimplementedValidationServer) mustEmbedUnimplementedValidationServer() {} +func (UnimplementedValidationServer) testEmbeddedByValue() {} -// UnsafeValidationV1Server may be embedded to opt out of forward compatibility for this service. -// Use of this interface is not recommended, as added methods to ValidationV1Server will +// UnsafeValidationServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to ValidationServer will // result in compilation errors. -type UnsafeValidationV1Server interface { - mustEmbedUnimplementedValidationV1Server() +type UnsafeValidationServer interface { + mustEmbedUnimplementedValidationServer() } -func RegisterValidationV1Server(s grpc.ServiceRegistrar, srv ValidationV1Server) { - // If the following call pancis, it indicates UnimplementedValidationV1Server was +func RegisterValidationServer(s grpc.ServiceRegistrar, srv ValidationServer) { + // If the following call pancis, it indicates UnimplementedValidationServer was // embedded by pointer and is nil. This will cause panics if an // unimplemented method is ever invoked, so we test this at initialization // time to prevent it from happening at runtime later due to I/O. if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { t.testEmbeddedByValue() } - s.RegisterService(&ValidationV1_ServiceDesc, srv) + s.RegisterService(&Validation_ServiceDesc, srv) } -func _ValidationV1_ValidateRegistration_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Validation_ValidateRegistration_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(ValidateRegistrationRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(ValidationV1Server).ValidateRegistration(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: ValidationV1_ValidateRegistration_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ValidationV1Server).ValidateRegistration(ctx, req.(*ValidateRegistrationRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _ValidationV1_ValidateAuthorization_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(ValidateAuthorizationRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(ValidationV1Server).ValidateAuthorization(ctx, in) + return srv.(ValidationServer).ValidateRegistration(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: ValidationV1_ValidateAuthorization_FullMethodName, + FullMethod: Validation_ValidateRegistration_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ValidationV1Server).ValidateAuthorization(ctx, req.(*ValidateAuthorizationRequest)) + return srv.(ValidationServer).ValidateRegistration(ctx, req.(*ValidateRegistrationRequest)) } return interceptor(ctx, in, info, handler) } -// ValidationV1_ServiceDesc is the grpc.ServiceDesc for ValidationV1 service. +// Validation_ServiceDesc is the grpc.ServiceDesc for Validation service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) -var ValidationV1_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "validation_v1.ValidationV1", - HandlerType: (*ValidationV1Server)(nil), +var Validation_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "validation.Validation", + HandlerType: (*ValidationServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "ValidateRegistration", - Handler: _ValidationV1_ValidateRegistration_Handler, - }, - { - MethodName: "ValidateAuthorization", - Handler: _ValidationV1_ValidateAuthorization_Handler, + Handler: _Validation_ValidateRegistration_Handler, }, }, Streams: []grpc.StreamDesc{}, diff --git a/validation-service/internal/pkg/pkg.go b/validation-service/internal/pkg/pkg.go deleted file mode 100644 index c1caffe..0000000 --- a/validation-service/internal/pkg/pkg.go +++ /dev/null @@ -1 +0,0 @@ -package pkg