From 40dc4e30cb8fc0f0bce01f7c3ee0f38873c9e42c Mon Sep 17 00:00:00 2001 From: PseudoMera Date: Mon, 10 Jun 2024 14:19:42 +0200 Subject: [PATCH 1/8] fix: bug where user can't have multiple orders --- schema/schema.sql | 1 - 1 file changed, 1 deletion(-) diff --git a/schema/schema.sql b/schema/schema.sql index 2670ca4..2e322ef 100644 --- a/schema/schema.sql +++ b/schema/schema.sql @@ -37,7 +37,6 @@ CREATE TABLE user_order ( FOREIGN KEY (user_id) REFERENCES vstore_user (id) ON DELETE CASCADE, total_price NUMERIC(12, 2) NOT NULL, status order_status DEFAULT 'pending', - UNIQUE(user_id), created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ); From 00ee511d579088ef813b2f2c0bb7e65d998e9011 Mon Sep 17 00:00:00 2001 From: PseudoMera Date: Mon, 10 Jun 2024 14:40:27 +0200 Subject: [PATCH 2/8] feat: add grpc server to user pkg --- .gitignore | 2 ++ docker-compose.yml | 2 ++ go.mod | 5 +-- user/grpc/server.go | 72 +++++++++++++++++++++++++++++++++++++++++ user/grpc/service.proto | 24 ++++++++++++++ user/main.go | 17 ++++++++++ user/store/store.go | 2 +- 7 files changed, 121 insertions(+), 3 deletions(-) create mode 100644 user/grpc/server.go create mode 100644 user/grpc/service.proto diff --git a/.gitignore b/.gitignore index 2dd5137..5668c83 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,5 @@ go.work .env + +*.pb.go diff --git a/docker-compose.yml b/docker-compose.yml index 14f0d10..b35129f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -27,10 +27,12 @@ services: BUILD_PATH: user ports: - 3000:3000 + - 3010:3010 restart: always environment: CONNECTION_STRING: "postgresql://postgres:postgres@db:5432/postgres?sslmode=disable" HTTP_SERVER_PORT: "3000" + GRPC_SERVER_PORT: "3010" env_file: - .env depends_on: diff --git a/go.mod b/go.mod index 0d898dd..d3e66ce 100644 --- a/go.mod +++ b/go.mod @@ -8,6 +8,8 @@ require ( github.com/testcontainers/testcontainers-go v0.31.0 github.com/testcontainers/testcontainers-go/modules/postgres v0.31.0 golang.org/x/crypto v0.23.0 + google.golang.org/grpc v1.58.3 + google.golang.org/protobuf v1.33.0 ) require ( @@ -56,11 +58,10 @@ require ( go.opentelemetry.io/otel/metric v1.24.0 // indirect go.opentelemetry.io/otel/trace v1.24.0 // indirect golang.org/x/mod v0.16.0 // indirect + golang.org/x/net v0.21.0 // indirect golang.org/x/sync v0.3.0 // indirect golang.org/x/sys v0.20.0 // indirect golang.org/x/text v0.15.0 // indirect golang.org/x/tools v0.13.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20230731190214-cbb8c96f2d6d // indirect - google.golang.org/grpc v1.58.3 // indirect - google.golang.org/protobuf v1.33.0 // indirect ) diff --git a/user/grpc/server.go b/user/grpc/server.go new file mode 100644 index 0000000..835b9d1 --- /dev/null +++ b/user/grpc/server.go @@ -0,0 +1,72 @@ +package grpc + +import ( + "context" + "errors" + + "github.com/PseudoMera/virtual-store/user/store" +) + +var ( + errEmptyEmail = errors.New("email field cannot be empty") + errEmptyPassword = errors.New("password field cannot be empty") + + errRetrievingUser = errors.New("something went wrong while retrieving user") +) + +type UserServer struct { + db *store.Store + UnimplementedUserServiceServer +} + +func NewUserServer(db *store.Store) *UserServer { + return &UserServer{ + db: db, + } +} + +func (us *UserServer) GetUser(ctx context.Context, req *GetUserRequest) (*User, error) { + email := *req.Email + if email == "" { + return nil, errEmptyEmail + } + + user, err := us.db.RetrieveUser(ctx, email) + if err != nil { + return nil, errRetrievingUser + } + + cUser := &User{ + Email: &user.Email, + Id: &user.ID, + Password: &user.Password, + } + return cUser, nil +} + +func (us *UserServer) CreateUser(ctx context.Context, req *CreateUserRequest) (*User, error) { + email, password := *req.Email, *req.Password + + if email == "" { + return nil, errEmptyEmail + } + if password == "" { + return nil, errEmptyPassword + } + + id, err := us.db.StoreUser(ctx, store.User{ + Email: email, + Password: password, + }) + if err != nil { + return nil, err + } + + cID := int64(id) + + return &User{ + Id: &cID, + Email: &email, + Password: &password, + }, err +} diff --git a/user/grpc/service.proto b/user/grpc/service.proto new file mode 100644 index 0000000..c64ca94 --- /dev/null +++ b/user/grpc/service.proto @@ -0,0 +1,24 @@ +syntax = "proto3"; +option go_package = "https://github.com/PseudoMera/virtual-store/user/grpc"; + +package grpc; + +service UserService { + rpc GetUser(GetUserRequest) returns (User) {} + rpc CreateUser(CreateUserRequest) returns (User) {} +} + +message GetUserRequest { + string email = 1; +} + +message CreateUserRequest { + string email = 1; + string password = 2; +} + +message User { + int64 id = 1; + string email = 2; + string password = 3; +} diff --git a/user/main.go b/user/main.go index 41eb38f..74529cc 100644 --- a/user/main.go +++ b/user/main.go @@ -3,13 +3,16 @@ package main import ( "context" "fmt" + "net" "net/http" "time" "github.com/PseudoMera/virtual-store/shared" "github.com/PseudoMera/virtual-store/user/api" + "github.com/PseudoMera/virtual-store/user/grpc" "github.com/PseudoMera/virtual-store/user/service" "github.com/PseudoMera/virtual-store/user/store" + egrpc "google.golang.org/grpc" ) const ( @@ -37,6 +40,20 @@ func main() { router.Get(fmt.Sprintf("%s/user/profile", apiPath), userAPI.GetUserProfile) router.Put(fmt.Sprintf("%s/user/profile", apiPath), userAPI.UpdateUserProfile) + lis, err := net.Listen("tcp", ":3010") + if err != nil { + panic(err) + } + + var opts []egrpc.ServerOption + grpcServer := egrpc.NewServer(opts...) + serviceServer := grpc.NewUserServer(store) + grpc.RegisterUserServiceServer(grpcServer, serviceServer) + + if err := grpcServer.Serve(lis); err != nil { + panic(err) + } + if err := http.ListenAndServe(fmt.Sprintf(":%s", config.httpServerPort), router); err != nil { panic(err) } diff --git a/user/store/store.go b/user/store/store.go index e85fb21..2db816d 100644 --- a/user/store/store.go +++ b/user/store/store.go @@ -19,7 +19,7 @@ func NewStore(db *pgxpool.Pool) *Store { } type User struct { - ID int + ID int64 Email string Password string CreatedAt time.Time From 13b994cc918de066cd04f90169edae8c97ce88de Mon Sep 17 00:00:00 2001 From: PseudoMera Date: Mon, 10 Jun 2024 15:25:33 +0200 Subject: [PATCH 3/8] feat: fully implement user api in grpc version --- user/grpc/server.go | 111 ++++++++++++++++++++++++++++++++++++---- user/grpc/service.proto | 49 ++++++++++++++++-- user/store/store.go | 2 +- 3 files changed, 149 insertions(+), 13 deletions(-) diff --git a/user/grpc/server.go b/user/grpc/server.go index 835b9d1..890f971 100644 --- a/user/grpc/server.go +++ b/user/grpc/server.go @@ -10,6 +10,12 @@ import ( var ( errEmptyEmail = errors.New("email field cannot be empty") errEmptyPassword = errors.New("password field cannot be empty") + errEmptyUserID = errors.New("user_id field cannot be empty") + errEmptyName = errors.New("name field cannot be empty") + errEmptyPhoto = errors.New("photo field cannot be empty") + errEmptyCountry = errors.New("country field cannot be empty") + errEmptyAddress = errors.New("address field cannot be empty") + errEmptyPhone = errors.New("phone field cannot be empty") errRetrievingUser = errors.New("something went wrong while retrieving user") ) @@ -26,7 +32,7 @@ func NewUserServer(db *store.Store) *UserServer { } func (us *UserServer) GetUser(ctx context.Context, req *GetUserRequest) (*User, error) { - email := *req.Email + email := req.Email if email == "" { return nil, errEmptyEmail } @@ -36,17 +42,17 @@ func (us *UserServer) GetUser(ctx context.Context, req *GetUserRequest) (*User, return nil, errRetrievingUser } + cID := int64(user.ID) cUser := &User{ - Email: &user.Email, - Id: &user.ID, - Password: &user.Password, + Email: user.Email, + Id: cID, + Password: user.Password, } return cUser, nil } func (us *UserServer) CreateUser(ctx context.Context, req *CreateUserRequest) (*User, error) { - email, password := *req.Email, *req.Password - + email, password := req.Email, req.Password if email == "" { return nil, errEmptyEmail } @@ -65,8 +71,95 @@ func (us *UserServer) CreateUser(ctx context.Context, req *CreateUserRequest) (* cID := int64(id) return &User{ - Id: &cID, - Email: &email, - Password: &password, + Id: cID, + Email: email, + Password: password, }, err } + +func (us *UserServer) CreateUserProfile(ctx context.Context, req *CreateUserProfileRequest) (*CreateUserProfileResponse, error) { + userID, name, photo, country, address, phone := req.Id, req.Name, req.Photo, req.Country, req.Address, req.Phone + if userID == 0 { + return nil, errEmptyUserID + } + if name == "" { + return nil, errEmptyName + } + if photo == "" { + return nil, errEmptyPhoto + } + if country == "" { + return nil, errEmptyCountry + } + if address == "" { + return nil, errEmptyAddress + } + if phone == "" { + return nil, errEmptyPhone + } + + profileID, err := us.db.StoreUserProfile(ctx, store.Profile{ + UserID: int(userID), + Name: name, + Photo: photo, + Country: country, + Address: address, + Phone: phone, + }) + return &CreateUserProfileResponse{Id: int64(profileID)}, err +} + +func (us *UserServer) GetUserProfile(ctx context.Context, req *GetUserProfileRequest) (*Profile, error) { + if req.Id == 0 { + return nil, errEmptyUserID + } + + profile, err := us.db.RetrieveUserProfile(ctx, int(req.Id)) + + return &Profile{ + Id: int64(profile.ID), + UserID: int64(profile.UserID), + Name: profile.Name, + Photo: profile.Photo, + Country: profile.Country, + Address: profile.Address, + Phone: profile.Phone, + }, err +} + +func (us *UserServer) UpdateUserProfile(ctx context.Context, req *UpdateUserProfileRequest) (*SuccessResponse, error) { + userID, name, photo, country, address, phone := req.UserID, req.Name, req.Photo, req.Country, req.Address, req.Phone + if userID == 0 { + return nil, errEmptyUserID + } + if name == "" { + return nil, errEmptyName + } + if photo == "" { + return nil, errEmptyPhoto + } + if country == "" { + return nil, errEmptyCountry + } + if address == "" { + return nil, errEmptyAddress + } + if phone == "" { + return nil, errEmptyPhone + } + + if err := us.db.UpdateUserProfile(ctx, store.Profile{ + UserID: int(userID), + Name: name, + Photo: photo, + Country: country, + Address: address, + Phone: phone, + }); err != nil { + return nil, err + } + + return &SuccessResponse{ + Msg: "Success!", + }, nil +} diff --git a/user/grpc/service.proto b/user/grpc/service.proto index c64ca94..f37ae92 100644 --- a/user/grpc/service.proto +++ b/user/grpc/service.proto @@ -6,6 +6,25 @@ package grpc; service UserService { rpc GetUser(GetUserRequest) returns (User) {} rpc CreateUser(CreateUserRequest) returns (User) {} + rpc CreateUserProfile(CreateUserProfileRequest) returns (CreateUserProfileResponse) {} + rpc GetUserProfile(GetUserProfileRequest) returns (Profile) {} + rpc UpdateUserProfile(UpdateUserProfileRequest) returns (SuccessResponse) {} +} + +message User { + int64 id = 1; + string email = 2; + string password = 3; +} + +message Profile { + int64 id = 1; + int64 userID = 2; + string name = 3; + string photo = 4; + string country = 5; + string address = 6; + string phone = 7; } message GetUserRequest { @@ -17,8 +36,32 @@ message CreateUserRequest { string password = 2; } -message User { +message CreateUserProfileRequest { int64 id = 1; - string email = 2; - string password = 3; + string name = 2; + string photo = 3; + string country = 4; + string address = 5; + string phone = 6; +} + +message CreateUserProfileResponse { + int64 id = 1; +} + +message GetUserProfileRequest { + int64 id = 1; +} + +message UpdateUserProfileRequest { + int64 userID = 1; + string name = 2; + string photo = 3; + string country = 4; + string address = 5; + string phone = 6; +} + +message SuccessResponse { + string msg = 1; } diff --git a/user/store/store.go b/user/store/store.go index 2db816d..e85fb21 100644 --- a/user/store/store.go +++ b/user/store/store.go @@ -19,7 +19,7 @@ func NewStore(db *pgxpool.Pool) *Store { } type User struct { - ID int64 + ID int Email string Password string CreatedAt time.Time From d2287449a958c97610622373395ceb01c94c1afc Mon Sep 17 00:00:00 2001 From: PseudoMera Date: Mon, 10 Jun 2024 15:50:29 +0200 Subject: [PATCH 4/8] feat: add product proto definition --- product/grpc/service.proto | 50 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 product/grpc/service.proto diff --git a/product/grpc/service.proto b/product/grpc/service.proto new file mode 100644 index 0000000..7e501a6 --- /dev/null +++ b/product/grpc/service.proto @@ -0,0 +1,50 @@ +syntax = "proto3"; +option go_package = "https://github.com/PseudoMera/virtual-store/product/grpc"; + +package grpc; + +service ProductService { + rpc CreateProduct(CreateProductRequest) returns(CreateProductResponse) {} + rpc GetProduct(GetProductRequest) returns(SuccessResponse) {} + rpc GetProducts(GetProductRequest) returns (GetProductsResponse) {} + rpc UpdateProductRequest(Product) returns (SuccessResponse) {} + rpc UpdateProductStock(UpdateProductStockRequest) returns (SuccessResponse) {} +} + +message Product { + int64 id = 1; + string name = 2; + float price = 3; + int32 stock = 4; +} + +message CreateProductRequest { + string name = 1; + float price = 2; + int32 stock = 3; +} + +message CreateProductResponse { + int64 id = 1; +} + +message GetProductRequest { + int64 id = 1; +} + +message SuccessResponse { + string msg = 1; +} + +message GetProductsRequest { + string name = 1; +} + +message GetProductsResponse { + repeated Product products = 1; +} + +message UpdateProductStockRequest { + int64 id = 1; + int32 stock = 2; +} From f3b80f3981f65487e30e64a597ccf450c2a3f327 Mon Sep 17 00:00:00 2001 From: PseudoMera Date: Mon, 10 Jun 2024 18:54:08 +0200 Subject: [PATCH 5/8] feat: add order grpc proto definition --- order/grpc/service.proto | 56 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 order/grpc/service.proto diff --git a/order/grpc/service.proto b/order/grpc/service.proto new file mode 100644 index 0000000..c14bb42 --- /dev/null +++ b/order/grpc/service.proto @@ -0,0 +1,56 @@ +syntax = "proto3"; +option go_package = "https://github.com/PseudoMera/virtual-store/order/grpc"; + +package grpc; + +service OrderService { + rpc CreateOrder(CreateOrderRequest) returns(CreateOrderResponse) {} + rpc GetOrder(GetOrderRequest) returns(Order) {} + rpc GetOrdersByUser(GetOrdersByUserRequest) returns (GetOrdersByUserResponse) {} + rpc UpdateOrder(UpdateOrderRequest) returns(SuccessResponse) {} + rpc UpdateOrderStatus(UpdateOrderStatusRequest) returns(SuccessResponse) {} +} + +message CreateOrderRequest { + int64 userID = 1; + float totalPrice = 2; + string status = 3; +} + +message CreateOrderResponse { + int64 id = 1; +} + +message GetOrderRequest { + int64 id = 1; +} + +message Order { + int64 id = 1; + int64 userID = 2; + float totalPrice = 3; + string status = 4; +} + +message GetOrdersByUserRequest { + int64 userID = 1; +} + +message GetOrdersByUserResponse { + repeated Order orders = 1; +} + +message UpdateOrderRequest { + int64 id = 1; + string status = 2; + float totalPrice = 3; +} + +message SuccessResponse { + string message = 1; +} + +message UpdateOrderStatusRequest { + int64 id = 1; + string status = 2; +} From fa6f528b66221450954b867d57cce890a7135e2c Mon Sep 17 00:00:00 2001 From: PseudoMera Date: Thu, 13 Jun 2024 18:06:01 +0200 Subject: [PATCH 6/8] feat: parity between http and grpc apis --- docker-compose.yml | 6 +- order/grpc/server.go | 119 +++++++++++++++++++++++++++++++ order/grpc/service.proto | 2 +- order/main.go | 17 +++++ product/grpc/server.go | 139 +++++++++++++++++++++++++++++++++++++ product/grpc/service.proto | 8 ++- product/main.go | 17 +++++ 7 files changed, 303 insertions(+), 5 deletions(-) create mode 100644 order/grpc/server.go create mode 100644 product/grpc/server.go diff --git a/docker-compose.yml b/docker-compose.yml index b35129f..48edb61 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -26,8 +26,8 @@ services: args: BUILD_PATH: user ports: - - 3000:3000 - - 3010:3010 + - 3000:3000 + - 3010:3010 restart: always environment: CONNECTION_STRING: "postgresql://postgres:postgres@db:5432/postgres?sslmode=disable" @@ -49,6 +49,7 @@ services: BUILD_PATH: order ports: - 3001:3000 + - 3011:3010 restart: always environment: CONNECTION_STRING: "postgresql://postgres:postgres@db:5432/postgres?sslmode=disable" @@ -69,6 +70,7 @@ services: BUILD_PATH: product ports: - 3002:3000 + - 3012:3010 restart: always environment: CONNECTION_STRING: "postgresql://postgres:postgres@db:5432/postgres?sslmode=disable" diff --git a/order/grpc/server.go b/order/grpc/server.go new file mode 100644 index 0000000..30140e1 --- /dev/null +++ b/order/grpc/server.go @@ -0,0 +1,119 @@ +package grpc + +import ( + context "context" + + "github.com/PseudoMera/virtual-store/order/store" +) + +type OrderServer struct { + db *store.Store + UnimplementedOrderServiceServer +} + +func NewOrderServer(db *store.Store) *OrderServer { + return &OrderServer{ + db: db, + } +} + +func (os *OrderServer) CreateOrder(ctx context.Context, req *CreateOrderRequest) (*CreateOrderResponse, error) { + if req.UserID == 0 { + return nil, nil + } + if req.Status == "" { + return nil, nil + } + if req.TotalPrice == 0.0 { + return nil, nil + } + + id, err := os.db.StoreOrder(ctx, store.Order{ + UserID: int(req.UserID), + Status: store.OrderStatus(req.Status), + TotalPrice: float64(req.TotalPrice), + }) + + return &CreateOrderResponse{ + Id: int64(id), + }, err +} + +func (os *OrderServer) GetOrder(ctx context.Context, req *GetOrderRequest) (*Order, error) { + if req.Id == 0 { + return nil, nil + } + + order, err := os.db.RetrieveOrder(ctx, int(req.Id)) + return &Order{ + Id: int64(order.ID), + UserID: int64(order.UserID), + TotalPrice: float32(order.TotalPrice), + Status: string(order.Status), + }, err +} + +func (os *OrderServer) GetOrdersByUser(ctx context.Context, req *GetOrdersByUserRequest) (*GetOrdersByUserResponse, error) { + if req.UserID == 0 { + return nil, nil + } + + orders, err := os.db.RetrieveOrdersByUserID(ctx, int(req.UserID)) + if err != nil { + return nil, err + } + + parsedOrders := make([]*Order, len(orders)) + for i := range orders { + parsedOrders[i] = &Order{ + Id: int64(orders[i].ID), + UserID: int64(orders[i].UserID), + TotalPrice: float32(orders[i].TotalPrice), + Status: string(orders[i].Status), + } + } + + return &GetOrdersByUserResponse{ + Orders: parsedOrders, + }, nil +} + +func (os *OrderServer) UpdateOrder(ctx context.Context, req *UpdateOrderRequest) (*SuccessResponse, error) { + if req.Id == 0 { + return nil, nil + } + if req.Status == "" { + return nil, nil + } + if req.TotalPrice == 0.0 { + return nil, nil + } + + if err := os.db.UpdateOrder(ctx, int(req.Id), store.Order{ + ID: int(req.Id), + TotalPrice: float64(req.TotalPrice), + Status: store.OrderStatus(req.Status), + }); err != nil { + return nil, err + } + + return &SuccessResponse{ + Msg: "Success!", + }, nil +} + +func (os *OrderServer) UpdateOrderStatus(ctx context.Context, req *UpdateOrderStatusRequest) (*SuccessResponse, error) { + if req.Id == 0 { + return nil, nil + } + if req.Status == "" { + return nil, nil + } + if err := os.db.UpdateOrderStatus(ctx, int(req.Id), store.OrderStatus(req.Status)); err != nil { + return nil, err + } + + return &SuccessResponse{ + Msg: "Success!", + }, nil +} diff --git a/order/grpc/service.proto b/order/grpc/service.proto index c14bb42..885a11f 100644 --- a/order/grpc/service.proto +++ b/order/grpc/service.proto @@ -47,7 +47,7 @@ message UpdateOrderRequest { } message SuccessResponse { - string message = 1; + string msg = 1; } message UpdateOrderStatusRequest { diff --git a/order/main.go b/order/main.go index 84dc601..bc49fc6 100644 --- a/order/main.go +++ b/order/main.go @@ -3,13 +3,16 @@ package main import ( "context" "fmt" + "net" "net/http" "time" "github.com/PseudoMera/virtual-store/order/api" + "github.com/PseudoMera/virtual-store/order/grpc" "github.com/PseudoMera/virtual-store/order/service" "github.com/PseudoMera/virtual-store/order/store" "github.com/PseudoMera/virtual-store/shared" + egrpc "google.golang.org/grpc" ) const ( @@ -37,6 +40,20 @@ func main() { router.Put(fmt.Sprintf("%s/order", apiPath), orderAPI.UpdateOrder) router.Put(fmt.Sprintf("%s/order/status", apiPath), orderAPI.UpdateOrderStatus) + lis, err := net.Listen("tcp", ":3010") + if err != nil { + panic(err) + } + + var opts []egrpc.ServerOption + grpcServer := egrpc.NewServer(opts...) + serviceServer := grpc.NewOrderServer(store) + grpc.RegisterOrderServiceServer(grpcServer, serviceServer) + + if err := grpcServer.Serve(lis); err != nil { + panic(err) + } + if err := http.ListenAndServe(fmt.Sprintf(":%s", config.httpServerPort), router); err != nil { panic(err) } diff --git a/product/grpc/server.go b/product/grpc/server.go new file mode 100644 index 0000000..84dcf1c --- /dev/null +++ b/product/grpc/server.go @@ -0,0 +1,139 @@ +package grpc + +import ( + context "context" + "errors" + + "github.com/PseudoMera/virtual-store/product/store" +) + +var ( + errEmptyName = errors.New("name field cannot be empty") + errEmptyPrice = errors.New("price field cannot be empty") + errEmptyStock = errors.New("stock field cannot be empty") + errEmptyID = errors.New("id field cannot be empty") +) + +type ProductServer struct { + db *store.Store + UnimplementedProductServiceServer +} + +func NewProductServer(db *store.Store) *ProductServer { + return &ProductServer{ + db: db, + } +} + +func (ps *ProductServer) CreateProduct(ctx context.Context, req *CreateProductRequest) (*CreateProductResponse, error) { + if req.Name == "" { + return nil, errEmptyName + } + if req.Price == 0.0 { + return nil, errEmptyPrice + } + if req.Stock == 0 { + return nil, errEmptyStock + } + + id, err := ps.db.StoreProduct(ctx, store.Product{ + Name: req.Name, + Price: float64(req.Price), + Stock: int(req.Stock), + }) + if err != nil { + return nil, err + } + + return &CreateProductResponse{ + Id: int64(id), + }, nil +} + +func (ps *ProductServer) GetProduct(ctx context.Context, req *GetProductRequest) (*GetProductResponse, error) { + if req.Id == 0 { + return nil, errEmptyID + } + + product, err := ps.db.RetrieveProduct(ctx, int(req.Id)) + if err != nil { + return nil, err + } + + return &GetProductResponse{ + Product: &Product{ + Id: int64(product.ID), + Name: product.Name, + Stock: int32(product.Stock), + Price: float32(product.Price), + }, + }, nil +} + +func (ps *ProductServer) GetProducts(ctx context.Context, req *GetProductsRequest) (*GetProductsResponse, error) { + if req.Name == "" { + return nil, errEmptyName + } + + products, err := ps.db.RetrieveProducts(ctx, req.Name) + if err != nil { + return nil, err + } + + parsedProducts := make([]*Product, len(products)) + for i := range products { + parsedProducts = append(parsedProducts, &Product{ + Id: int64(products[i].ID), + Name: products[i].Name, + Price: float32(products[i].Price), + Stock: int32(products[i].Stock), + }) + } + + return &GetProductsResponse{ + Products: parsedProducts, + }, nil +} + +func (ps *ProductServer) UpdateProductRequest(ctx context.Context, req *Product) (*SuccessResponse, error) { + id, name, price, stock := req.Id, req.Name, req.Price, req.Stock + if name == "" { + return nil, errEmptyName + } + if price == 0.0 { + return nil, errEmptyPrice + } + if stock == 0 { + return nil, errEmptyStock + } + + err := ps.db.UpdateProduct(ctx, store.Product{ + ID: int(id), + Name: name, + Price: float64(price), + Stock: int(stock), + }) + if err != nil { + return nil, err + } + + return &SuccessResponse{ + Msg: "Success!", + }, nil +} + +func (ps *ProductServer) UpdateProductStock(ctx context.Context, req *UpdateProductStockRequest) (*SuccessResponse, error) { + id, stock := req.Id, req.Stock + if stock == 0 { + return nil, errEmptyStock + } + + err := ps.db.UpdateProductStock(ctx, int(id), int(stock)) + if err != nil { + return nil, err + } + + return &SuccessResponse{ + Msg: "Success!", + }, nil +} diff --git a/product/grpc/service.proto b/product/grpc/service.proto index 7e501a6..783cad5 100644 --- a/product/grpc/service.proto +++ b/product/grpc/service.proto @@ -5,8 +5,8 @@ package grpc; service ProductService { rpc CreateProduct(CreateProductRequest) returns(CreateProductResponse) {} - rpc GetProduct(GetProductRequest) returns(SuccessResponse) {} - rpc GetProducts(GetProductRequest) returns (GetProductsResponse) {} + rpc GetProduct(GetProductRequest) returns(GetProductResponse) {} + rpc GetProducts(GetProductsRequest) returns (GetProductsResponse) {} rpc UpdateProductRequest(Product) returns (SuccessResponse) {} rpc UpdateProductStock(UpdateProductStockRequest) returns (SuccessResponse) {} } @@ -32,6 +32,10 @@ message GetProductRequest { int64 id = 1; } +message GetProductResponse { + Product product = 1; +} + message SuccessResponse { string msg = 1; } diff --git a/product/main.go b/product/main.go index 7e5c29f..31ba1ca 100644 --- a/product/main.go +++ b/product/main.go @@ -3,13 +3,16 @@ package main import ( "context" "fmt" + "net" "net/http" "time" "github.com/PseudoMera/virtual-store/product/api" + "github.com/PseudoMera/virtual-store/product/grpc" "github.com/PseudoMera/virtual-store/product/service" "github.com/PseudoMera/virtual-store/product/store" "github.com/PseudoMera/virtual-store/shared" + egrpc "google.golang.org/grpc" ) const ( @@ -37,6 +40,20 @@ func main() { router.Put(fmt.Sprintf("%s/product", apiPath), productAPI.UpdateProduct) router.Put(fmt.Sprintf("%s/product/stock", apiPath), productAPI.UpdateProductStock) + lis, err := net.Listen("tcp", ":3010") + if err != nil { + panic(err) + } + + var opts []egrpc.ServerOption + grpcServer := egrpc.NewServer(opts...) + serviceServer := grpc.NewProductServer(store) + grpc.RegisterProductServiceServer(grpcServer, serviceServer) + + if err := grpcServer.Serve(lis); err != nil { + panic(err) + } + if err := http.ListenAndServe(fmt.Sprintf(":%s", config.httpServerPort), router); err != nil { panic(err) } From ae4789f9817791da64410f44253b43d7d4ca5776 Mon Sep 17 00:00:00 2001 From: PseudoMera Date: Thu, 13 Jun 2024 18:12:22 +0200 Subject: [PATCH 7/8] feat: add grpc server port --- order/config.go | 9 +++++++++ order/main.go | 2 +- product/config.go | 9 +++++++++ product/main.go | 2 +- user/config.go | 9 +++++++++ user/main.go | 2 +- 6 files changed, 30 insertions(+), 3 deletions(-) diff --git a/order/config.go b/order/config.go index 7aa474b..bda873e 100644 --- a/order/config.go +++ b/order/config.go @@ -8,16 +8,19 @@ import ( const ( connectionString = "CONNECTION_STRING" httpServerPort = "HTTP_SERVER_PORT" + grpcServerPort = "GRPC_SERVER_PORT" ) var ( errEmptyConnectionString = errors.New("env variable 'CONNECTION_STRING' cannot be empty") errEmptyHTTPServerPort = errors.New("env variable 'HTTP_SERVER_PORT' cannot be empty") + errEmptyGRPCServerPort = errors.New("env variable 'GRPC_SERVER_PORT' cannot be empty") ) type config struct { connectionString string httpServerPort string + grpcServerPort string } func getConfig() config { @@ -31,8 +34,14 @@ func getConfig() config { panic(errEmptyHTTPServerPort) } + grpcPort := os.Getenv(grpcServerPort) + if grpcPort == "" { + panic(errEmptyGRPCServerPort) + } + return config{ connectionString: cstr, httpServerPort: httpPort, + grpcServerPort: grpcPort, } } diff --git a/order/main.go b/order/main.go index bc49fc6..6a44687 100644 --- a/order/main.go +++ b/order/main.go @@ -40,7 +40,7 @@ func main() { router.Put(fmt.Sprintf("%s/order", apiPath), orderAPI.UpdateOrder) router.Put(fmt.Sprintf("%s/order/status", apiPath), orderAPI.UpdateOrderStatus) - lis, err := net.Listen("tcp", ":3010") + lis, err := net.Listen("tcp", config.grpcServerPort) if err != nil { panic(err) } diff --git a/product/config.go b/product/config.go index 7aa474b..bda873e 100644 --- a/product/config.go +++ b/product/config.go @@ -8,16 +8,19 @@ import ( const ( connectionString = "CONNECTION_STRING" httpServerPort = "HTTP_SERVER_PORT" + grpcServerPort = "GRPC_SERVER_PORT" ) var ( errEmptyConnectionString = errors.New("env variable 'CONNECTION_STRING' cannot be empty") errEmptyHTTPServerPort = errors.New("env variable 'HTTP_SERVER_PORT' cannot be empty") + errEmptyGRPCServerPort = errors.New("env variable 'GRPC_SERVER_PORT' cannot be empty") ) type config struct { connectionString string httpServerPort string + grpcServerPort string } func getConfig() config { @@ -31,8 +34,14 @@ func getConfig() config { panic(errEmptyHTTPServerPort) } + grpcPort := os.Getenv(grpcServerPort) + if grpcPort == "" { + panic(errEmptyGRPCServerPort) + } + return config{ connectionString: cstr, httpServerPort: httpPort, + grpcServerPort: grpcPort, } } diff --git a/product/main.go b/product/main.go index 31ba1ca..854c070 100644 --- a/product/main.go +++ b/product/main.go @@ -40,7 +40,7 @@ func main() { router.Put(fmt.Sprintf("%s/product", apiPath), productAPI.UpdateProduct) router.Put(fmt.Sprintf("%s/product/stock", apiPath), productAPI.UpdateProductStock) - lis, err := net.Listen("tcp", ":3010") + lis, err := net.Listen("tcp", config.grpcServerPort) if err != nil { panic(err) } diff --git a/user/config.go b/user/config.go index 7aa474b..bda873e 100644 --- a/user/config.go +++ b/user/config.go @@ -8,16 +8,19 @@ import ( const ( connectionString = "CONNECTION_STRING" httpServerPort = "HTTP_SERVER_PORT" + grpcServerPort = "GRPC_SERVER_PORT" ) var ( errEmptyConnectionString = errors.New("env variable 'CONNECTION_STRING' cannot be empty") errEmptyHTTPServerPort = errors.New("env variable 'HTTP_SERVER_PORT' cannot be empty") + errEmptyGRPCServerPort = errors.New("env variable 'GRPC_SERVER_PORT' cannot be empty") ) type config struct { connectionString string httpServerPort string + grpcServerPort string } func getConfig() config { @@ -31,8 +34,14 @@ func getConfig() config { panic(errEmptyHTTPServerPort) } + grpcPort := os.Getenv(grpcServerPort) + if grpcPort == "" { + panic(errEmptyGRPCServerPort) + } + return config{ connectionString: cstr, httpServerPort: httpPort, + grpcServerPort: grpcPort, } } diff --git a/user/main.go b/user/main.go index 74529cc..8c074b4 100644 --- a/user/main.go +++ b/user/main.go @@ -40,7 +40,7 @@ func main() { router.Get(fmt.Sprintf("%s/user/profile", apiPath), userAPI.GetUserProfile) router.Put(fmt.Sprintf("%s/user/profile", apiPath), userAPI.UpdateUserProfile) - lis, err := net.Listen("tcp", ":3010") + lis, err := net.Listen("tcp", config.grpcServerPort) if err != nil { panic(err) } From d3b6e166b54a42e0cb71e8ed34e16fc7d0c8e5c0 Mon Sep 17 00:00:00 2001 From: PseudoMera Date: Thu, 13 Jun 2024 18:16:06 +0200 Subject: [PATCH 8/8] feat: add grpc generated files --- .gitignore | 2 - order/grpc/service.pb.go | 758 ++++++++++++++++++++++++++++ order/grpc/service_grpc.pb.go | 250 ++++++++++ product/grpc/service.pb.go | 741 +++++++++++++++++++++++++++ product/grpc/service_grpc.pb.go | 250 ++++++++++ user/grpc/service.pb.go | 857 ++++++++++++++++++++++++++++++++ user/grpc/service_grpc.pb.go | 250 ++++++++++ 7 files changed, 3106 insertions(+), 2 deletions(-) create mode 100644 order/grpc/service.pb.go create mode 100644 order/grpc/service_grpc.pb.go create mode 100644 product/grpc/service.pb.go create mode 100644 product/grpc/service_grpc.pb.go create mode 100644 user/grpc/service.pb.go create mode 100644 user/grpc/service_grpc.pb.go diff --git a/.gitignore b/.gitignore index 5668c83..2dd5137 100644 --- a/.gitignore +++ b/.gitignore @@ -21,5 +21,3 @@ go.work .env - -*.pb.go diff --git a/order/grpc/service.pb.go b/order/grpc/service.pb.go new file mode 100644 index 0000000..75753b1 --- /dev/null +++ b/order/grpc/service.pb.go @@ -0,0 +1,758 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.28.1 +// protoc v5.27.0 +// source: order/grpc/service.proto + +package grpc + +import ( + reflect "reflect" + sync "sync" + + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" +) + +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 CreateOrderRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + UserID int64 `protobuf:"varint,1,opt,name=userID,proto3" json:"userID,omitempty"` + TotalPrice float32 `protobuf:"fixed32,2,opt,name=totalPrice,proto3" json:"totalPrice,omitempty"` + Status string `protobuf:"bytes,3,opt,name=status,proto3" json:"status,omitempty"` +} + +func (x *CreateOrderRequest) Reset() { + *x = CreateOrderRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_order_grpc_service_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CreateOrderRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateOrderRequest) ProtoMessage() {} + +func (x *CreateOrderRequest) ProtoReflect() protoreflect.Message { + mi := &file_order_grpc_service_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 CreateOrderRequest.ProtoReflect.Descriptor instead. +func (*CreateOrderRequest) Descriptor() ([]byte, []int) { + return file_order_grpc_service_proto_rawDescGZIP(), []int{0} +} + +func (x *CreateOrderRequest) GetUserID() int64 { + if x != nil { + return x.UserID + } + return 0 +} + +func (x *CreateOrderRequest) GetTotalPrice() float32 { + if x != nil { + return x.TotalPrice + } + return 0 +} + +func (x *CreateOrderRequest) GetStatus() string { + if x != nil { + return x.Status + } + return "" +} + +type CreateOrderResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` +} + +func (x *CreateOrderResponse) Reset() { + *x = CreateOrderResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_order_grpc_service_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CreateOrderResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateOrderResponse) ProtoMessage() {} + +func (x *CreateOrderResponse) ProtoReflect() protoreflect.Message { + mi := &file_order_grpc_service_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 CreateOrderResponse.ProtoReflect.Descriptor instead. +func (*CreateOrderResponse) Descriptor() ([]byte, []int) { + return file_order_grpc_service_proto_rawDescGZIP(), []int{1} +} + +func (x *CreateOrderResponse) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +type GetOrderRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` +} + +func (x *GetOrderRequest) Reset() { + *x = GetOrderRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_order_grpc_service_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetOrderRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetOrderRequest) ProtoMessage() {} + +func (x *GetOrderRequest) ProtoReflect() protoreflect.Message { + mi := &file_order_grpc_service_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 GetOrderRequest.ProtoReflect.Descriptor instead. +func (*GetOrderRequest) Descriptor() ([]byte, []int) { + return file_order_grpc_service_proto_rawDescGZIP(), []int{2} +} + +func (x *GetOrderRequest) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +type Order struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + UserID int64 `protobuf:"varint,2,opt,name=userID,proto3" json:"userID,omitempty"` + TotalPrice float32 `protobuf:"fixed32,3,opt,name=totalPrice,proto3" json:"totalPrice,omitempty"` + Status string `protobuf:"bytes,4,opt,name=status,proto3" json:"status,omitempty"` +} + +func (x *Order) Reset() { + *x = Order{} + if protoimpl.UnsafeEnabled { + mi := &file_order_grpc_service_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Order) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Order) ProtoMessage() {} + +func (x *Order) ProtoReflect() protoreflect.Message { + mi := &file_order_grpc_service_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 Order.ProtoReflect.Descriptor instead. +func (*Order) Descriptor() ([]byte, []int) { + return file_order_grpc_service_proto_rawDescGZIP(), []int{3} +} + +func (x *Order) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *Order) GetUserID() int64 { + if x != nil { + return x.UserID + } + return 0 +} + +func (x *Order) GetTotalPrice() float32 { + if x != nil { + return x.TotalPrice + } + return 0 +} + +func (x *Order) GetStatus() string { + if x != nil { + return x.Status + } + return "" +} + +type GetOrdersByUserRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + UserID int64 `protobuf:"varint,1,opt,name=userID,proto3" json:"userID,omitempty"` +} + +func (x *GetOrdersByUserRequest) Reset() { + *x = GetOrdersByUserRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_order_grpc_service_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetOrdersByUserRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetOrdersByUserRequest) ProtoMessage() {} + +func (x *GetOrdersByUserRequest) ProtoReflect() protoreflect.Message { + mi := &file_order_grpc_service_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 GetOrdersByUserRequest.ProtoReflect.Descriptor instead. +func (*GetOrdersByUserRequest) Descriptor() ([]byte, []int) { + return file_order_grpc_service_proto_rawDescGZIP(), []int{4} +} + +func (x *GetOrdersByUserRequest) GetUserID() int64 { + if x != nil { + return x.UserID + } + return 0 +} + +type GetOrdersByUserResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Orders []*Order `protobuf:"bytes,1,rep,name=orders,proto3" json:"orders,omitempty"` +} + +func (x *GetOrdersByUserResponse) Reset() { + *x = GetOrdersByUserResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_order_grpc_service_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetOrdersByUserResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetOrdersByUserResponse) ProtoMessage() {} + +func (x *GetOrdersByUserResponse) ProtoReflect() protoreflect.Message { + mi := &file_order_grpc_service_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 GetOrdersByUserResponse.ProtoReflect.Descriptor instead. +func (*GetOrdersByUserResponse) Descriptor() ([]byte, []int) { + return file_order_grpc_service_proto_rawDescGZIP(), []int{5} +} + +func (x *GetOrdersByUserResponse) GetOrders() []*Order { + if x != nil { + return x.Orders + } + return nil +} + +type UpdateOrderRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + Status string `protobuf:"bytes,2,opt,name=status,proto3" json:"status,omitempty"` + TotalPrice float32 `protobuf:"fixed32,3,opt,name=totalPrice,proto3" json:"totalPrice,omitempty"` +} + +func (x *UpdateOrderRequest) Reset() { + *x = UpdateOrderRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_order_grpc_service_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *UpdateOrderRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdateOrderRequest) ProtoMessage() {} + +func (x *UpdateOrderRequest) ProtoReflect() protoreflect.Message { + mi := &file_order_grpc_service_proto_msgTypes[6] + 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 UpdateOrderRequest.ProtoReflect.Descriptor instead. +func (*UpdateOrderRequest) Descriptor() ([]byte, []int) { + return file_order_grpc_service_proto_rawDescGZIP(), []int{6} +} + +func (x *UpdateOrderRequest) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *UpdateOrderRequest) GetStatus() string { + if x != nil { + return x.Status + } + return "" +} + +func (x *UpdateOrderRequest) GetTotalPrice() float32 { + if x != nil { + return x.TotalPrice + } + return 0 +} + +type SuccessResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Msg string `protobuf:"bytes,1,opt,name=msg,proto3" json:"msg,omitempty"` +} + +func (x *SuccessResponse) Reset() { + *x = SuccessResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_order_grpc_service_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *SuccessResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SuccessResponse) ProtoMessage() {} + +func (x *SuccessResponse) ProtoReflect() protoreflect.Message { + mi := &file_order_grpc_service_proto_msgTypes[7] + 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 SuccessResponse.ProtoReflect.Descriptor instead. +func (*SuccessResponse) Descriptor() ([]byte, []int) { + return file_order_grpc_service_proto_rawDescGZIP(), []int{7} +} + +func (x *SuccessResponse) GetMsg() string { + if x != nil { + return x.Msg + } + return "" +} + +type UpdateOrderStatusRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + Status string `protobuf:"bytes,2,opt,name=status,proto3" json:"status,omitempty"` +} + +func (x *UpdateOrderStatusRequest) Reset() { + *x = UpdateOrderStatusRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_order_grpc_service_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *UpdateOrderStatusRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdateOrderStatusRequest) ProtoMessage() {} + +func (x *UpdateOrderStatusRequest) ProtoReflect() protoreflect.Message { + mi := &file_order_grpc_service_proto_msgTypes[8] + 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 UpdateOrderStatusRequest.ProtoReflect.Descriptor instead. +func (*UpdateOrderStatusRequest) Descriptor() ([]byte, []int) { + return file_order_grpc_service_proto_rawDescGZIP(), []int{8} +} + +func (x *UpdateOrderStatusRequest) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *UpdateOrderStatusRequest) GetStatus() string { + if x != nil { + return x.Status + } + return "" +} + +var File_order_grpc_service_proto protoreflect.FileDescriptor + +var file_order_grpc_service_proto_rawDesc = []byte{ + 0x0a, 0x18, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x73, 0x65, 0x72, + 0x76, 0x69, 0x63, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x04, 0x67, 0x72, 0x70, 0x63, + 0x22, 0x64, 0x0a, 0x12, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x44, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x44, 0x12, 0x1e, + 0x0a, 0x0a, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x50, 0x72, 0x69, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x02, 0x52, 0x0a, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x50, 0x72, 0x69, 0x63, 0x65, 0x12, 0x16, + 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, + 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, 0x25, 0x0a, 0x13, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, + 0x4f, 0x72, 0x64, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x0e, 0x0a, + 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x22, 0x21, 0x0a, + 0x0f, 0x47, 0x65, 0x74, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, + 0x22, 0x67, 0x0a, 0x05, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x75, 0x73, 0x65, + 0x72, 0x49, 0x44, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, + 0x44, 0x12, 0x1e, 0x0a, 0x0a, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x50, 0x72, 0x69, 0x63, 0x65, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x02, 0x52, 0x0a, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x50, 0x72, 0x69, 0x63, + 0x65, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, 0x30, 0x0a, 0x16, 0x47, 0x65, 0x74, + 0x4f, 0x72, 0x64, 0x65, 0x72, 0x73, 0x42, 0x79, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x44, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x03, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x44, 0x22, 0x3e, 0x0a, 0x17, 0x47, + 0x65, 0x74, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x73, 0x42, 0x79, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x23, 0x0a, 0x06, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x73, + 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x4f, 0x72, + 0x64, 0x65, 0x72, 0x52, 0x06, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x73, 0x22, 0x5c, 0x0a, 0x12, 0x55, + 0x70, 0x64, 0x61, 0x74, 0x65, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, + 0x64, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x1e, 0x0a, 0x0a, 0x74, 0x6f, 0x74, + 0x61, 0x6c, 0x50, 0x72, 0x69, 0x63, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x02, 0x52, 0x0a, 0x74, + 0x6f, 0x74, 0x61, 0x6c, 0x50, 0x72, 0x69, 0x63, 0x65, 0x22, 0x23, 0x0a, 0x0f, 0x53, 0x75, 0x63, + 0x63, 0x65, 0x73, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x10, 0x0a, 0x03, + 0x6d, 0x73, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6d, 0x73, 0x67, 0x22, 0x42, + 0x0a, 0x18, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x53, 0x74, 0x61, + 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, + 0x61, 0x74, 0x75, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, + 0x75, 0x73, 0x32, 0xe8, 0x02, 0x0a, 0x0c, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, + 0x69, 0x63, 0x65, 0x12, 0x44, 0x0a, 0x0b, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4f, 0x72, 0x64, + 0x65, 0x72, 0x12, 0x18, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, + 0x4f, 0x72, 0x64, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x67, + 0x72, 0x70, 0x63, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x30, 0x0a, 0x08, 0x47, 0x65, 0x74, + 0x4f, 0x72, 0x64, 0x65, 0x72, 0x12, 0x15, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, + 0x4f, 0x72, 0x64, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0b, 0x2e, 0x67, + 0x72, 0x70, 0x63, 0x2e, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x22, 0x00, 0x12, 0x50, 0x0a, 0x0f, 0x47, + 0x65, 0x74, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x73, 0x42, 0x79, 0x55, 0x73, 0x65, 0x72, 0x12, 0x1c, + 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x73, 0x42, + 0x79, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x67, + 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x73, 0x42, 0x79, 0x55, + 0x73, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x40, 0x0a, + 0x0b, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x12, 0x18, 0x2e, 0x67, + 0x72, 0x70, 0x63, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x15, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x53, 0x75, + 0x63, 0x63, 0x65, 0x73, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, + 0x4c, 0x0a, 0x11, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x53, 0x74, + 0x61, 0x74, 0x75, 0x73, 0x12, 0x1e, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x55, 0x70, 0x64, 0x61, + 0x74, 0x65, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x15, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x53, 0x75, 0x63, 0x63, + 0x65, 0x73, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x38, 0x5a, + 0x36, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, + 0x63, 0x6f, 0x6d, 0x2f, 0x50, 0x73, 0x65, 0x75, 0x64, 0x6f, 0x4d, 0x65, 0x72, 0x61, 0x2f, 0x76, + 0x69, 0x72, 0x74, 0x75, 0x61, 0x6c, 0x2d, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2f, 0x6f, 0x72, 0x64, + 0x65, 0x72, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_order_grpc_service_proto_rawDescOnce sync.Once + file_order_grpc_service_proto_rawDescData = file_order_grpc_service_proto_rawDesc +) + +func file_order_grpc_service_proto_rawDescGZIP() []byte { + file_order_grpc_service_proto_rawDescOnce.Do(func() { + file_order_grpc_service_proto_rawDescData = protoimpl.X.CompressGZIP(file_order_grpc_service_proto_rawDescData) + }) + return file_order_grpc_service_proto_rawDescData +} + +var file_order_grpc_service_proto_msgTypes = make([]protoimpl.MessageInfo, 9) +var file_order_grpc_service_proto_goTypes = []interface{}{ + (*CreateOrderRequest)(nil), // 0: grpc.CreateOrderRequest + (*CreateOrderResponse)(nil), // 1: grpc.CreateOrderResponse + (*GetOrderRequest)(nil), // 2: grpc.GetOrderRequest + (*Order)(nil), // 3: grpc.Order + (*GetOrdersByUserRequest)(nil), // 4: grpc.GetOrdersByUserRequest + (*GetOrdersByUserResponse)(nil), // 5: grpc.GetOrdersByUserResponse + (*UpdateOrderRequest)(nil), // 6: grpc.UpdateOrderRequest + (*SuccessResponse)(nil), // 7: grpc.SuccessResponse + (*UpdateOrderStatusRequest)(nil), // 8: grpc.UpdateOrderStatusRequest +} +var file_order_grpc_service_proto_depIdxs = []int32{ + 3, // 0: grpc.GetOrdersByUserResponse.orders:type_name -> grpc.Order + 0, // 1: grpc.OrderService.CreateOrder:input_type -> grpc.CreateOrderRequest + 2, // 2: grpc.OrderService.GetOrder:input_type -> grpc.GetOrderRequest + 4, // 3: grpc.OrderService.GetOrdersByUser:input_type -> grpc.GetOrdersByUserRequest + 6, // 4: grpc.OrderService.UpdateOrder:input_type -> grpc.UpdateOrderRequest + 8, // 5: grpc.OrderService.UpdateOrderStatus:input_type -> grpc.UpdateOrderStatusRequest + 1, // 6: grpc.OrderService.CreateOrder:output_type -> grpc.CreateOrderResponse + 3, // 7: grpc.OrderService.GetOrder:output_type -> grpc.Order + 5, // 8: grpc.OrderService.GetOrdersByUser:output_type -> grpc.GetOrdersByUserResponse + 7, // 9: grpc.OrderService.UpdateOrder:output_type -> grpc.SuccessResponse + 7, // 10: grpc.OrderService.UpdateOrderStatus:output_type -> grpc.SuccessResponse + 6, // [6:11] is the sub-list for method output_type + 1, // [1:6] 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 +} + +func init() { file_order_grpc_service_proto_init() } +func file_order_grpc_service_proto_init() { + if File_order_grpc_service_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_order_grpc_service_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CreateOrderRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_order_grpc_service_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CreateOrderResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_order_grpc_service_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetOrderRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_order_grpc_service_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Order); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_order_grpc_service_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetOrdersByUserRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_order_grpc_service_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetOrdersByUserResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_order_grpc_service_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*UpdateOrderRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_order_grpc_service_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SuccessResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_order_grpc_service_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*UpdateOrderStatusRequest); 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_order_grpc_service_proto_rawDesc, + NumEnums: 0, + NumMessages: 9, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_order_grpc_service_proto_goTypes, + DependencyIndexes: file_order_grpc_service_proto_depIdxs, + MessageInfos: file_order_grpc_service_proto_msgTypes, + }.Build() + File_order_grpc_service_proto = out.File + file_order_grpc_service_proto_rawDesc = nil + file_order_grpc_service_proto_goTypes = nil + file_order_grpc_service_proto_depIdxs = nil +} diff --git a/order/grpc/service_grpc.pb.go b/order/grpc/service_grpc.pb.go new file mode 100644 index 0000000..ee5fa24 --- /dev/null +++ b/order/grpc/service_grpc.pb.go @@ -0,0 +1,250 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.2.0 +// - protoc v5.27.0 +// source: order/grpc/service.proto + +package grpc + +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 + +// OrderServiceClient is the client API for OrderService 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 OrderServiceClient interface { + CreateOrder(ctx context.Context, in *CreateOrderRequest, opts ...grpc.CallOption) (*CreateOrderResponse, error) + GetOrder(ctx context.Context, in *GetOrderRequest, opts ...grpc.CallOption) (*Order, error) + GetOrdersByUser(ctx context.Context, in *GetOrdersByUserRequest, opts ...grpc.CallOption) (*GetOrdersByUserResponse, error) + UpdateOrder(ctx context.Context, in *UpdateOrderRequest, opts ...grpc.CallOption) (*SuccessResponse, error) + UpdateOrderStatus(ctx context.Context, in *UpdateOrderStatusRequest, opts ...grpc.CallOption) (*SuccessResponse, error) +} + +type orderServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewOrderServiceClient(cc grpc.ClientConnInterface) OrderServiceClient { + return &orderServiceClient{cc} +} + +func (c *orderServiceClient) CreateOrder(ctx context.Context, in *CreateOrderRequest, opts ...grpc.CallOption) (*CreateOrderResponse, error) { + out := new(CreateOrderResponse) + err := c.cc.Invoke(ctx, "/grpc.OrderService/CreateOrder", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *orderServiceClient) GetOrder(ctx context.Context, in *GetOrderRequest, opts ...grpc.CallOption) (*Order, error) { + out := new(Order) + err := c.cc.Invoke(ctx, "/grpc.OrderService/GetOrder", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *orderServiceClient) GetOrdersByUser(ctx context.Context, in *GetOrdersByUserRequest, opts ...grpc.CallOption) (*GetOrdersByUserResponse, error) { + out := new(GetOrdersByUserResponse) + err := c.cc.Invoke(ctx, "/grpc.OrderService/GetOrdersByUser", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *orderServiceClient) UpdateOrder(ctx context.Context, in *UpdateOrderRequest, opts ...grpc.CallOption) (*SuccessResponse, error) { + out := new(SuccessResponse) + err := c.cc.Invoke(ctx, "/grpc.OrderService/UpdateOrder", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *orderServiceClient) UpdateOrderStatus(ctx context.Context, in *UpdateOrderStatusRequest, opts ...grpc.CallOption) (*SuccessResponse, error) { + out := new(SuccessResponse) + err := c.cc.Invoke(ctx, "/grpc.OrderService/UpdateOrderStatus", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// OrderServiceServer is the server API for OrderService service. +// All implementations must embed UnimplementedOrderServiceServer +// for forward compatibility +type OrderServiceServer interface { + CreateOrder(context.Context, *CreateOrderRequest) (*CreateOrderResponse, error) + GetOrder(context.Context, *GetOrderRequest) (*Order, error) + GetOrdersByUser(context.Context, *GetOrdersByUserRequest) (*GetOrdersByUserResponse, error) + UpdateOrder(context.Context, *UpdateOrderRequest) (*SuccessResponse, error) + UpdateOrderStatus(context.Context, *UpdateOrderStatusRequest) (*SuccessResponse, error) + mustEmbedUnimplementedOrderServiceServer() +} + +// UnimplementedOrderServiceServer must be embedded to have forward compatible implementations. +type UnimplementedOrderServiceServer struct { +} + +func (UnimplementedOrderServiceServer) CreateOrder(context.Context, *CreateOrderRequest) (*CreateOrderResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CreateOrder not implemented") +} +func (UnimplementedOrderServiceServer) GetOrder(context.Context, *GetOrderRequest) (*Order, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetOrder not implemented") +} +func (UnimplementedOrderServiceServer) GetOrdersByUser(context.Context, *GetOrdersByUserRequest) (*GetOrdersByUserResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetOrdersByUser not implemented") +} +func (UnimplementedOrderServiceServer) UpdateOrder(context.Context, *UpdateOrderRequest) (*SuccessResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateOrder not implemented") +} +func (UnimplementedOrderServiceServer) UpdateOrderStatus(context.Context, *UpdateOrderStatusRequest) (*SuccessResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateOrderStatus not implemented") +} +func (UnimplementedOrderServiceServer) mustEmbedUnimplementedOrderServiceServer() {} + +// UnsafeOrderServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to OrderServiceServer will +// result in compilation errors. +type UnsafeOrderServiceServer interface { + mustEmbedUnimplementedOrderServiceServer() +} + +func RegisterOrderServiceServer(s grpc.ServiceRegistrar, srv OrderServiceServer) { + s.RegisterService(&OrderService_ServiceDesc, srv) +} + +func _OrderService_CreateOrder_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(CreateOrderRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(OrderServiceServer).CreateOrder(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/grpc.OrderService/CreateOrder", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(OrderServiceServer).CreateOrder(ctx, req.(*CreateOrderRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _OrderService_GetOrder_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetOrderRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(OrderServiceServer).GetOrder(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/grpc.OrderService/GetOrder", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(OrderServiceServer).GetOrder(ctx, req.(*GetOrderRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _OrderService_GetOrdersByUser_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetOrdersByUserRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(OrderServiceServer).GetOrdersByUser(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/grpc.OrderService/GetOrdersByUser", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(OrderServiceServer).GetOrdersByUser(ctx, req.(*GetOrdersByUserRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _OrderService_UpdateOrder_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(UpdateOrderRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(OrderServiceServer).UpdateOrder(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/grpc.OrderService/UpdateOrder", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(OrderServiceServer).UpdateOrder(ctx, req.(*UpdateOrderRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _OrderService_UpdateOrderStatus_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(UpdateOrderStatusRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(OrderServiceServer).UpdateOrderStatus(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/grpc.OrderService/UpdateOrderStatus", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(OrderServiceServer).UpdateOrderStatus(ctx, req.(*UpdateOrderStatusRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// OrderService_ServiceDesc is the grpc.ServiceDesc for OrderService service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var OrderService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "grpc.OrderService", + HandlerType: (*OrderServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "CreateOrder", + Handler: _OrderService_CreateOrder_Handler, + }, + { + MethodName: "GetOrder", + Handler: _OrderService_GetOrder_Handler, + }, + { + MethodName: "GetOrdersByUser", + Handler: _OrderService_GetOrdersByUser_Handler, + }, + { + MethodName: "UpdateOrder", + Handler: _OrderService_UpdateOrder_Handler, + }, + { + MethodName: "UpdateOrderStatus", + Handler: _OrderService_UpdateOrderStatus_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "order/grpc/service.proto", +} diff --git a/product/grpc/service.pb.go b/product/grpc/service.pb.go new file mode 100644 index 0000000..1ddc110 --- /dev/null +++ b/product/grpc/service.pb.go @@ -0,0 +1,741 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.28.1 +// protoc v5.27.0 +// source: product/grpc/service.proto + +package grpc + +import ( + reflect "reflect" + sync "sync" + + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" +) + +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 Product struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + Price float32 `protobuf:"fixed32,3,opt,name=price,proto3" json:"price,omitempty"` + Stock int32 `protobuf:"varint,4,opt,name=stock,proto3" json:"stock,omitempty"` +} + +func (x *Product) Reset() { + *x = Product{} + if protoimpl.UnsafeEnabled { + mi := &file_product_grpc_service_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Product) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Product) ProtoMessage() {} + +func (x *Product) ProtoReflect() protoreflect.Message { + mi := &file_product_grpc_service_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 Product.ProtoReflect.Descriptor instead. +func (*Product) Descriptor() ([]byte, []int) { + return file_product_grpc_service_proto_rawDescGZIP(), []int{0} +} + +func (x *Product) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *Product) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *Product) GetPrice() float32 { + if x != nil { + return x.Price + } + return 0 +} + +func (x *Product) GetStock() int32 { + if x != nil { + return x.Stock + } + return 0 +} + +type CreateProductRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + Price float32 `protobuf:"fixed32,2,opt,name=price,proto3" json:"price,omitempty"` + Stock int32 `protobuf:"varint,3,opt,name=stock,proto3" json:"stock,omitempty"` +} + +func (x *CreateProductRequest) Reset() { + *x = CreateProductRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_product_grpc_service_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CreateProductRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateProductRequest) ProtoMessage() {} + +func (x *CreateProductRequest) ProtoReflect() protoreflect.Message { + mi := &file_product_grpc_service_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 CreateProductRequest.ProtoReflect.Descriptor instead. +func (*CreateProductRequest) Descriptor() ([]byte, []int) { + return file_product_grpc_service_proto_rawDescGZIP(), []int{1} +} + +func (x *CreateProductRequest) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *CreateProductRequest) GetPrice() float32 { + if x != nil { + return x.Price + } + return 0 +} + +func (x *CreateProductRequest) GetStock() int32 { + if x != nil { + return x.Stock + } + return 0 +} + +type CreateProductResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` +} + +func (x *CreateProductResponse) Reset() { + *x = CreateProductResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_product_grpc_service_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CreateProductResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateProductResponse) ProtoMessage() {} + +func (x *CreateProductResponse) ProtoReflect() protoreflect.Message { + mi := &file_product_grpc_service_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 CreateProductResponse.ProtoReflect.Descriptor instead. +func (*CreateProductResponse) Descriptor() ([]byte, []int) { + return file_product_grpc_service_proto_rawDescGZIP(), []int{2} +} + +func (x *CreateProductResponse) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +type GetProductRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` +} + +func (x *GetProductRequest) Reset() { + *x = GetProductRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_product_grpc_service_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetProductRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetProductRequest) ProtoMessage() {} + +func (x *GetProductRequest) ProtoReflect() protoreflect.Message { + mi := &file_product_grpc_service_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 GetProductRequest.ProtoReflect.Descriptor instead. +func (*GetProductRequest) Descriptor() ([]byte, []int) { + return file_product_grpc_service_proto_rawDescGZIP(), []int{3} +} + +func (x *GetProductRequest) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +type GetProductResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Product *Product `protobuf:"bytes,1,opt,name=product,proto3" json:"product,omitempty"` +} + +func (x *GetProductResponse) Reset() { + *x = GetProductResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_product_grpc_service_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetProductResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetProductResponse) ProtoMessage() {} + +func (x *GetProductResponse) ProtoReflect() protoreflect.Message { + mi := &file_product_grpc_service_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 GetProductResponse.ProtoReflect.Descriptor instead. +func (*GetProductResponse) Descriptor() ([]byte, []int) { + return file_product_grpc_service_proto_rawDescGZIP(), []int{4} +} + +func (x *GetProductResponse) GetProduct() *Product { + if x != nil { + return x.Product + } + return nil +} + +type SuccessResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Msg string `protobuf:"bytes,1,opt,name=msg,proto3" json:"msg,omitempty"` +} + +func (x *SuccessResponse) Reset() { + *x = SuccessResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_product_grpc_service_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *SuccessResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SuccessResponse) ProtoMessage() {} + +func (x *SuccessResponse) ProtoReflect() protoreflect.Message { + mi := &file_product_grpc_service_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 SuccessResponse.ProtoReflect.Descriptor instead. +func (*SuccessResponse) Descriptor() ([]byte, []int) { + return file_product_grpc_service_proto_rawDescGZIP(), []int{5} +} + +func (x *SuccessResponse) GetMsg() string { + if x != nil { + return x.Msg + } + return "" +} + +type GetProductsRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` +} + +func (x *GetProductsRequest) Reset() { + *x = GetProductsRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_product_grpc_service_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetProductsRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetProductsRequest) ProtoMessage() {} + +func (x *GetProductsRequest) ProtoReflect() protoreflect.Message { + mi := &file_product_grpc_service_proto_msgTypes[6] + 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 GetProductsRequest.ProtoReflect.Descriptor instead. +func (*GetProductsRequest) Descriptor() ([]byte, []int) { + return file_product_grpc_service_proto_rawDescGZIP(), []int{6} +} + +func (x *GetProductsRequest) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +type GetProductsResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Products []*Product `protobuf:"bytes,1,rep,name=products,proto3" json:"products,omitempty"` +} + +func (x *GetProductsResponse) Reset() { + *x = GetProductsResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_product_grpc_service_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetProductsResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetProductsResponse) ProtoMessage() {} + +func (x *GetProductsResponse) ProtoReflect() protoreflect.Message { + mi := &file_product_grpc_service_proto_msgTypes[7] + 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 GetProductsResponse.ProtoReflect.Descriptor instead. +func (*GetProductsResponse) Descriptor() ([]byte, []int) { + return file_product_grpc_service_proto_rawDescGZIP(), []int{7} +} + +func (x *GetProductsResponse) GetProducts() []*Product { + if x != nil { + return x.Products + } + return nil +} + +type UpdateProductStockRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + Stock int32 `protobuf:"varint,2,opt,name=stock,proto3" json:"stock,omitempty"` +} + +func (x *UpdateProductStockRequest) Reset() { + *x = UpdateProductStockRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_product_grpc_service_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *UpdateProductStockRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdateProductStockRequest) ProtoMessage() {} + +func (x *UpdateProductStockRequest) ProtoReflect() protoreflect.Message { + mi := &file_product_grpc_service_proto_msgTypes[8] + 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 UpdateProductStockRequest.ProtoReflect.Descriptor instead. +func (*UpdateProductStockRequest) Descriptor() ([]byte, []int) { + return file_product_grpc_service_proto_rawDescGZIP(), []int{8} +} + +func (x *UpdateProductStockRequest) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *UpdateProductStockRequest) GetStock() int32 { + if x != nil { + return x.Stock + } + return 0 +} + +var File_product_grpc_service_proto protoreflect.FileDescriptor + +var file_product_grpc_service_proto_rawDesc = []byte{ + 0x0a, 0x1a, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x73, + 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x04, 0x67, 0x72, + 0x70, 0x63, 0x22, 0x59, 0x0a, 0x07, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x12, 0x0e, 0x0a, + 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, + 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, + 0x65, 0x12, 0x14, 0x0a, 0x05, 0x70, 0x72, 0x69, 0x63, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x02, + 0x52, 0x05, 0x70, 0x72, 0x69, 0x63, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x73, 0x74, 0x6f, 0x63, 0x6b, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x73, 0x74, 0x6f, 0x63, 0x6b, 0x22, 0x56, 0x0a, + 0x14, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x70, 0x72, 0x69, + 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x02, 0x52, 0x05, 0x70, 0x72, 0x69, 0x63, 0x65, 0x12, + 0x14, 0x0a, 0x05, 0x73, 0x74, 0x6f, 0x63, 0x6b, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, + 0x73, 0x74, 0x6f, 0x63, 0x6b, 0x22, 0x27, 0x0a, 0x15, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, + 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x0e, + 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x22, 0x23, + 0x0a, 0x11, 0x47, 0x65, 0x74, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, + 0x02, 0x69, 0x64, 0x22, 0x3d, 0x0a, 0x12, 0x47, 0x65, 0x74, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, + 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x27, 0x0a, 0x07, 0x70, 0x72, 0x6f, + 0x64, 0x75, 0x63, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x67, 0x72, 0x70, + 0x63, 0x2e, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x52, 0x07, 0x70, 0x72, 0x6f, 0x64, 0x75, + 0x63, 0x74, 0x22, 0x23, 0x0a, 0x0f, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x6d, 0x73, 0x67, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x03, 0x6d, 0x73, 0x67, 0x22, 0x28, 0x0a, 0x12, 0x47, 0x65, 0x74, 0x50, 0x72, + 0x6f, 0x64, 0x75, 0x63, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, + 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, + 0x65, 0x22, 0x40, 0x0a, 0x13, 0x47, 0x65, 0x74, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x73, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x29, 0x0a, 0x08, 0x70, 0x72, 0x6f, 0x64, + 0x75, 0x63, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x67, 0x72, 0x70, + 0x63, 0x2e, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x52, 0x08, 0x70, 0x72, 0x6f, 0x64, 0x75, + 0x63, 0x74, 0x73, 0x22, 0x41, 0x0a, 0x19, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, + 0x64, 0x75, 0x63, 0x74, 0x53, 0x74, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, + 0x12, 0x14, 0x0a, 0x05, 0x73, 0x74, 0x6f, 0x63, 0x6b, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, + 0x05, 0x73, 0x74, 0x6f, 0x63, 0x6b, 0x32, 0xf5, 0x02, 0x0a, 0x0e, 0x50, 0x72, 0x6f, 0x64, 0x75, + 0x63, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x4a, 0x0a, 0x0d, 0x43, 0x72, 0x65, + 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x12, 0x1a, 0x2e, 0x67, 0x72, 0x70, + 0x63, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x72, + 0x65, 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x41, 0x0a, 0x0a, 0x47, 0x65, 0x74, 0x50, 0x72, 0x6f, 0x64, + 0x75, 0x63, 0x74, 0x12, 0x17, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x72, + 0x6f, 0x64, 0x75, 0x63, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x67, + 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x44, 0x0a, 0x0b, 0x47, 0x65, 0x74, 0x50, + 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x73, 0x12, 0x18, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x47, + 0x65, 0x74, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x19, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x72, 0x6f, 0x64, + 0x75, 0x63, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x3e, + 0x0a, 0x14, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0d, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x50, 0x72, + 0x6f, 0x64, 0x75, 0x63, 0x74, 0x1a, 0x15, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x53, 0x75, 0x63, + 0x63, 0x65, 0x73, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x4e, + 0x0a, 0x12, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x53, + 0x74, 0x6f, 0x63, 0x6b, 0x12, 0x1f, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x55, 0x70, 0x64, 0x61, + 0x74, 0x65, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x53, 0x74, 0x6f, 0x63, 0x6b, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x15, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x53, 0x75, 0x63, + 0x63, 0x65, 0x73, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x3a, + 0x5a, 0x38, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, + 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x50, 0x73, 0x65, 0x75, 0x64, 0x6f, 0x4d, 0x65, 0x72, 0x61, 0x2f, + 0x76, 0x69, 0x72, 0x74, 0x75, 0x61, 0x6c, 0x2d, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2f, 0x70, 0x72, + 0x6f, 0x64, 0x75, 0x63, 0x74, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x33, +} + +var ( + file_product_grpc_service_proto_rawDescOnce sync.Once + file_product_grpc_service_proto_rawDescData = file_product_grpc_service_proto_rawDesc +) + +func file_product_grpc_service_proto_rawDescGZIP() []byte { + file_product_grpc_service_proto_rawDescOnce.Do(func() { + file_product_grpc_service_proto_rawDescData = protoimpl.X.CompressGZIP(file_product_grpc_service_proto_rawDescData) + }) + return file_product_grpc_service_proto_rawDescData +} + +var file_product_grpc_service_proto_msgTypes = make([]protoimpl.MessageInfo, 9) +var file_product_grpc_service_proto_goTypes = []interface{}{ + (*Product)(nil), // 0: grpc.Product + (*CreateProductRequest)(nil), // 1: grpc.CreateProductRequest + (*CreateProductResponse)(nil), // 2: grpc.CreateProductResponse + (*GetProductRequest)(nil), // 3: grpc.GetProductRequest + (*GetProductResponse)(nil), // 4: grpc.GetProductResponse + (*SuccessResponse)(nil), // 5: grpc.SuccessResponse + (*GetProductsRequest)(nil), // 6: grpc.GetProductsRequest + (*GetProductsResponse)(nil), // 7: grpc.GetProductsResponse + (*UpdateProductStockRequest)(nil), // 8: grpc.UpdateProductStockRequest +} +var file_product_grpc_service_proto_depIdxs = []int32{ + 0, // 0: grpc.GetProductResponse.product:type_name -> grpc.Product + 0, // 1: grpc.GetProductsResponse.products:type_name -> grpc.Product + 1, // 2: grpc.ProductService.CreateProduct:input_type -> grpc.CreateProductRequest + 3, // 3: grpc.ProductService.GetProduct:input_type -> grpc.GetProductRequest + 6, // 4: grpc.ProductService.GetProducts:input_type -> grpc.GetProductsRequest + 0, // 5: grpc.ProductService.UpdateProductRequest:input_type -> grpc.Product + 8, // 6: grpc.ProductService.UpdateProductStock:input_type -> grpc.UpdateProductStockRequest + 2, // 7: grpc.ProductService.CreateProduct:output_type -> grpc.CreateProductResponse + 4, // 8: grpc.ProductService.GetProduct:output_type -> grpc.GetProductResponse + 7, // 9: grpc.ProductService.GetProducts:output_type -> grpc.GetProductsResponse + 5, // 10: grpc.ProductService.UpdateProductRequest:output_type -> grpc.SuccessResponse + 5, // 11: grpc.ProductService.UpdateProductStock:output_type -> grpc.SuccessResponse + 7, // [7:12] is the sub-list for method output_type + 2, // [2:7] 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_product_grpc_service_proto_init() } +func file_product_grpc_service_proto_init() { + if File_product_grpc_service_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_product_grpc_service_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Product); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_product_grpc_service_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CreateProductRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_product_grpc_service_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CreateProductResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_product_grpc_service_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetProductRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_product_grpc_service_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetProductResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_product_grpc_service_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SuccessResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_product_grpc_service_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetProductsRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_product_grpc_service_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetProductsResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_product_grpc_service_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*UpdateProductStockRequest); 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_product_grpc_service_proto_rawDesc, + NumEnums: 0, + NumMessages: 9, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_product_grpc_service_proto_goTypes, + DependencyIndexes: file_product_grpc_service_proto_depIdxs, + MessageInfos: file_product_grpc_service_proto_msgTypes, + }.Build() + File_product_grpc_service_proto = out.File + file_product_grpc_service_proto_rawDesc = nil + file_product_grpc_service_proto_goTypes = nil + file_product_grpc_service_proto_depIdxs = nil +} diff --git a/product/grpc/service_grpc.pb.go b/product/grpc/service_grpc.pb.go new file mode 100644 index 0000000..bd13ee2 --- /dev/null +++ b/product/grpc/service_grpc.pb.go @@ -0,0 +1,250 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.2.0 +// - protoc v5.27.0 +// source: product/grpc/service.proto + +package grpc + +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 + +// ProductServiceClient is the client API for ProductService 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 ProductServiceClient interface { + CreateProduct(ctx context.Context, in *CreateProductRequest, opts ...grpc.CallOption) (*CreateProductResponse, error) + GetProduct(ctx context.Context, in *GetProductRequest, opts ...grpc.CallOption) (*GetProductResponse, error) + GetProducts(ctx context.Context, in *GetProductsRequest, opts ...grpc.CallOption) (*GetProductsResponse, error) + UpdateProductRequest(ctx context.Context, in *Product, opts ...grpc.CallOption) (*SuccessResponse, error) + UpdateProductStock(ctx context.Context, in *UpdateProductStockRequest, opts ...grpc.CallOption) (*SuccessResponse, error) +} + +type productServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewProductServiceClient(cc grpc.ClientConnInterface) ProductServiceClient { + return &productServiceClient{cc} +} + +func (c *productServiceClient) CreateProduct(ctx context.Context, in *CreateProductRequest, opts ...grpc.CallOption) (*CreateProductResponse, error) { + out := new(CreateProductResponse) + err := c.cc.Invoke(ctx, "/grpc.ProductService/CreateProduct", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *productServiceClient) GetProduct(ctx context.Context, in *GetProductRequest, opts ...grpc.CallOption) (*GetProductResponse, error) { + out := new(GetProductResponse) + err := c.cc.Invoke(ctx, "/grpc.ProductService/GetProduct", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *productServiceClient) GetProducts(ctx context.Context, in *GetProductsRequest, opts ...grpc.CallOption) (*GetProductsResponse, error) { + out := new(GetProductsResponse) + err := c.cc.Invoke(ctx, "/grpc.ProductService/GetProducts", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *productServiceClient) UpdateProductRequest(ctx context.Context, in *Product, opts ...grpc.CallOption) (*SuccessResponse, error) { + out := new(SuccessResponse) + err := c.cc.Invoke(ctx, "/grpc.ProductService/UpdateProductRequest", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *productServiceClient) UpdateProductStock(ctx context.Context, in *UpdateProductStockRequest, opts ...grpc.CallOption) (*SuccessResponse, error) { + out := new(SuccessResponse) + err := c.cc.Invoke(ctx, "/grpc.ProductService/UpdateProductStock", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// ProductServiceServer is the server API for ProductService service. +// All implementations must embed UnimplementedProductServiceServer +// for forward compatibility +type ProductServiceServer interface { + CreateProduct(context.Context, *CreateProductRequest) (*CreateProductResponse, error) + GetProduct(context.Context, *GetProductRequest) (*GetProductResponse, error) + GetProducts(context.Context, *GetProductsRequest) (*GetProductsResponse, error) + UpdateProductRequest(context.Context, *Product) (*SuccessResponse, error) + UpdateProductStock(context.Context, *UpdateProductStockRequest) (*SuccessResponse, error) + mustEmbedUnimplementedProductServiceServer() +} + +// UnimplementedProductServiceServer must be embedded to have forward compatible implementations. +type UnimplementedProductServiceServer struct { +} + +func (UnimplementedProductServiceServer) CreateProduct(context.Context, *CreateProductRequest) (*CreateProductResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CreateProduct not implemented") +} +func (UnimplementedProductServiceServer) GetProduct(context.Context, *GetProductRequest) (*GetProductResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetProduct not implemented") +} +func (UnimplementedProductServiceServer) GetProducts(context.Context, *GetProductsRequest) (*GetProductsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetProducts not implemented") +} +func (UnimplementedProductServiceServer) UpdateProductRequest(context.Context, *Product) (*SuccessResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateProductRequest not implemented") +} +func (UnimplementedProductServiceServer) UpdateProductStock(context.Context, *UpdateProductStockRequest) (*SuccessResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateProductStock not implemented") +} +func (UnimplementedProductServiceServer) mustEmbedUnimplementedProductServiceServer() {} + +// UnsafeProductServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to ProductServiceServer will +// result in compilation errors. +type UnsafeProductServiceServer interface { + mustEmbedUnimplementedProductServiceServer() +} + +func RegisterProductServiceServer(s grpc.ServiceRegistrar, srv ProductServiceServer) { + s.RegisterService(&ProductService_ServiceDesc, srv) +} + +func _ProductService_CreateProduct_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(CreateProductRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ProductServiceServer).CreateProduct(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/grpc.ProductService/CreateProduct", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ProductServiceServer).CreateProduct(ctx, req.(*CreateProductRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _ProductService_GetProduct_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetProductRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ProductServiceServer).GetProduct(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/grpc.ProductService/GetProduct", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ProductServiceServer).GetProduct(ctx, req.(*GetProductRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _ProductService_GetProducts_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetProductsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ProductServiceServer).GetProducts(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/grpc.ProductService/GetProducts", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ProductServiceServer).GetProducts(ctx, req.(*GetProductsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _ProductService_UpdateProductRequest_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(Product) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ProductServiceServer).UpdateProductRequest(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/grpc.ProductService/UpdateProductRequest", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ProductServiceServer).UpdateProductRequest(ctx, req.(*Product)) + } + return interceptor(ctx, in, info, handler) +} + +func _ProductService_UpdateProductStock_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(UpdateProductStockRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ProductServiceServer).UpdateProductStock(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/grpc.ProductService/UpdateProductStock", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ProductServiceServer).UpdateProductStock(ctx, req.(*UpdateProductStockRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// ProductService_ServiceDesc is the grpc.ServiceDesc for ProductService service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var ProductService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "grpc.ProductService", + HandlerType: (*ProductServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "CreateProduct", + Handler: _ProductService_CreateProduct_Handler, + }, + { + MethodName: "GetProduct", + Handler: _ProductService_GetProduct_Handler, + }, + { + MethodName: "GetProducts", + Handler: _ProductService_GetProducts_Handler, + }, + { + MethodName: "UpdateProductRequest", + Handler: _ProductService_UpdateProductRequest_Handler, + }, + { + MethodName: "UpdateProductStock", + Handler: _ProductService_UpdateProductStock_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "product/grpc/service.proto", +} diff --git a/user/grpc/service.pb.go b/user/grpc/service.pb.go new file mode 100644 index 0000000..1f4e51c --- /dev/null +++ b/user/grpc/service.pb.go @@ -0,0 +1,857 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.28.1 +// protoc v5.27.0 +// source: user/grpc/service.proto + +package grpc + +import ( + reflect "reflect" + sync "sync" + + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" +) + +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 User struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + Email string `protobuf:"bytes,2,opt,name=email,proto3" json:"email,omitempty"` + Password string `protobuf:"bytes,3,opt,name=password,proto3" json:"password,omitempty"` +} + +func (x *User) Reset() { + *x = User{} + if protoimpl.UnsafeEnabled { + mi := &file_user_grpc_service_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *User) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*User) ProtoMessage() {} + +func (x *User) ProtoReflect() protoreflect.Message { + mi := &file_user_grpc_service_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 User.ProtoReflect.Descriptor instead. +func (*User) Descriptor() ([]byte, []int) { + return file_user_grpc_service_proto_rawDescGZIP(), []int{0} +} + +func (x *User) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *User) GetEmail() string { + if x != nil { + return x.Email + } + return "" +} + +func (x *User) GetPassword() string { + if x != nil { + return x.Password + } + return "" +} + +type Profile struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + UserID int64 `protobuf:"varint,2,opt,name=userID,proto3" json:"userID,omitempty"` + Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty"` + Photo string `protobuf:"bytes,4,opt,name=photo,proto3" json:"photo,omitempty"` + Country string `protobuf:"bytes,5,opt,name=country,proto3" json:"country,omitempty"` + Address string `protobuf:"bytes,6,opt,name=address,proto3" json:"address,omitempty"` + Phone string `protobuf:"bytes,7,opt,name=phone,proto3" json:"phone,omitempty"` +} + +func (x *Profile) Reset() { + *x = Profile{} + if protoimpl.UnsafeEnabled { + mi := &file_user_grpc_service_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Profile) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Profile) ProtoMessage() {} + +func (x *Profile) ProtoReflect() protoreflect.Message { + mi := &file_user_grpc_service_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 Profile.ProtoReflect.Descriptor instead. +func (*Profile) Descriptor() ([]byte, []int) { + return file_user_grpc_service_proto_rawDescGZIP(), []int{1} +} + +func (x *Profile) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *Profile) GetUserID() int64 { + if x != nil { + return x.UserID + } + return 0 +} + +func (x *Profile) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *Profile) GetPhoto() string { + if x != nil { + return x.Photo + } + return "" +} + +func (x *Profile) GetCountry() string { + if x != nil { + return x.Country + } + return "" +} + +func (x *Profile) GetAddress() string { + if x != nil { + return x.Address + } + return "" +} + +func (x *Profile) GetPhone() string { + if x != nil { + return x.Phone + } + return "" +} + +type GetUserRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Email string `protobuf:"bytes,1,opt,name=email,proto3" json:"email,omitempty"` +} + +func (x *GetUserRequest) Reset() { + *x = GetUserRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_user_grpc_service_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetUserRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetUserRequest) ProtoMessage() {} + +func (x *GetUserRequest) ProtoReflect() protoreflect.Message { + mi := &file_user_grpc_service_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 GetUserRequest.ProtoReflect.Descriptor instead. +func (*GetUserRequest) Descriptor() ([]byte, []int) { + return file_user_grpc_service_proto_rawDescGZIP(), []int{2} +} + +func (x *GetUserRequest) GetEmail() string { + if x != nil { + return x.Email + } + return "" +} + +type CreateUserRequest 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 *CreateUserRequest) Reset() { + *x = CreateUserRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_user_grpc_service_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CreateUserRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateUserRequest) ProtoMessage() {} + +func (x *CreateUserRequest) ProtoReflect() protoreflect.Message { + mi := &file_user_grpc_service_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 CreateUserRequest.ProtoReflect.Descriptor instead. +func (*CreateUserRequest) Descriptor() ([]byte, []int) { + return file_user_grpc_service_proto_rawDescGZIP(), []int{3} +} + +func (x *CreateUserRequest) GetEmail() string { + if x != nil { + return x.Email + } + return "" +} + +func (x *CreateUserRequest) GetPassword() string { + if x != nil { + return x.Password + } + return "" +} + +type CreateUserProfileRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + Photo string `protobuf:"bytes,3,opt,name=photo,proto3" json:"photo,omitempty"` + Country string `protobuf:"bytes,4,opt,name=country,proto3" json:"country,omitempty"` + Address string `protobuf:"bytes,5,opt,name=address,proto3" json:"address,omitempty"` + Phone string `protobuf:"bytes,6,opt,name=phone,proto3" json:"phone,omitempty"` +} + +func (x *CreateUserProfileRequest) Reset() { + *x = CreateUserProfileRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_user_grpc_service_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CreateUserProfileRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateUserProfileRequest) ProtoMessage() {} + +func (x *CreateUserProfileRequest) ProtoReflect() protoreflect.Message { + mi := &file_user_grpc_service_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 CreateUserProfileRequest.ProtoReflect.Descriptor instead. +func (*CreateUserProfileRequest) Descriptor() ([]byte, []int) { + return file_user_grpc_service_proto_rawDescGZIP(), []int{4} +} + +func (x *CreateUserProfileRequest) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *CreateUserProfileRequest) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *CreateUserProfileRequest) GetPhoto() string { + if x != nil { + return x.Photo + } + return "" +} + +func (x *CreateUserProfileRequest) GetCountry() string { + if x != nil { + return x.Country + } + return "" +} + +func (x *CreateUserProfileRequest) GetAddress() string { + if x != nil { + return x.Address + } + return "" +} + +func (x *CreateUserProfileRequest) GetPhone() string { + if x != nil { + return x.Phone + } + return "" +} + +type CreateUserProfileResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` +} + +func (x *CreateUserProfileResponse) Reset() { + *x = CreateUserProfileResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_user_grpc_service_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CreateUserProfileResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateUserProfileResponse) ProtoMessage() {} + +func (x *CreateUserProfileResponse) ProtoReflect() protoreflect.Message { + mi := &file_user_grpc_service_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 CreateUserProfileResponse.ProtoReflect.Descriptor instead. +func (*CreateUserProfileResponse) Descriptor() ([]byte, []int) { + return file_user_grpc_service_proto_rawDescGZIP(), []int{5} +} + +func (x *CreateUserProfileResponse) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +type GetUserProfileRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` +} + +func (x *GetUserProfileRequest) Reset() { + *x = GetUserProfileRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_user_grpc_service_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetUserProfileRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetUserProfileRequest) ProtoMessage() {} + +func (x *GetUserProfileRequest) ProtoReflect() protoreflect.Message { + mi := &file_user_grpc_service_proto_msgTypes[6] + 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 GetUserProfileRequest.ProtoReflect.Descriptor instead. +func (*GetUserProfileRequest) Descriptor() ([]byte, []int) { + return file_user_grpc_service_proto_rawDescGZIP(), []int{6} +} + +func (x *GetUserProfileRequest) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +type UpdateUserProfileRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + UserID int64 `protobuf:"varint,1,opt,name=userID,proto3" json:"userID,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + Photo string `protobuf:"bytes,3,opt,name=photo,proto3" json:"photo,omitempty"` + Country string `protobuf:"bytes,4,opt,name=country,proto3" json:"country,omitempty"` + Address string `protobuf:"bytes,5,opt,name=address,proto3" json:"address,omitempty"` + Phone string `protobuf:"bytes,6,opt,name=phone,proto3" json:"phone,omitempty"` +} + +func (x *UpdateUserProfileRequest) Reset() { + *x = UpdateUserProfileRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_user_grpc_service_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *UpdateUserProfileRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*UpdateUserProfileRequest) ProtoMessage() {} + +func (x *UpdateUserProfileRequest) ProtoReflect() protoreflect.Message { + mi := &file_user_grpc_service_proto_msgTypes[7] + 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 UpdateUserProfileRequest.ProtoReflect.Descriptor instead. +func (*UpdateUserProfileRequest) Descriptor() ([]byte, []int) { + return file_user_grpc_service_proto_rawDescGZIP(), []int{7} +} + +func (x *UpdateUserProfileRequest) GetUserID() int64 { + if x != nil { + return x.UserID + } + return 0 +} + +func (x *UpdateUserProfileRequest) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *UpdateUserProfileRequest) GetPhoto() string { + if x != nil { + return x.Photo + } + return "" +} + +func (x *UpdateUserProfileRequest) GetCountry() string { + if x != nil { + return x.Country + } + return "" +} + +func (x *UpdateUserProfileRequest) GetAddress() string { + if x != nil { + return x.Address + } + return "" +} + +func (x *UpdateUserProfileRequest) GetPhone() string { + if x != nil { + return x.Phone + } + return "" +} + +type SuccessResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Msg string `protobuf:"bytes,1,opt,name=msg,proto3" json:"msg,omitempty"` +} + +func (x *SuccessResponse) Reset() { + *x = SuccessResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_user_grpc_service_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *SuccessResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SuccessResponse) ProtoMessage() {} + +func (x *SuccessResponse) ProtoReflect() protoreflect.Message { + mi := &file_user_grpc_service_proto_msgTypes[8] + 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 SuccessResponse.ProtoReflect.Descriptor instead. +func (*SuccessResponse) Descriptor() ([]byte, []int) { + return file_user_grpc_service_proto_rawDescGZIP(), []int{8} +} + +func (x *SuccessResponse) GetMsg() string { + if x != nil { + return x.Msg + } + return "" +} + +var File_user_grpc_service_proto protoreflect.FileDescriptor + +var file_user_grpc_service_proto_rawDesc = []byte{ + 0x0a, 0x17, 0x75, 0x73, 0x65, 0x72, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x73, 0x65, 0x72, 0x76, + 0x69, 0x63, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x04, 0x67, 0x72, 0x70, 0x63, 0x22, + 0x48, 0x0a, 0x04, 0x55, 0x73, 0x65, 0x72, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x12, 0x1a, 0x0a, + 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x22, 0xa5, 0x01, 0x0a, 0x07, 0x50, 0x72, + 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x44, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x44, 0x12, 0x12, 0x0a, + 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, + 0x65, 0x12, 0x14, 0x0a, 0x05, 0x70, 0x68, 0x6f, 0x74, 0x6f, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x05, 0x70, 0x68, 0x6f, 0x74, 0x6f, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x75, 0x6e, 0x74, + 0x72, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x72, + 0x79, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x06, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x70, + 0x68, 0x6f, 0x6e, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x70, 0x68, 0x6f, 0x6e, + 0x65, 0x22, 0x26, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 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, 0x22, 0x45, 0x0a, 0x11, 0x43, 0x72, 0x65, + 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 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, 0x9e, 0x01, 0x0a, 0x18, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x50, + 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, + 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, + 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, + 0x65, 0x12, 0x14, 0x0a, 0x05, 0x70, 0x68, 0x6f, 0x74, 0x6f, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x05, 0x70, 0x68, 0x6f, 0x74, 0x6f, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x75, 0x6e, 0x74, + 0x72, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x72, + 0x79, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x05, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x70, + 0x68, 0x6f, 0x6e, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x70, 0x68, 0x6f, 0x6e, + 0x65, 0x22, 0x2b, 0x0a, 0x19, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x50, + 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x0e, + 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x22, 0x27, + 0x0a, 0x15, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x50, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x22, 0xa6, 0x01, 0x0a, 0x18, 0x55, 0x70, 0x64, 0x61, + 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x50, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x44, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x44, 0x12, 0x12, 0x0a, 0x04, + 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, + 0x12, 0x14, 0x0a, 0x05, 0x70, 0x68, 0x6f, 0x74, 0x6f, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x05, 0x70, 0x68, 0x6f, 0x74, 0x6f, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x72, + 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x72, 0x79, + 0x12, 0x18, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x70, 0x68, + 0x6f, 0x6e, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x70, 0x68, 0x6f, 0x6e, 0x65, + 0x22, 0x23, 0x0a, 0x0f, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x6d, 0x73, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x03, 0x6d, 0x73, 0x67, 0x32, 0xd7, 0x02, 0x0a, 0x0b, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, + 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x2d, 0x0a, 0x07, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, + 0x12, 0x14, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0a, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x55, 0x73, + 0x65, 0x72, 0x22, 0x00, 0x12, 0x33, 0x0a, 0x0a, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x55, 0x73, + 0x65, 0x72, 0x12, 0x17, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, + 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0a, 0x2e, 0x67, 0x72, + 0x70, 0x63, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x22, 0x00, 0x12, 0x56, 0x0a, 0x11, 0x43, 0x72, 0x65, + 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x50, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x12, 0x1e, + 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, + 0x50, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1f, + 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, + 0x50, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, + 0x00, 0x12, 0x3e, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x50, 0x72, 0x6f, 0x66, + 0x69, 0x6c, 0x65, 0x12, 0x1b, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, 0x55, 0x73, + 0x65, 0x72, 0x50, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x0d, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x50, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x22, + 0x00, 0x12, 0x4c, 0x0a, 0x11, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x50, + 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x12, 0x1e, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x55, 0x70, + 0x64, 0x61, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x50, 0x72, 0x6f, 0x66, 0x69, 0x6c, 0x65, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x15, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x53, 0x75, + 0x63, 0x63, 0x65, 0x73, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, + 0x37, 0x5a, 0x35, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x67, 0x69, 0x74, 0x68, 0x75, + 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x50, 0x73, 0x65, 0x75, 0x64, 0x6f, 0x4d, 0x65, 0x72, 0x61, + 0x2f, 0x76, 0x69, 0x72, 0x74, 0x75, 0x61, 0x6c, 0x2d, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2f, 0x75, + 0x73, 0x65, 0x72, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_user_grpc_service_proto_rawDescOnce sync.Once + file_user_grpc_service_proto_rawDescData = file_user_grpc_service_proto_rawDesc +) + +func file_user_grpc_service_proto_rawDescGZIP() []byte { + file_user_grpc_service_proto_rawDescOnce.Do(func() { + file_user_grpc_service_proto_rawDescData = protoimpl.X.CompressGZIP(file_user_grpc_service_proto_rawDescData) + }) + return file_user_grpc_service_proto_rawDescData +} + +var file_user_grpc_service_proto_msgTypes = make([]protoimpl.MessageInfo, 9) +var file_user_grpc_service_proto_goTypes = []interface{}{ + (*User)(nil), // 0: grpc.User + (*Profile)(nil), // 1: grpc.Profile + (*GetUserRequest)(nil), // 2: grpc.GetUserRequest + (*CreateUserRequest)(nil), // 3: grpc.CreateUserRequest + (*CreateUserProfileRequest)(nil), // 4: grpc.CreateUserProfileRequest + (*CreateUserProfileResponse)(nil), // 5: grpc.CreateUserProfileResponse + (*GetUserProfileRequest)(nil), // 6: grpc.GetUserProfileRequest + (*UpdateUserProfileRequest)(nil), // 7: grpc.UpdateUserProfileRequest + (*SuccessResponse)(nil), // 8: grpc.SuccessResponse +} +var file_user_grpc_service_proto_depIdxs = []int32{ + 2, // 0: grpc.UserService.GetUser:input_type -> grpc.GetUserRequest + 3, // 1: grpc.UserService.CreateUser:input_type -> grpc.CreateUserRequest + 4, // 2: grpc.UserService.CreateUserProfile:input_type -> grpc.CreateUserProfileRequest + 6, // 3: grpc.UserService.GetUserProfile:input_type -> grpc.GetUserProfileRequest + 7, // 4: grpc.UserService.UpdateUserProfile:input_type -> grpc.UpdateUserProfileRequest + 0, // 5: grpc.UserService.GetUser:output_type -> grpc.User + 0, // 6: grpc.UserService.CreateUser:output_type -> grpc.User + 5, // 7: grpc.UserService.CreateUserProfile:output_type -> grpc.CreateUserProfileResponse + 1, // 8: grpc.UserService.GetUserProfile:output_type -> grpc.Profile + 8, // 9: grpc.UserService.UpdateUserProfile:output_type -> grpc.SuccessResponse + 5, // [5:10] is the sub-list for method output_type + 0, // [0:5] 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_user_grpc_service_proto_init() } +func file_user_grpc_service_proto_init() { + if File_user_grpc_service_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_user_grpc_service_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*User); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_user_grpc_service_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Profile); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_user_grpc_service_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetUserRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_user_grpc_service_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CreateUserRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_user_grpc_service_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CreateUserProfileRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_user_grpc_service_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CreateUserProfileResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_user_grpc_service_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetUserProfileRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_user_grpc_service_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*UpdateUserProfileRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_user_grpc_service_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SuccessResponse); 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_user_grpc_service_proto_rawDesc, + NumEnums: 0, + NumMessages: 9, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_user_grpc_service_proto_goTypes, + DependencyIndexes: file_user_grpc_service_proto_depIdxs, + MessageInfos: file_user_grpc_service_proto_msgTypes, + }.Build() + File_user_grpc_service_proto = out.File + file_user_grpc_service_proto_rawDesc = nil + file_user_grpc_service_proto_goTypes = nil + file_user_grpc_service_proto_depIdxs = nil +} diff --git a/user/grpc/service_grpc.pb.go b/user/grpc/service_grpc.pb.go new file mode 100644 index 0000000..3411cb0 --- /dev/null +++ b/user/grpc/service_grpc.pb.go @@ -0,0 +1,250 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.2.0 +// - protoc v5.27.0 +// source: user/grpc/service.proto + +package grpc + +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 + +// 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 { + GetUser(ctx context.Context, in *GetUserRequest, opts ...grpc.CallOption) (*User, error) + CreateUser(ctx context.Context, in *CreateUserRequest, opts ...grpc.CallOption) (*User, error) + CreateUserProfile(ctx context.Context, in *CreateUserProfileRequest, opts ...grpc.CallOption) (*CreateUserProfileResponse, error) + GetUserProfile(ctx context.Context, in *GetUserProfileRequest, opts ...grpc.CallOption) (*Profile, error) + UpdateUserProfile(ctx context.Context, in *UpdateUserProfileRequest, opts ...grpc.CallOption) (*SuccessResponse, error) +} + +type userServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewUserServiceClient(cc grpc.ClientConnInterface) UserServiceClient { + return &userServiceClient{cc} +} + +func (c *userServiceClient) GetUser(ctx context.Context, in *GetUserRequest, opts ...grpc.CallOption) (*User, error) { + out := new(User) + err := c.cc.Invoke(ctx, "/grpc.UserService/GetUser", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *userServiceClient) CreateUser(ctx context.Context, in *CreateUserRequest, opts ...grpc.CallOption) (*User, error) { + out := new(User) + err := c.cc.Invoke(ctx, "/grpc.UserService/CreateUser", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *userServiceClient) CreateUserProfile(ctx context.Context, in *CreateUserProfileRequest, opts ...grpc.CallOption) (*CreateUserProfileResponse, error) { + out := new(CreateUserProfileResponse) + err := c.cc.Invoke(ctx, "/grpc.UserService/CreateUserProfile", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *userServiceClient) GetUserProfile(ctx context.Context, in *GetUserProfileRequest, opts ...grpc.CallOption) (*Profile, error) { + out := new(Profile) + err := c.cc.Invoke(ctx, "/grpc.UserService/GetUserProfile", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *userServiceClient) UpdateUserProfile(ctx context.Context, in *UpdateUserProfileRequest, opts ...grpc.CallOption) (*SuccessResponse, error) { + out := new(SuccessResponse) + err := c.cc.Invoke(ctx, "/grpc.UserService/UpdateUserProfile", in, out, opts...) + 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 { + GetUser(context.Context, *GetUserRequest) (*User, error) + CreateUser(context.Context, *CreateUserRequest) (*User, error) + CreateUserProfile(context.Context, *CreateUserProfileRequest) (*CreateUserProfileResponse, error) + GetUserProfile(context.Context, *GetUserProfileRequest) (*Profile, error) + UpdateUserProfile(context.Context, *UpdateUserProfileRequest) (*SuccessResponse, error) + mustEmbedUnimplementedUserServiceServer() +} + +// UnimplementedUserServiceServer must be embedded to have forward compatible implementations. +type UnimplementedUserServiceServer struct { +} + +func (UnimplementedUserServiceServer) GetUser(context.Context, *GetUserRequest) (*User, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetUser not implemented") +} +func (UnimplementedUserServiceServer) CreateUser(context.Context, *CreateUserRequest) (*User, error) { + return nil, status.Errorf(codes.Unimplemented, "method CreateUser not implemented") +} +func (UnimplementedUserServiceServer) CreateUserProfile(context.Context, *CreateUserProfileRequest) (*CreateUserProfileResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CreateUserProfile not implemented") +} +func (UnimplementedUserServiceServer) GetUserProfile(context.Context, *GetUserProfileRequest) (*Profile, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetUserProfile not implemented") +} +func (UnimplementedUserServiceServer) UpdateUserProfile(context.Context, *UpdateUserProfileRequest) (*SuccessResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateUserProfile not implemented") +} +func (UnimplementedUserServiceServer) mustEmbedUnimplementedUserServiceServer() {} + +// 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) { + s.RegisterService(&UserService_ServiceDesc, srv) +} + +func _UserService_GetUser_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetUserRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(UserServiceServer).GetUser(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/grpc.UserService/GetUser", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(UserServiceServer).GetUser(ctx, req.(*GetUserRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _UserService_CreateUser_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(CreateUserRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(UserServiceServer).CreateUser(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/grpc.UserService/CreateUser", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(UserServiceServer).CreateUser(ctx, req.(*CreateUserRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _UserService_CreateUserProfile_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(CreateUserProfileRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(UserServiceServer).CreateUserProfile(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/grpc.UserService/CreateUserProfile", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(UserServiceServer).CreateUserProfile(ctx, req.(*CreateUserProfileRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _UserService_GetUserProfile_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetUserProfileRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(UserServiceServer).GetUserProfile(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/grpc.UserService/GetUserProfile", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(UserServiceServer).GetUserProfile(ctx, req.(*GetUserProfileRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _UserService_UpdateUserProfile_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(UpdateUserProfileRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(UserServiceServer).UpdateUserProfile(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/grpc.UserService/UpdateUserProfile", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(UserServiceServer).UpdateUserProfile(ctx, req.(*UpdateUserProfileRequest)) + } + 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: "grpc.UserService", + HandlerType: (*UserServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "GetUser", + Handler: _UserService_GetUser_Handler, + }, + { + MethodName: "CreateUser", + Handler: _UserService_CreateUser_Handler, + }, + { + MethodName: "CreateUserProfile", + Handler: _UserService_CreateUserProfile_Handler, + }, + { + MethodName: "GetUserProfile", + Handler: _UserService_GetUserProfile_Handler, + }, + { + MethodName: "UpdateUserProfile", + Handler: _UserService_UpdateUserProfile_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "user/grpc/service.proto", +}