修复:为 user-svc 添加健康检查和启动顺序控制

This commit is contained in:
fish
2026-03-28 21:54:09 +08:00
parent 5ac0a52bb1
commit c5260bcae8
31 changed files with 1995 additions and 167 deletions

View File

@@ -1,16 +1,29 @@
FROM golang:1.26.1-alpine3.23 as builder
FROM golang:1.25.8-alpine3.23 AS builder
# 设置工作目录
WORKDIR /app
# 复制 go.mod 和 go.sum
COPY go.mod go.sum ./
# 安装 git
RUN apk add --no-cache git
# 下载依赖
RUN go mod download
# 设置 Go 环境变量
ENV GOPROXY=https://goproxy.io,direct
ENV GOSUMDB=off
# 复制共享包
COPY shared/ /shared/
# 复制 go.mod
COPY services/user-svc/go.mod ./
# 复制 go.sum如果存在
COPY services/user-svc/go.sum* ./
# 复制源代码
COPY . .
COPY services/user-svc/ .
# 生成 go.sum 并下载依赖
RUN go mod tidy
# 构建应用
RUN go build -o user-svc ./cmd/main.go

View File

@@ -4,12 +4,13 @@ import (
"fmt"
"log"
"backend/services/user-svc/internal/config"
"backend/services/user-svc/internal/grpcserver"
"backend/services/user-svc/internal/repository"
"backend/services/user-svc/internal/service"
"backend/shared/pkg/database"
"backend/shared/pkg/logger"
"user-svc/internal/config"
"user-svc/internal/grpcserver"
"user-svc/internal/repository"
"user-svc/internal/service"
"shared/pkg/database"
"shared/pkg/logger"
)
func main() {

View File

@@ -1,6 +1,6 @@
module backend/services/user-svc
module user-svc
go 1.26.1
go 1.25.8
require (
github.com/google/uuid v1.6.0
@@ -8,4 +8,9 @@ require (
golang.org/x/crypto v0.20.0
google.golang.org/grpc v1.64.0
google.golang.org/protobuf v1.33.0
shared v0.0.0
)
replace (
shared => /shared
)

View File

@@ -30,7 +30,7 @@ func Load() (*Config, error) {
viper.AddConfigPath("../../config")
viper.SetDefault("server.port", 9000)
viper.SetDefault("database.host", "postgres")
viper.SetDefault("database.host", "backend-postgres")
viper.SetDefault("database.port", 5432)
viper.SetDefault("database.user", "admin")
viper.SetDefault("database.password", "password")

View File

@@ -5,17 +5,18 @@ import (
"fmt"
"net"
"backend/services/user-svc/internal/domain"
"backend/services/user-svc/internal/service"
"backend/shared/pkg/errors"
"backend/shared/pkg/logger"
"user-svc/internal/domain"
"user-svc/internal/service"
"shared/pkg/errors"
"shared/pkg/logger"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
// 导入生成的 proto 代码
userpb "backend/services/user-svc/proto"
userpb "shared/proto/user"
common "shared/proto/common"
)
type UserServer struct {
@@ -41,36 +42,36 @@ func (s *UserServer) Register(ctx context.Context, req *userpb.RegisterRequest)
logger.Error("Register failed: %v", err)
// 转换错误类型
switch {
case errors.IsConflict(err):
return &userpb.RegisterResponse{
Response: &userpb.Response{
Code: 409,
Message: "账号已存在",
},
}, status.Errorf(codes.AlreadyExists, "账号已存在")
case errors.IsInvalidInput(err):
return &userpb.RegisterResponse{
Response: &userpb.Response{
Code: 400,
Message: "无效的输入参数",
},
}, status.Errorf(codes.InvalidArgument, "无效的输入参数")
default:
return &userpb.RegisterResponse{
Response: &userpb.Response{
Code: 500,
Message: "内部服务器错误",
},
}, status.Errorf(codes.Internal, "内部服务器错误")
}
switch {
case errors.IsConflict(err):
return &userpb.RegisterResponse{
Response: &common.Response{
Code: 409,
Message: "账号已存在",
},
}, status.Errorf(codes.AlreadyExists, "账号已存在")
case errors.IsInvalidInput(err):
return &userpb.RegisterResponse{
Response: &common.Response{
Code: 400,
Message: "无效的输入参数",
},
}, status.Errorf(codes.InvalidArgument, "无效的输入参数")
default:
return &userpb.RegisterResponse{
Response: &common.Response{
Code: 500,
Message: "内部服务器错误",
},
}, status.Errorf(codes.Internal, "内部服务器错误")
}
}
// 构造响应
return &userpb.RegisterResponse{
UserId: resp.UserID.String(),
Account: resp.Account,
Response: &userpb.Response{
Response: &common.Response{
Code: 200,
Message: "注册成功",
},
@@ -88,21 +89,21 @@ func (s *UserServer) GetUserByAccount(ctx context.Context, req *userpb.GetUserBy
switch {
case errors.IsNotFound(err):
return &userpb.GetUserByAccountResponse{
Response: &userpb.Response{
Response: &common.Response{
Code: 404,
Message: "用户不存在",
},
}, status.Errorf(codes.NotFound, "用户不存在")
case errors.IsInvalidInput(err):
return &userpb.GetUserByAccountResponse{
Response: &userpb.Response{
Response: &common.Response{
Code: 400,
Message: "无效的输入参数",
},
}, status.Errorf(codes.InvalidArgument, "无效的输入参数")
default:
return &userpb.GetUserByAccountResponse{
Response: &userpb.Response{
Response: &common.Response{
Code: 500,
Message: "内部服务器错误",
},
@@ -114,7 +115,7 @@ func (s *UserServer) GetUserByAccount(ctx context.Context, req *userpb.GetUserBy
return &userpb.GetUserByAccountResponse{
UserId: user.ID.String(),
Account: account.Account,
Response: &userpb.Response{
Response: &common.Response{
Code: 200,
Message: "获取成功",
},

View File

@@ -2,10 +2,9 @@ package repository
import (
"database/sql"
"time"
"backend/services/user-svc/internal/domain"
"backend/shared/pkg/errors"
"user-svc/internal/domain"
"shared/pkg/errors"
"github.com/google/uuid"
"golang.org/x/crypto/bcrypt"
@@ -41,7 +40,11 @@ func (r *UserRepository) Register(req *domain.RegisterRequest) (*domain.Register
}
// 创建用户
userID := uuid.NewV7()
userID, err := uuid.NewV7()
if err != nil {
tx.Rollback()
return nil, errors.WrapError(err, "failed to generate user ID")
}
userQuery := "INSERT INTO user_main (id, deleted) VALUES ($1, $2)"
if _, err := tx.Exec(userQuery, userID, false); err != nil {
@@ -50,7 +53,11 @@ func (r *UserRepository) Register(req *domain.RegisterRequest) (*domain.Register
}
// 创建登录账号
accountID := uuid.NewV7()
accountID, err := uuid.NewV7()
if err != nil {
tx.Rollback()
return nil, errors.WrapError(err, "failed to generate account ID")
}
accountQuery := "INSERT INTO user_login_account (id, user_id, account, deleted) VALUES ($1, $2, $3, $4)"
if _, err := tx.Exec(accountQuery, accountID, userID, req.Account, false); err != nil {
tx.Rollback()
@@ -65,7 +72,11 @@ func (r *UserRepository) Register(req *domain.RegisterRequest) (*domain.Register
}
// 创建密码记录
passwordID := uuid.NewV7()
passwordID, err := uuid.NewV7()
if err != nil {
tx.Rollback()
return nil, errors.WrapError(err, "failed to generate password ID")
}
passwordQuery := "INSERT INTO user_login_password (id, user_id, password, deleted) VALUES ($1, $2, $3, $4)"
if _, err := tx.Exec(passwordQuery, passwordID, userID, string(hashedPassword), false); err != nil {
tx.Rollback()

View File

@@ -1,9 +1,10 @@
package service
import (
"backend/services/user-svc/internal/domain"
"backend/services/user-svc/internal/repository"
"backend/shared/pkg/errors"
"user-svc/internal/domain"
"user-svc/internal/repository"
"shared/pkg/errors"
)
type UserService struct {

View File

@@ -0,0 +1,11 @@
module user-svc/proto
go 1.25.8
require (
google.golang.org/grpc v1.64.0
google.golang.org/protobuf v1.33.0
shared v0.0.0
)
replace shared => /shared

View File

@@ -0,0 +1,323 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.36.11
// protoc v6.31.1
// source: services/user-svc/proto/user.proto
package proto
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
common "shared/proto/common"
sync "sync"
unsafe "unsafe"
)
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 RegisterRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
Account string `protobuf:"bytes,1,opt,name=account,proto3" json:"account,omitempty"`
Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *RegisterRequest) Reset() {
*x = RegisterRequest{}
mi := &file_services_user_svc_proto_user_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *RegisterRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*RegisterRequest) ProtoMessage() {}
func (x *RegisterRequest) ProtoReflect() protoreflect.Message {
mi := &file_services_user_svc_proto_user_proto_msgTypes[0]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use RegisterRequest.ProtoReflect.Descriptor instead.
func (*RegisterRequest) Descriptor() ([]byte, []int) {
return file_services_user_svc_proto_user_proto_rawDescGZIP(), []int{0}
}
func (x *RegisterRequest) GetAccount() string {
if x != nil {
return x.Account
}
return ""
}
func (x *RegisterRequest) GetPassword() string {
if x != nil {
return x.Password
}
return ""
}
// 注册响应
type RegisterResponse struct {
state protoimpl.MessageState `protogen:"open.v1"`
UserId string `protobuf:"bytes,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"`
Account string `protobuf:"bytes,2,opt,name=account,proto3" json:"account,omitempty"`
Response *common.Response `protobuf:"bytes,3,opt,name=response,proto3" json:"response,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *RegisterResponse) Reset() {
*x = RegisterResponse{}
mi := &file_services_user_svc_proto_user_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *RegisterResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*RegisterResponse) ProtoMessage() {}
func (x *RegisterResponse) ProtoReflect() protoreflect.Message {
mi := &file_services_user_svc_proto_user_proto_msgTypes[1]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use RegisterResponse.ProtoReflect.Descriptor instead.
func (*RegisterResponse) Descriptor() ([]byte, []int) {
return file_services_user_svc_proto_user_proto_rawDescGZIP(), []int{1}
}
func (x *RegisterResponse) GetUserId() string {
if x != nil {
return x.UserId
}
return ""
}
func (x *RegisterResponse) GetAccount() string {
if x != nil {
return x.Account
}
return ""
}
func (x *RegisterResponse) GetResponse() *common.Response {
if x != nil {
return x.Response
}
return nil
}
// 获取用户信息请求
type GetUserByAccountRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
Account string `protobuf:"bytes,1,opt,name=account,proto3" json:"account,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *GetUserByAccountRequest) Reset() {
*x = GetUserByAccountRequest{}
mi := &file_services_user_svc_proto_user_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *GetUserByAccountRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*GetUserByAccountRequest) ProtoMessage() {}
func (x *GetUserByAccountRequest) ProtoReflect() protoreflect.Message {
mi := &file_services_user_svc_proto_user_proto_msgTypes[2]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use GetUserByAccountRequest.ProtoReflect.Descriptor instead.
func (*GetUserByAccountRequest) Descriptor() ([]byte, []int) {
return file_services_user_svc_proto_user_proto_rawDescGZIP(), []int{2}
}
func (x *GetUserByAccountRequest) GetAccount() string {
if x != nil {
return x.Account
}
return ""
}
// 获取用户信息响应
type GetUserByAccountResponse struct {
state protoimpl.MessageState `protogen:"open.v1"`
UserId string `protobuf:"bytes,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"`
Account string `protobuf:"bytes,2,opt,name=account,proto3" json:"account,omitempty"`
Response *common.Response `protobuf:"bytes,3,opt,name=response,proto3" json:"response,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *GetUserByAccountResponse) Reset() {
*x = GetUserByAccountResponse{}
mi := &file_services_user_svc_proto_user_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *GetUserByAccountResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*GetUserByAccountResponse) ProtoMessage() {}
func (x *GetUserByAccountResponse) ProtoReflect() protoreflect.Message {
mi := &file_services_user_svc_proto_user_proto_msgTypes[3]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use GetUserByAccountResponse.ProtoReflect.Descriptor instead.
func (*GetUserByAccountResponse) Descriptor() ([]byte, []int) {
return file_services_user_svc_proto_user_proto_rawDescGZIP(), []int{3}
}
func (x *GetUserByAccountResponse) GetUserId() string {
if x != nil {
return x.UserId
}
return ""
}
func (x *GetUserByAccountResponse) GetAccount() string {
if x != nil {
return x.Account
}
return ""
}
func (x *GetUserByAccountResponse) GetResponse() *common.Response {
if x != nil {
return x.Response
}
return nil
}
var File_services_user_svc_proto_user_proto protoreflect.FileDescriptor
const file_services_user_svc_proto_user_proto_rawDesc = "" +
"\n" +
"\"services/user-svc/proto/user.proto\x12\x04user\x1a shared/proto/common/common.proto\"G\n" +
"\x0fRegisterRequest\x12\x18\n" +
"\aaccount\x18\x01 \x01(\tR\aaccount\x12\x1a\n" +
"\bpassword\x18\x02 \x01(\tR\bpassword\"s\n" +
"\x10RegisterResponse\x12\x17\n" +
"\auser_id\x18\x01 \x01(\tR\x06userId\x12\x18\n" +
"\aaccount\x18\x02 \x01(\tR\aaccount\x12,\n" +
"\bresponse\x18\x03 \x01(\v2\x10.common.ResponseR\bresponse\"3\n" +
"\x17GetUserByAccountRequest\x12\x18\n" +
"\aaccount\x18\x01 \x01(\tR\aaccount\"{\n" +
"\x18GetUserByAccountResponse\x12\x17\n" +
"\auser_id\x18\x01 \x01(\tR\x06userId\x12\x18\n" +
"\aaccount\x18\x02 \x01(\tR\aaccount\x12,\n" +
"\bresponse\x18\x03 \x01(\v2\x10.common.ResponseR\bresponse2\x9b\x01\n" +
"\vUserService\x129\n" +
"\bRegister\x12\x15.user.RegisterRequest\x1a\x16.user.RegisterResponse\x12Q\n" +
"\x10GetUserByAccount\x12\x1d.user.GetUserByAccountRequest\x1a\x1e.user.GetUserByAccountResponseB\x10Z\x0euser-svc/protob\x06proto3"
var (
file_services_user_svc_proto_user_proto_rawDescOnce sync.Once
file_services_user_svc_proto_user_proto_rawDescData []byte
)
func file_services_user_svc_proto_user_proto_rawDescGZIP() []byte {
file_services_user_svc_proto_user_proto_rawDescOnce.Do(func() {
file_services_user_svc_proto_user_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_services_user_svc_proto_user_proto_rawDesc), len(file_services_user_svc_proto_user_proto_rawDesc)))
})
return file_services_user_svc_proto_user_proto_rawDescData
}
var file_services_user_svc_proto_user_proto_msgTypes = make([]protoimpl.MessageInfo, 4)
var file_services_user_svc_proto_user_proto_goTypes = []any{
(*RegisterRequest)(nil), // 0: user.RegisterRequest
(*RegisterResponse)(nil), // 1: user.RegisterResponse
(*GetUserByAccountRequest)(nil), // 2: user.GetUserByAccountRequest
(*GetUserByAccountResponse)(nil), // 3: user.GetUserByAccountResponse
(*common.Response)(nil), // 4: common.Response
}
var file_services_user_svc_proto_user_proto_depIdxs = []int32{
4, // 0: user.RegisterResponse.response:type_name -> common.Response
4, // 1: user.GetUserByAccountResponse.response:type_name -> common.Response
0, // 2: user.UserService.Register:input_type -> user.RegisterRequest
2, // 3: user.UserService.GetUserByAccount:input_type -> user.GetUserByAccountRequest
1, // 4: user.UserService.Register:output_type -> user.RegisterResponse
3, // 5: user.UserService.GetUserByAccount:output_type -> user.GetUserByAccountResponse
4, // [4:6] is the sub-list for method output_type
2, // [2:4] 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_services_user_svc_proto_user_proto_init() }
func file_services_user_svc_proto_user_proto_init() {
if File_services_user_svc_proto_user_proto != nil {
return
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: unsafe.Slice(unsafe.StringData(file_services_user_svc_proto_user_proto_rawDesc), len(file_services_user_svc_proto_user_proto_rawDesc)),
NumEnums: 0,
NumMessages: 4,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_services_user_svc_proto_user_proto_goTypes,
DependencyIndexes: file_services_user_svc_proto_user_proto_depIdxs,
MessageInfos: file_services_user_svc_proto_user_proto_msgTypes,
}.Build()
File_services_user_svc_proto_user_proto = out.File
file_services_user_svc_proto_user_proto_goTypes = nil
file_services_user_svc_proto_user_proto_depIdxs = nil
}

View File

@@ -1,38 +0,0 @@
syntax = "proto3";
package user;
import "shared/proto/common/common.proto";
// 用户服务
service UserService {
// 注册用户
rpc Register(RegisterRequest) returns (RegisterResponse);
// 获取用户信息
rpc GetUserByAccount(GetUserByAccountRequest) returns (GetUserByAccountResponse);
}
// 注册请求
message RegisterRequest {
string account = 1;
string password = 2;
}
// 注册响应
message RegisterResponse {
string user_id = 1;
string account = 2;
common.Response response = 3;
}
// 获取用户信息请求
message GetUserByAccountRequest {
string account = 1;
}
// 获取用户信息响应
message GetUserByAccountResponse {
string user_id = 1;
string account = 2;
common.Response response = 3;
}

View File

@@ -0,0 +1,167 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.6.1
// - protoc v6.31.1
// source: services/user-svc/proto/user.proto
package proto
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.64.0 or later.
const _ = grpc.SupportPackageIsVersion9
const (
UserService_Register_FullMethodName = "/user.UserService/Register"
UserService_GetUserByAccount_FullMethodName = "/user.UserService/GetUserByAccount"
)
// UserServiceClient is the client API for UserService 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 UserServiceClient interface {
// 注册用户
Register(ctx context.Context, in *RegisterRequest, opts ...grpc.CallOption) (*RegisterResponse, error)
// 获取用户信息
GetUserByAccount(ctx context.Context, in *GetUserByAccountRequest, opts ...grpc.CallOption) (*GetUserByAccountResponse, error)
}
type userServiceClient struct {
cc grpc.ClientConnInterface
}
func NewUserServiceClient(cc grpc.ClientConnInterface) UserServiceClient {
return &userServiceClient{cc}
}
func (c *userServiceClient) Register(ctx context.Context, in *RegisterRequest, opts ...grpc.CallOption) (*RegisterResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(RegisterResponse)
err := c.cc.Invoke(ctx, UserService_Register_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *userServiceClient) GetUserByAccount(ctx context.Context, in *GetUserByAccountRequest, opts ...grpc.CallOption) (*GetUserByAccountResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(GetUserByAccountResponse)
err := c.cc.Invoke(ctx, UserService_GetUserByAccount_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
// UserServiceServer is the server API for UserService service.
// All implementations must embed UnimplementedUserServiceServer
// for forward compatibility.
//
// 用户服务
type UserServiceServer interface {
// 注册用户
Register(context.Context, *RegisterRequest) (*RegisterResponse, error)
// 获取用户信息
GetUserByAccount(context.Context, *GetUserByAccountRequest) (*GetUserByAccountResponse, error)
mustEmbedUnimplementedUserServiceServer()
}
// UnimplementedUserServiceServer 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 UnimplementedUserServiceServer struct{}
func (UnimplementedUserServiceServer) Register(context.Context, *RegisterRequest) (*RegisterResponse, error) {
return nil, status.Error(codes.Unimplemented, "method Register not implemented")
}
func (UnimplementedUserServiceServer) GetUserByAccount(context.Context, *GetUserByAccountRequest) (*GetUserByAccountResponse, error) {
return nil, status.Error(codes.Unimplemented, "method GetUserByAccount not implemented")
}
func (UnimplementedUserServiceServer) mustEmbedUnimplementedUserServiceServer() {}
func (UnimplementedUserServiceServer) testEmbeddedByValue() {}
// UnsafeUserServiceServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to UserServiceServer will
// result in compilation errors.
type UnsafeUserServiceServer interface {
mustEmbedUnimplementedUserServiceServer()
}
func RegisterUserServiceServer(s grpc.ServiceRegistrar, srv UserServiceServer) {
// If the following call panics, it indicates UnimplementedUserServiceServer 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(&UserService_ServiceDesc, srv)
}
func _UserService_Register_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(RegisterRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(UserServiceServer).Register(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: UserService_Register_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(UserServiceServer).Register(ctx, req.(*RegisterRequest))
}
return interceptor(ctx, in, info, handler)
}
func _UserService_GetUserByAccount_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetUserByAccountRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(UserServiceServer).GetUserByAccount(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: UserService_GetUserByAccount_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(UserServiceServer).GetUserByAccount(ctx, req.(*GetUserByAccountRequest))
}
return interceptor(ctx, in, info, handler)
}
// UserService_ServiceDesc is the grpc.ServiceDesc for UserService service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var UserService_ServiceDesc = grpc.ServiceDesc{
ServiceName: "user.UserService",
HandlerType: (*UserServiceServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "Register",
Handler: _UserService_Register_Handler,
},
{
MethodName: "GetUserByAccount",
Handler: _UserService_GetUserByAccount_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "services/user-svc/proto/user.proto",
}