├── .gitignore ├── diagram.drawio.png ├── product-svc ├── pkg │ ├── config │ │ ├── envs │ │ │ └── dev.env │ │ └── config.go │ ├── models │ │ ├── stock_decrease_log.go │ │ └── product.go │ ├── db │ │ └── db.go │ ├── pb │ │ ├── product.proto │ │ └── product_grpc.pb.go │ └── services │ │ └── product.go ├── Makefile ├── Dockerfile ├── cmd │ └── main.go └── go.mod ├── auth-svc ├── Makefile ├── pkg │ ├── config │ │ ├── envs │ │ │ └── dev.env │ │ └── config.go │ ├── models │ │ └── auth.go │ ├── utils │ │ ├── hash.go │ │ └── jwt.go │ ├── pb │ │ ├── auth.proto │ │ ├── auth_grpc.pb.go │ │ └── auth.pb.go │ ├── services │ │ ├── admin.go │ │ └── auth.go │ └── db │ │ └── db.go ├── Dockerfile ├── cmd │ └── main.go └── go.mod ├── order-svc ├── Makefile ├── pkg │ ├── config │ │ ├── envs │ │ │ └── dev.env │ │ └── config.go │ ├── models │ │ └── order.go │ ├── pb │ │ ├── order.proto │ │ ├── product.proto │ │ ├── order_grpc.pb.go │ │ ├── product_grpc.pb.go │ │ ├── order.pb.go │ │ └── product.pb.go │ ├── db │ │ └── db.go │ ├── client │ │ └── product_client.go │ └── services │ │ └── order.go ├── Dockerfile ├── cmd │ └── main.go └── go.mod ├── api-gateway ├── pkg │ ├── config │ │ ├── envs │ │ │ └── dev.env │ │ └── config.go │ ├── product │ │ ├── routes │ │ │ ├── find_all.go │ │ │ ├── find_one.go │ │ │ └── create_product.go │ │ ├── client.go │ │ ├── routes.go │ │ └── pb │ │ │ ├── product.proto │ │ │ └── product_grpc.pb.go │ ├── auth │ │ ├── client.go │ │ ├── routes │ │ │ ├── login.go │ │ │ ├── admin_login.go │ │ │ └── register.go │ │ ├── routes.go │ │ ├── middleware.go │ │ └── pb │ │ │ ├── auth.proto │ │ │ ├── auth_grpc.pb.go │ │ │ └── auth.pb.go │ └── order │ │ ├── client.go │ │ ├── routes.go │ │ ├── routes │ │ └── create_order.go │ │ └── pb │ │ ├── order.proto │ │ ├── order_grpc.pb.go │ │ └── order.pb.go ├── Makefile ├── Dockerfile ├── cmd │ └── main.go └── go.mod ├── README.md ├── .github └── workflows │ ├── test.yml │ └── deploy.yml ├── Makefile └── docker-compose.yml /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | .env -------------------------------------------------------------------------------- /diagram.drawio.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amalmadhu06/go-grpc-microservices/HEAD/diagram.drawio.png -------------------------------------------------------------------------------- /product-svc/pkg/config/envs/dev.env: -------------------------------------------------------------------------------- 1 | PORT=:50052 2 | DB_URL=postgres://postgres:postgres@localhost:5432/product_svc -------------------------------------------------------------------------------- /auth-svc/Makefile: -------------------------------------------------------------------------------- 1 | proto: 2 | protoc --go_out=. --go-grpc_out=. pkg/pb/*.proto 3 | 4 | server: 5 | go run cmd/main.go -------------------------------------------------------------------------------- /order-svc/Makefile: -------------------------------------------------------------------------------- 1 | proto: 2 | protoc --go_out=. --go-grpc_out=. pkg/pb/*.proto 3 | 4 | server: 5 | go run cmd/main.go -------------------------------------------------------------------------------- /product-svc/Makefile: -------------------------------------------------------------------------------- 1 | proto: 2 | protoc --go_out=. --go-grpc_out=. pkg/pb/*.proto 3 | 4 | server: 5 | go run cmd/main.go -------------------------------------------------------------------------------- /auth-svc/pkg/config/envs/dev.env: -------------------------------------------------------------------------------- 1 | PORT=:50051 2 | DB_URL=postgres://postgres:postgres@localhost:5432/auth_svc 3 | JWT_SECRET_KEY=h28dh582fcu390 -------------------------------------------------------------------------------- /api-gateway/pkg/config/envs/dev.env: -------------------------------------------------------------------------------- 1 | PORT=:3000 2 | AUTH_SUV_URL=localhost:50051 3 | PRODUCT_SUV_URL=localhost:50052 4 | ORDER_SUV_URL=localhost:50053 -------------------------------------------------------------------------------- /order-svc/pkg/config/envs/dev.env: -------------------------------------------------------------------------------- 1 | PORT=:50053 2 | DB_URL=postgres://postgres:postgres@localhost:5432/order_svc 3 | PRODUCT_SVC_URL=localhost:50052 -------------------------------------------------------------------------------- /product-svc/pkg/models/stock_decrease_log.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | type StockDecreaseLog struct { 4 | Id int64 `json:"id"` 5 | OrderId int64 `json:"orderId"` 6 | ProductRefer int64 `json:"productRefer"` 7 | } 8 | -------------------------------------------------------------------------------- /order-svc/pkg/models/order.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | type Order struct { 4 | Id int64 `json:"id" gorm:"primaryKey"` 5 | Price int64 `json:"price"` 6 | ProductId int64 `json:"product_id"` 7 | UserId int64 `json:"user_id"` 8 | } 9 | -------------------------------------------------------------------------------- /product-svc/pkg/models/product.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | type Product struct { 4 | Id int64 `json:"id"` 5 | Name string `json:"name"` 6 | Stock int64 `json:"stock"` 7 | Price int64 `json:"price"` 8 | StockDecreaseLogs StockDecreaseLog `gorm:"foreignKey:ProductRefer"` 9 | } 10 | -------------------------------------------------------------------------------- /auth-svc/pkg/models/auth.go: -------------------------------------------------------------------------------- 1 | package models 2 | 3 | type User struct { 4 | Id int64 `json:"id" gorm:"primaryKey"` 5 | Email string `json:"email" gorm:"unique"` 6 | Password string `json:"password"` 7 | } 8 | 9 | type Admin struct { 10 | Id int64 `json:"id" gorm:"primaryKey"` 11 | Email string `json:"email" gorm:"unique"` 12 | Password string `json:"password"` 13 | } 14 | -------------------------------------------------------------------------------- /auth-svc/pkg/utils/hash.go: -------------------------------------------------------------------------------- 1 | package utils 2 | 3 | import "golang.org/x/crypto/bcrypt" 4 | 5 | func HashPassword(password string) string { 6 | bytes, _ := bcrypt.GenerateFromPassword([]byte(password), 5) 7 | 8 | return string(bytes) 9 | } 10 | 11 | func CheckPasswordHash(password string, hash string) bool { 12 | err := bcrypt.CompareHashAndPassword([]byte(hash), []byte(password)) 13 | return err == nil 14 | } 15 | -------------------------------------------------------------------------------- /order-svc/pkg/pb/order.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package order; 4 | 5 | option go_package="./pkg/pb"; 6 | 7 | service OrderService{ 8 | rpc CreateOrder(CreateOrderRequest) returns (CreateOrderResponse); 9 | } 10 | 11 | message CreateOrderRequest{ 12 | int64 productId = 1; 13 | int64 quantity = 2; 14 | int64 userId = 3; 15 | } 16 | 17 | message CreateOrderResponse{ 18 | int64 status = 1; 19 | string error = 2; 20 | int64 id = 3; 21 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Microservices application written in Go 2 | This is a simple application written it Go to help understand how to build microservices. It uses HTTP for communication between client and the API Gateway, and gRPC for communication between services. 3 | ![alt text](/diagram.drawio.png) 4 | 5 | 6 | ## Create DB 7 | ```shell 8 | psql postgres 9 | CREATE DATABASE auth_svc; 10 | CREATE DATABASE order_svc; 11 | CREATE DATABASE product_svc; 12 | \l 13 | \q 14 | ``` -------------------------------------------------------------------------------- /order-svc/pkg/db/db.go: -------------------------------------------------------------------------------- 1 | package db 2 | 3 | import ( 4 | "github.com/amalmadhu06/go-grpc-microservices/order-svc/pkg/models" 5 | "gorm.io/driver/postgres" 6 | "gorm.io/gorm" 7 | "log" 8 | ) 9 | 10 | type Handler struct { 11 | DB *gorm.DB 12 | } 13 | 14 | func Init(url string) Handler { 15 | db, err := gorm.Open(postgres.Open(url), &gorm.Config{}) 16 | 17 | if err != nil { 18 | log.Fatalln(err) 19 | } 20 | 21 | db.AutoMigrate(&models.Order{}) 22 | 23 | return Handler{db} 24 | } 25 | -------------------------------------------------------------------------------- /api-gateway/pkg/product/routes/find_all.go: -------------------------------------------------------------------------------- 1 | package routes 2 | 3 | import ( 4 | "context" 5 | "github.com/amalmadhu06/go-grpc-microservices/api-gateway/pkg/product/pb" 6 | "github.com/gin-gonic/gin" 7 | "net/http" 8 | ) 9 | 10 | func FindAll(ctx *gin.Context, c pb.ProductServiceClient) { 11 | res, err := c.FindAll(context.Background(), &pb.FindAllRequest{}) 12 | if err != nil { 13 | ctx.AbortWithError(http.StatusBadGateway, err) 14 | return 15 | } 16 | ctx.JSON(http.StatusOK, &res) 17 | } 18 | -------------------------------------------------------------------------------- /product-svc/pkg/db/db.go: -------------------------------------------------------------------------------- 1 | package db 2 | 3 | import ( 4 | "github.com/amalmadhu06/go-grpc-microservices/product-svc/pkg/models" 5 | "gorm.io/driver/postgres" 6 | "gorm.io/gorm" 7 | "log" 8 | ) 9 | 10 | type Handler struct { 11 | DB *gorm.DB 12 | } 13 | 14 | func Init(url string) Handler { 15 | db, err := gorm.Open(postgres.Open(url), &gorm.Config{}) 16 | 17 | if err != nil { 18 | log.Fatalln(err) 19 | } 20 | 21 | db.AutoMigrate(&models.Product{}) 22 | db.AutoMigrate(&models.StockDecreaseLog{}) 23 | 24 | return Handler{db} 25 | } 26 | -------------------------------------------------------------------------------- /product-svc/pkg/config/config.go: -------------------------------------------------------------------------------- 1 | package config 2 | 3 | import "github.com/spf13/viper" 4 | 5 | type Config struct { 6 | Port string `mapstructure:"PORT"` 7 | DBUrl string `mapstructure:"DB_URL"` 8 | } 9 | 10 | func LoadConfig() (config Config, err error) { 11 | viper.AddConfigPath("./pkg/config/envs") 12 | viper.SetConfigName("dev") 13 | viper.SetConfigType("env") 14 | 15 | viper.AutomaticEnv() 16 | 17 | err = viper.ReadInConfig() 18 | 19 | if err != nil { 20 | return 21 | } 22 | 23 | err = viper.Unmarshal(&config) 24 | 25 | return 26 | } 27 | -------------------------------------------------------------------------------- /api-gateway/Makefile: -------------------------------------------------------------------------------- 1 | proto: 2 | # proto target compiles the protocol buffer files for authentication, order, and product packages. 3 | # It uses the 'protoc' command to generate gRPC code from the .proto files. 4 | # The generated code will be placed in the same directory as the .proto files. 5 | # Compiling auth.proto 6 | proto: 7 | protoc --go_out=. --go-grpc_out=. pkg/auth/pb/*.proto 8 | protoc --go_out=. --go-grpc_out=. pkg/order/pb/*.proto 9 | protoc --go_out=. --go-grpc_out=. pkg/product/pb/*.proto 10 | 11 | server: 12 | # server target runs the main.go file to start the server. 13 | # Starting the server 14 | go run cmd/main.go -------------------------------------------------------------------------------- /order-svc/pkg/config/config.go: -------------------------------------------------------------------------------- 1 | package config 2 | 3 | import "github.com/spf13/viper" 4 | 5 | type Config struct { 6 | Port string `mapstructure:"PORT"` 7 | DBUrl string `mapstructure:"DB_URL"` 8 | ProductSvcUrl string `mapstructure:"PRODUCT_SVC_URL"` 9 | } 10 | 11 | func LoadConfig() (config Config, err error) { 12 | viper.AddConfigPath("./pkg/config/envs") 13 | viper.SetConfigName("dev") 14 | viper.SetConfigType("env") 15 | 16 | viper.AutomaticEnv() 17 | 18 | err = viper.ReadInConfig() 19 | 20 | if err != nil { 21 | return 22 | } 23 | 24 | err = viper.Unmarshal(&config) 25 | 26 | return 27 | } 28 | -------------------------------------------------------------------------------- /auth-svc/Dockerfile: -------------------------------------------------------------------------------- 1 | # base image : specify the enviorment 2 | FROM golang:1.19-alpine AS build 3 | # working directory 4 | WORKDIR /app 5 | # copy go.mod and go.sum to working directory 6 | COPY go.mod ./ 7 | COPY go.sum ./ 8 | # download dependencies 9 | RUN go mod download 10 | # copy rest of the files to working directory 11 | COPY . . 12 | # build the application 13 | RUN go build -o ./out/dist ./cmd 14 | 15 | #use a smaller base image for final image 16 | FROM alpine:3.14 17 | #copy executable from build stage 18 | COPY --from=build /app/out/dist /app/dist 19 | #set working directory 20 | WORKDIR /app 21 | #set entrypoint for the application 22 | CMD ["/app/dist"] -------------------------------------------------------------------------------- /order-svc/Dockerfile: -------------------------------------------------------------------------------- 1 | # base image : specify the enviorment 2 | FROM golang:1.19-alpine AS build 3 | # working directory 4 | WORKDIR /app 5 | # copy go.mod and go.sum to working directory 6 | COPY go.mod ./ 7 | COPY go.sum ./ 8 | # download dependencies 9 | RUN go mod download 10 | # copy rest of the files to working directory 11 | COPY . . 12 | # build the application 13 | RUN go build -o ./out/dist ./cmd 14 | 15 | #use a smaller base image for final image 16 | FROM alpine:3.14 17 | #copy executable from build stage 18 | COPY --from=build /app/out/dist /app/dist 19 | #set working directory 20 | WORKDIR /app 21 | #set entrypoint for the application 22 | CMD ["/app/dist"] -------------------------------------------------------------------------------- /api-gateway/Dockerfile: -------------------------------------------------------------------------------- 1 | # base image : specify the enviorment 2 | FROM golang:1.19-alpine AS build 3 | # working directory 4 | WORKDIR /app 5 | # copy go.mod and go.sum to working directory 6 | COPY go.mod ./ 7 | COPY go.sum ./ 8 | # download dependencies 9 | RUN go mod download 10 | # copy rest of the files to working directory 11 | COPY . . 12 | # build the application 13 | RUN go build -o ./out/dist ./cmd 14 | 15 | #use a smaller base image for final image 16 | FROM alpine:3.14 17 | #copy executable from build stage 18 | COPY --from=build /app/out/dist /app/dist 19 | #set working directory 20 | WORKDIR /app 21 | #set entrypoint for the application 22 | CMD ["/app/dist"] -------------------------------------------------------------------------------- /product-svc/Dockerfile: -------------------------------------------------------------------------------- 1 | # base image : specify the enviorment 2 | FROM golang:1.19-alpine AS build 3 | # working directory 4 | WORKDIR /app 5 | # copy go.mod and go.sum to working directory 6 | COPY go.mod ./ 7 | COPY go.sum ./ 8 | # download dependencies 9 | RUN go mod download 10 | # copy rest of the files to working directory 11 | COPY . . 12 | # build the application 13 | RUN go build -o ./out/dist ./cmd 14 | 15 | #use a smaller base image for final image 16 | FROM alpine:3.14 17 | #copy executable from build stage 18 | COPY --from=build /app/out/dist /app/dist 19 | #set working directory 20 | WORKDIR /app 21 | #set entrypoint for the application 22 | CMD ["/app/dist"] -------------------------------------------------------------------------------- /api-gateway/pkg/product/routes/find_one.go: -------------------------------------------------------------------------------- 1 | package routes 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | "github.com/amalmadhu06/go-grpc-microservices/api-gateway/pkg/product/pb" 7 | "net/http" 8 | "strconv" 9 | 10 | "github.com/gin-gonic/gin" 11 | ) 12 | 13 | func FineOne(ctx *gin.Context, c pb.ProductServiceClient) { 14 | fmt.Println("API Gateway : FindOne") 15 | id, _ := strconv.ParseInt(ctx.Param("id"), 10, 32) 16 | 17 | res, err := c.FindOne(context.Background(), &pb.FindOneRequest{ 18 | Id: int64(id), 19 | }) 20 | 21 | if err != nil { 22 | ctx.AbortWithError(http.StatusBadGateway, err) 23 | return 24 | } 25 | 26 | ctx.JSON(http.StatusOK, &res) 27 | } 28 | -------------------------------------------------------------------------------- /api-gateway/pkg/auth/client.go: -------------------------------------------------------------------------------- 1 | package auth 2 | 3 | import ( 4 | "fmt" 5 | "github.com/amalmadhu06/go-grpc-microservices/api-gateway/pkg/auth/pb" 6 | "github.com/amalmadhu06/go-grpc-microservices/api-gateway/pkg/config" 7 | "google.golang.org/grpc" 8 | ) 9 | 10 | type ServiceClient struct { 11 | Client pb.AuthServiceClient 12 | } 13 | 14 | func InitServiceClient(c *config.Config) pb.AuthServiceClient { 15 | fmt.Println("API Gateway : InitServiceClient") 16 | // using WithInsecure() because no SSL running 17 | cc, err := grpc.Dial(c.AuthSuvUrl, grpc.WithInsecure()) 18 | 19 | if err != nil { 20 | fmt.Println("Could not connect:", err) 21 | } 22 | return pb.NewAuthServiceClient(cc) 23 | } 24 | -------------------------------------------------------------------------------- /api-gateway/pkg/product/client.go: -------------------------------------------------------------------------------- 1 | package product 2 | 3 | import ( 4 | "fmt" 5 | "github.com/amalmadhu06/go-grpc-microservices/api-gateway/pkg/config" 6 | "github.com/amalmadhu06/go-grpc-microservices/api-gateway/pkg/product/pb" 7 | 8 | "google.golang.org/grpc" 9 | ) 10 | 11 | type ServiceClient struct { 12 | Client pb.ProductServiceClient 13 | } 14 | 15 | func InitServiceClient(c *config.Config) pb.ProductServiceClient { 16 | fmt.Println("API Gateway : InitServiceClient") 17 | // using WithInsecure() because no SSL running 18 | cc, err := grpc.Dial(c.ProductSuvUrl, grpc.WithInsecure()) 19 | 20 | if err != nil { 21 | fmt.Println("Could not connect:", err) 22 | } 23 | 24 | return pb.NewProductServiceClient(cc) 25 | } 26 | -------------------------------------------------------------------------------- /api-gateway/pkg/order/client.go: -------------------------------------------------------------------------------- 1 | package order 2 | 3 | import ( 4 | "fmt" 5 | "github.com/amalmadhu06/go-grpc-microservices/api-gateway/pkg/config" 6 | "github.com/amalmadhu06/go-grpc-microservices/api-gateway/pkg/order/pb" 7 | "google.golang.org/grpc" 8 | ) 9 | 10 | type ServiceClient struct { 11 | Client pb.OrderServiceClient 12 | } 13 | 14 | func InitServiceClient(c *config.Config) pb.OrderServiceClient { 15 | fmt.Println("API Gateway : InitServiceClient") 16 | // using WithInsecure() because of no SSL running 17 | cc, err := grpc.Dial(c.OrderSuvUrl, grpc.WithInsecure()) // cc is a pointer to client connection 18 | 19 | if err != nil { 20 | fmt.Println("Could not connect : ", err) 21 | } 22 | return pb.NewOrderServiceClient(cc) 23 | } 24 | -------------------------------------------------------------------------------- /auth-svc/pkg/config/config.go: -------------------------------------------------------------------------------- 1 | package config 2 | 3 | import "github.com/spf13/viper" 4 | 5 | type Config struct { 6 | Port string `mapstructure:"PORT"` 7 | DBUrl string `mapstructure:"DB_URL"` 8 | JWTSecretKey string `mapstructure:"JWT_SECRET_KEY"` 9 | AdminEmail string `mapstructure:"ADMIN_EMAIL"` 10 | AdminPassword string `mapstructure:"ADMIN_PASSWORD"` 11 | } 12 | 13 | func LoadConfig() (Config, error) { 14 | var config Config 15 | viper.AddConfigPath("./") 16 | viper.SetConfigFile(".env") 17 | //viper.SetConfigType("env") 18 | 19 | viper.AutomaticEnv() 20 | 21 | if err := viper.ReadInConfig(); err != nil { 22 | return Config{}, err 23 | } 24 | err := viper.Unmarshal(&config) 25 | return config, err 26 | } 27 | -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: Run Unit Test 2 | 3 | on: 4 | push: 5 | branches: [main] 6 | pull_request: 7 | branches: [main] 8 | 9 | jobs: 10 | test: 11 | name: Unit Test 12 | runs-on: ubuntu-latest 13 | steps: 14 | - uses: actions/checkout@v3 15 | 16 | - name: Set up Go 17 | uses: actions/setup-go@v4 18 | with: 19 | go-version: '1.19' 20 | 21 | - name: Test API Gateway 22 | run: cd api-gateway && go test ./... 23 | 24 | - name: Test Auth Service 25 | run: cd auth-svc && go test ./... 26 | 27 | - name: Test Product Service 28 | run: cd product-svc && go test ./... 29 | 30 | - name: Test Order Service 31 | run: cd order-svc && go test ./... 32 | -------------------------------------------------------------------------------- /api-gateway/cmd/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "github.com/amalmadhu06/go-grpc-microservices/api-gateway/pkg/auth" 6 | "github.com/amalmadhu06/go-grpc-microservices/api-gateway/pkg/config" 7 | "github.com/amalmadhu06/go-grpc-microservices/api-gateway/pkg/order" 8 | "github.com/amalmadhu06/go-grpc-microservices/api-gateway/pkg/product" 9 | "github.com/gin-gonic/gin" 10 | "log" 11 | ) 12 | 13 | func main() { 14 | fmt.Println("starting API Gateway") 15 | c, err := config.LoadConfig() 16 | 17 | if err != nil { 18 | log.Fatalln("Failed at config", err) 19 | } 20 | 21 | r := gin.Default() 22 | 23 | authSvc := *auth.RegisterRoutes(r, &c) 24 | product.RegisterRoutes(r, &c, &authSvc) 25 | order.RegisterRoutes(r, &c, &authSvc) 26 | 27 | r.Run(c.Port) 28 | } 29 | -------------------------------------------------------------------------------- /api-gateway/pkg/auth/routes/login.go: -------------------------------------------------------------------------------- 1 | package routes 2 | 3 | import ( 4 | "context" 5 | "github.com/amalmadhu06/go-grpc-microservices/api-gateway/pkg/auth/pb" 6 | "github.com/gin-gonic/gin" 7 | "net/http" 8 | ) 9 | 10 | type LoginRequestBody struct { 11 | Email string `json:"email"` 12 | Password string `json:"password"` 13 | } 14 | 15 | func Login(ctx *gin.Context, c pb.AuthServiceClient) { 16 | b := LoginRequestBody{} 17 | 18 | if err := ctx.BindJSON(&b); err != nil { 19 | ctx.AbortWithError(http.StatusBadRequest, err) 20 | return 21 | } 22 | 23 | res, err := c.Login(context.Background(), &pb.LoginRequest{ 24 | Email: b.Email, 25 | Password: b.Password, 26 | }) 27 | 28 | if err != nil { 29 | ctx.AbortWithError(http.StatusBadGateway, err) 30 | return 31 | } 32 | ctx.JSON(http.StatusCreated, &res) 33 | } 34 | -------------------------------------------------------------------------------- /api-gateway/pkg/auth/routes/admin_login.go: -------------------------------------------------------------------------------- 1 | package routes 2 | 3 | import ( 4 | "context" 5 | "github.com/amalmadhu06/go-grpc-microservices/api-gateway/pkg/auth/pb" 6 | "github.com/gin-gonic/gin" 7 | "net/http" 8 | ) 9 | 10 | type AdminLoginRequestBody struct { 11 | Email string `json:"email"` 12 | Password string `json:"password"` 13 | } 14 | 15 | func AdminLogin(ctx *gin.Context, c pb.AuthServiceClient) { 16 | b := AdminLoginRequestBody{} 17 | 18 | if err := ctx.BindJSON(&b); err != nil { 19 | ctx.AbortWithError(http.StatusBadRequest, err) 20 | return 21 | } 22 | 23 | res, err := c.AdminLogin(context.Background(), &pb.LoginRequest{ 24 | Email: b.Email, 25 | Password: b.Password, 26 | }) 27 | 28 | if err != nil { 29 | ctx.AbortWithError(http.StatusBadGateway, err) 30 | return 31 | } 32 | ctx.JSON(http.StatusCreated, &res) 33 | } 34 | -------------------------------------------------------------------------------- /api-gateway/pkg/auth/routes/register.go: -------------------------------------------------------------------------------- 1 | package routes 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/amalmadhu06/go-grpc-microservices/api-gateway/pkg/auth/pb" 7 | "github.com/gin-gonic/gin" 8 | "net/http" 9 | ) 10 | 11 | type RegisterRequestBody struct { 12 | Email string `json:"email"` 13 | Password string `json:"password"` 14 | } 15 | 16 | func Register(ctx *gin.Context, c pb.AuthServiceClient) { 17 | body := RegisterRequestBody{} 18 | 19 | if err := ctx.BindJSON(&body); err != nil { 20 | ctx.AbortWithError(http.StatusBadRequest, err) 21 | return 22 | } 23 | res, err := c.Register(context.Background(), &pb.RegisterRequest{ 24 | Email: body.Email, 25 | Password: body.Password, 26 | }) 27 | 28 | if err != nil { 29 | ctx.AbortWithError(http.StatusBadGateway, err) 30 | return 31 | } 32 | ctx.JSON(int(res.Status), res) 33 | } 34 | -------------------------------------------------------------------------------- /api-gateway/pkg/order/routes.go: -------------------------------------------------------------------------------- 1 | package order 2 | 3 | import ( 4 | "fmt" 5 | "github.com/amalmadhu06/go-grpc-microservices/api-gateway/pkg/auth" 6 | "github.com/amalmadhu06/go-grpc-microservices/api-gateway/pkg/config" 7 | "github.com/amalmadhu06/go-grpc-microservices/api-gateway/pkg/order/routes" 8 | "github.com/gin-gonic/gin" 9 | ) 10 | 11 | func RegisterRoutes(r *gin.Engine, c *config.Config, authSvc *auth.ServiceClient) { 12 | fmt.Println("API Gateway : RegisterRoutes") 13 | a := auth.InitAuthMiddleware(authSvc) 14 | 15 | svc := &ServiceClient{ 16 | Client: InitServiceClient(c), 17 | } 18 | routes := r.Group("order") 19 | routes.Use(a.UserAuth) 20 | routes.POST("/", svc.CreateOrder) 21 | } 22 | 23 | func (svc *ServiceClient) CreateOrder(ctx *gin.Context) { 24 | fmt.Println("API Gateway : CreateOrder") 25 | routes.CreateOrder(ctx, svc.Client) 26 | } 27 | -------------------------------------------------------------------------------- /auth-svc/pkg/pb/auth.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package auth; 4 | 5 | option go_package= "./pkg/pb"; 6 | 7 | service AuthService{ 8 | rpc Register(RegisterRequest) returns (RegisterResponse); 9 | rpc Login(LoginRequest) returns (LoginResponse); 10 | rpc Validate(ValidateRequest) returns (ValidateResponse); 11 | 12 | rpc AdminLogin(LoginRequest) returns (LoginResponse); 13 | } 14 | 15 | message RegisterRequest{ 16 | string email = 1; 17 | string password = 2; 18 | } 19 | 20 | message RegisterResponse{ 21 | int64 status = 1; 22 | string error = 2; 23 | } 24 | 25 | message LoginRequest{ 26 | string email = 1; 27 | string password = 2; 28 | } 29 | 30 | message LoginResponse{ 31 | int64 status = 1; 32 | string error = 2; 33 | string token = 3; 34 | } 35 | 36 | message ValidateRequest{ 37 | string token = 1; 38 | string role = 2; 39 | } 40 | 41 | message ValidateResponse{ 42 | int64 status = 1; 43 | string error = 2; 44 | int64 userId = 3; 45 | } -------------------------------------------------------------------------------- /api-gateway/pkg/auth/routes.go: -------------------------------------------------------------------------------- 1 | package auth 2 | 3 | import ( 4 | "fmt" 5 | "github.com/amalmadhu06/go-grpc-microservices/api-gateway/pkg/auth/routes" 6 | "github.com/amalmadhu06/go-grpc-microservices/api-gateway/pkg/config" 7 | "github.com/gin-gonic/gin" 8 | ) 9 | 10 | func RegisterRoutes(r *gin.Engine, c *config.Config) *ServiceClient { 11 | fmt.Println("API Gateway : Register Routes") 12 | svc := &ServiceClient{ 13 | Client: InitServiceClient(c), 14 | } 15 | user := r.Group("/auth") 16 | user.POST("/register", svc.Register) 17 | user.POST("/login", svc.Login) 18 | 19 | admin := r.Group("/admin") 20 | admin.POST("/login", svc.AdminLogin) 21 | return svc 22 | } 23 | 24 | func (svc *ServiceClient) Register(ctx *gin.Context) { 25 | routes.Register(ctx, svc.Client) 26 | } 27 | func (svc *ServiceClient) Login(ctx *gin.Context) { 28 | routes.Login(ctx, svc.Client) 29 | } 30 | 31 | func (svc *ServiceClient) AdminLogin(ctx *gin.Context) { 32 | routes.AdminLogin(ctx, svc.Client) 33 | } 34 | -------------------------------------------------------------------------------- /api-gateway/pkg/order/routes/create_order.go: -------------------------------------------------------------------------------- 1 | package routes 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | "github.com/amalmadhu06/go-grpc-microservices/api-gateway/pkg/order/pb" 7 | "github.com/gin-gonic/gin" 8 | "net/http" 9 | ) 10 | 11 | type CreateOrderRequestBody struct { 12 | ProductId int64 `json:"productId"` 13 | Quantity int64 `json:"quantity"` 14 | } 15 | 16 | func CreateOrder(ctx *gin.Context, c pb.OrderServiceClient) { 17 | fmt.Println("API Gateway : CreateOrder") 18 | body := CreateOrderRequestBody{} 19 | 20 | if err := ctx.BindJSON(&body); err != nil { 21 | ctx.AbortWithError(http.StatusBadRequest, err) 22 | return 23 | } 24 | 25 | userId, _ := ctx.Get("userId") 26 | 27 | res, err := c.CreateOrder(context.Background(), &pb.CreateOrderRequest{ 28 | ProductID: body.ProductId, 29 | Quantity: body.Quantity, 30 | UserId: userId.(int64), 31 | }) 32 | 33 | if err != nil { 34 | ctx.AbortWithError(http.StatusBadGateway, err) 35 | return 36 | } 37 | ctx.JSON(http.StatusCreated, &res) 38 | } 39 | -------------------------------------------------------------------------------- /product-svc/cmd/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "github.com/amalmadhu06/go-grpc-microservices/product-svc/pkg/config" 6 | "github.com/amalmadhu06/go-grpc-microservices/product-svc/pkg/db" 7 | "github.com/amalmadhu06/go-grpc-microservices/product-svc/pkg/pb" 8 | "github.com/amalmadhu06/go-grpc-microservices/product-svc/pkg/services" 9 | "google.golang.org/grpc" 10 | "log" 11 | "net" 12 | ) 13 | 14 | func main() { 15 | c, err := config.LoadConfig() 16 | 17 | if err != nil { 18 | log.Fatalln("Failed at config", err) 19 | } 20 | 21 | h := db.Init(c.DBUrl) 22 | 23 | lis, err := net.Listen("tcp", c.Port) 24 | 25 | if err != nil { 26 | log.Fatalln("Failed to listing:", err) 27 | } 28 | 29 | fmt.Println("Product Svc on", c.Port) 30 | 31 | s := services.Server{ 32 | H: h, 33 | } 34 | 35 | grpcServer := grpc.NewServer() 36 | 37 | pb.RegisterProductServiceServer(grpcServer, &s) 38 | 39 | if err := grpcServer.Serve(lis); err != nil { 40 | log.Fatalln("Failed to serve:", err) 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /auth-svc/pkg/services/admin.go: -------------------------------------------------------------------------------- 1 | package services 2 | 3 | import ( 4 | "context" 5 | "github.com/amalmadhu06/go-grpc-microservices/auth-svc/pkg/models" 6 | "github.com/amalmadhu06/go-grpc-microservices/auth-svc/pkg/pb" 7 | "github.com/amalmadhu06/go-grpc-microservices/auth-svc/pkg/utils" 8 | "net/http" 9 | ) 10 | 11 | func (s *Server) AdminLogin(ctx context.Context, req *pb.LoginRequest) (*pb.LoginResponse, error) { 12 | var admin models.Admin 13 | 14 | if result := s.H.DB.Where(&models.Admin{Email: req.Email}).First(&admin); result.Error != nil { 15 | return &pb.LoginResponse{ 16 | Status: http.StatusNotFound, 17 | Error: "admin not found", 18 | }, nil 19 | } 20 | 21 | if match := utils.CheckPasswordHash(req.Password, admin.Password); !match { 22 | return &pb.LoginResponse{ 23 | Status: http.StatusNotFound, 24 | Error: "invalid credentials ", 25 | }, nil 26 | } 27 | 28 | token, _ := s.Jwt.GenerateToken(models.User(admin), "admin") 29 | return &pb.LoginResponse{ 30 | Status: http.StatusOK, 31 | Token: token, 32 | }, nil 33 | 34 | } 35 | -------------------------------------------------------------------------------- /order-svc/pkg/pb/product.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package product; 4 | 5 | option go_package = "./pkg/pb"; 6 | 7 | service ProductService{ 8 | rpc CreateProduct(CreateProductRequest) returns (CreateProductResponse); 9 | rpc FindOne(FindOneRequest) returns (FindOneResponse); 10 | rpc DecreaseStock(DecreaseStockRequest) returns (DecreaseStockResponse); 11 | } 12 | 13 | message CreateProductRequest{ 14 | string name = 1; 15 | int64 stock = 2; 16 | int64 price = 3; 17 | } 18 | message CreateProductResponse{ 19 | int64 status = 1; 20 | string error = 2; 21 | int64 id = 3; 22 | } 23 | message FindOneData { 24 | int64 id = 1; 25 | string name = 2; 26 | int64 stock = 3; 27 | int64 price = 4; 28 | } 29 | 30 | 31 | message FindOneRequest{ 32 | int64 id = 1; 33 | } 34 | message FindOneResponse{ 35 | int64 status = 1; 36 | string error = 2; 37 | FindOneData data = 3; 38 | } 39 | 40 | message DecreaseStockRequest{ 41 | int64 id = 1; 42 | int64 orderId = 2; 43 | } 44 | message DecreaseStockResponse{ 45 | int64 status = 1; 46 | string error = 2; 47 | } 48 | 49 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | run-all: 2 | cd api-gateway && start /b make server 3 | cd auth-svc && start /b make server 4 | cd order-svc && start /b make server 5 | cd product-svc && start /b make server 6 | view-ports: 7 | netstat -ano | findstr :3000 8 | netstat -ano | findstr :50051 9 | netstat -ano | findstr :50052 10 | netstat -ano | findstr :50053 11 | #replace process id number with results from make ports command 12 | stop: 13 | taskkill /PID 13988 /F 14 | taskkill /PID 9160 /F 15 | taskkill /PID 8868 /F 16 | taskkill /PID 6864 /F 17 | docker-build: 18 | cd api-gateway && docker build -t amalmadhu06/ecom-api-gateway . 19 | cd auth-svc && docker build -t amalmadhu06/ecom-auth-svc . 20 | cd order-svc && docker build -t amalmadhu06/ecom-order-svc . 21 | cd product-svc && docker build -t amalmadhu06/ecom-product-svc . 22 | 23 | docker-push: 24 | cd api-gateway && docker push amalmadhu06/ecom-api-gateway 25 | cd auth-svc && docker push amalmadhu06/ecom-auth-svc 26 | cd order-svc && docker push amalmadhu06/ecom-order-svc 27 | cd product-svc && docker push amalmadhu06/ecom-product-svc 28 | run: 29 | sudo docker compose up 30 | -------------------------------------------------------------------------------- /order-svc/pkg/client/product_client.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | "github.com/amalmadhu06/go-grpc-microservices/order-svc/pkg/pb" 7 | "google.golang.org/grpc" 8 | ) 9 | 10 | type ProductServiceClient struct { 11 | Client pb.ProductServiceClient 12 | } 13 | 14 | func InitProductServiceClient(url string) ProductServiceClient { 15 | cc, err := grpc.Dial(url, grpc.WithInsecure()) 16 | 17 | if err != nil { 18 | fmt.Println("Could not connect:", err) 19 | } 20 | 21 | c := ProductServiceClient{ 22 | Client: pb.NewProductServiceClient(cc), 23 | } 24 | 25 | return c 26 | } 27 | 28 | func (c *ProductServiceClient) FindOne(productId int64) (*pb.FindOneResponse, error) { 29 | req := &pb.FindOneRequest{ 30 | Id: productId, 31 | } 32 | 33 | return c.Client.FindOne(context.Background(), req) 34 | } 35 | 36 | func (c *ProductServiceClient) DecreaseStock(productId int64, orderId int64) (*pb.DecreaseStockResponse, error) { 37 | req := &pb.DecreaseStockRequest{ 38 | Id: productId, 39 | OrderId: orderId, 40 | } 41 | 42 | return c.Client.DecreaseStock(context.Background(), req) 43 | } 44 | -------------------------------------------------------------------------------- /api-gateway/pkg/product/routes/create_product.go: -------------------------------------------------------------------------------- 1 | package routes 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | "github.com/amalmadhu06/go-grpc-microservices/api-gateway/pkg/product/pb" 7 | "github.com/gin-gonic/gin" 8 | "net/http" 9 | ) 10 | 11 | type CreateProductRequestBody struct { 12 | Name string `json:"name"` 13 | Stock int64 `json:"stock"` 14 | Price int64 `json:"price"` 15 | } 16 | 17 | func CreateProduct(ctx *gin.Context, c pb.ProductServiceClient) { 18 | fmt.Println("API Gateway : CreateProduct") 19 | var body CreateProductRequestBody 20 | if err := ctx.BindJSON(&body); err != nil { 21 | ctx.AbortWithError(http.StatusBadRequest, err) 22 | return 23 | } 24 | fmt.Println("api gateway") 25 | fmt.Println("body.stock : ", body.Stock) 26 | fmt.Println(body) 27 | fmt.Println("-----------------") 28 | res, err := c.CreateProduct(context.Background(), &pb.CreateProductRequest{ 29 | Name: body.Name, 30 | Stock: body.Stock, 31 | Price: body.Price, 32 | }) 33 | 34 | if err != nil { 35 | ctx.AbortWithError(http.StatusBadGateway, err) 36 | return 37 | } 38 | 39 | ctx.JSON(http.StatusCreated, &res) 40 | } 41 | -------------------------------------------------------------------------------- /api-gateway/pkg/order/pb/order.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package order; 4 | 5 | option go_package = "./pkg/order/pb"; 6 | 7 | // OrderService is a service that handles order-related operations. 8 | service OrderService{ 9 | 10 | // CreateOrder is an RPC method that allows the creation of a new order. 11 | // It takes a CreateOrderRequest message as input, containing the product ID, 12 | // quantity, and user ID associated with the order. The server will respond with 13 | // a CreateOrderResponse message, which includes a status indicating the result 14 | // of the order creation, an error message if applicable, and the ID of the newly 15 | // created order. 16 | rpc CreateOrder(CreateOrderRequest) returns (CreateOrderResponse) {} 17 | } 18 | 19 | // CreateOrderRequest is a message that carries the necessary data to create an order. 20 | message CreateOrderRequest{ 21 | int64 productID = 1; 22 | int64 quantity = 2; 23 | int64 userId = 3; 24 | } 25 | 26 | // CreateOrderResponse is a message that carries the response after attempting to create an order. 27 | message CreateOrderResponse{ 28 | int64 status = 1; 29 | string error = 2; 30 | int64 id = 3; 31 | } -------------------------------------------------------------------------------- /auth-svc/pkg/db/db.go: -------------------------------------------------------------------------------- 1 | package db 2 | 3 | import ( 4 | "github.com/amalmadhu06/go-grpc-microservices/auth-svc/pkg/config" 5 | "github.com/amalmadhu06/go-grpc-microservices/auth-svc/pkg/models" 6 | "github.com/amalmadhu06/go-grpc-microservices/auth-svc/pkg/utils" 7 | "gorm.io/driver/postgres" 8 | "gorm.io/gorm" 9 | "log" 10 | ) 11 | 12 | type Handler struct { 13 | DB *gorm.DB 14 | } 15 | 16 | func Init(config config.Config) Handler { 17 | db, err := gorm.Open(postgres.Open(config.DBUrl), &gorm.Config{}) 18 | 19 | if err != nil { 20 | log.Fatalln(err) 21 | } 22 | db.AutoMigrate( 23 | &models.User{}, 24 | &models.Admin{}, 25 | ) 26 | // check if admin already exists in db 27 | var count int 28 | sql := `SELECT COUNT(*) FROM admins WHERE email = $1` 29 | if err := db.Raw(sql, config.AdminEmail).Scan(&count).Error; err != nil { 30 | log.Fatalln(err) 31 | } 32 | if count == 0 { 33 | // create admin in db using env variables 34 | sql := `INSERT INTO admins(email, password) VALUES ($1, $2)` 35 | if err := db.Exec(sql, config.AdminEmail, utils.HashPassword(config.AdminPassword)).Error; err != nil { 36 | log.Fatalln(err) 37 | } 38 | } 39 | return Handler{DB: db} 40 | 41 | } 42 | -------------------------------------------------------------------------------- /api-gateway/pkg/product/routes.go: -------------------------------------------------------------------------------- 1 | package product 2 | 3 | import ( 4 | "fmt" 5 | "github.com/amalmadhu06/go-grpc-microservices/api-gateway/pkg/auth" 6 | "github.com/amalmadhu06/go-grpc-microservices/api-gateway/pkg/config" 7 | "github.com/amalmadhu06/go-grpc-microservices/api-gateway/pkg/product/routes" 8 | "github.com/gin-gonic/gin" 9 | ) 10 | 11 | func RegisterRoutes(r *gin.Engine, c *config.Config, authSvc *auth.ServiceClient) { 12 | fmt.Println("API Gateway : RegisterRoutes") 13 | a := auth.InitAuthMiddleware(authSvc) 14 | 15 | svc := &ServiceClient{ 16 | Client: InitServiceClient(c), 17 | } 18 | 19 | route := r.Group("/product") 20 | route.GET("/:id", svc.FindOne) 21 | route.GET("/", svc.FindAll) 22 | 23 | route.Use(a.AdminAuth) 24 | route.POST("/", svc.CreateProduct) 25 | 26 | } 27 | 28 | func (svc *ServiceClient) FindOne(ctx *gin.Context) { 29 | fmt.Println("API Gateway : FindOne") 30 | routes.FineOne(ctx, svc.Client) 31 | } 32 | 33 | func (svc *ServiceClient) CreateProduct(ctx *gin.Context) { 34 | fmt.Println("API Gateway : CreateProduct called --> 1") 35 | routes.CreateProduct(ctx, svc.Client) 36 | } 37 | 38 | func (svc *ServiceClient) FindAll(ctx *gin.Context) { 39 | routes.FindAll(ctx, svc.Client) 40 | } 41 | -------------------------------------------------------------------------------- /auth-svc/cmd/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "github.com/amalmadhu06/go-grpc-microservices/auth-svc/pkg/config" 6 | "github.com/amalmadhu06/go-grpc-microservices/auth-svc/pkg/db" 7 | "github.com/amalmadhu06/go-grpc-microservices/auth-svc/pkg/pb" 8 | "github.com/amalmadhu06/go-grpc-microservices/auth-svc/pkg/services" 9 | "github.com/amalmadhu06/go-grpc-microservices/auth-svc/pkg/utils" 10 | 11 | "google.golang.org/grpc" 12 | "log" 13 | "net" 14 | ) 15 | 16 | func main() { 17 | c, err := config.LoadConfig() 18 | 19 | if err != nil { 20 | log.Fatalln("failed at config ", err) 21 | } 22 | 23 | fmt.Println(c.DBUrl) 24 | h := db.Init(c) 25 | 26 | jwt := utils.JWTWrapper{ 27 | SecretKey: c.JWTSecretKey, 28 | Issuer: "go-grpc-auth-svc", 29 | ExpirationHours: 24 * 365, 30 | } 31 | 32 | lis, err := net.Listen("tcp", c.Port) 33 | 34 | if err != nil { 35 | log.Fatalln("failed at listening : ", err) 36 | } 37 | fmt.Println("Auth svc on ", c.Port) 38 | s := services.Server{ 39 | H: h, 40 | Jwt: jwt, 41 | } 42 | 43 | grpcServer := grpc.NewServer() 44 | 45 | pb.RegisterAuthServiceServer(grpcServer, &s) 46 | 47 | if err := grpcServer.Serve(lis); err != nil { 48 | log.Fatalln("Failed to serve:", err) 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /order-svc/cmd/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "github.com/amalmadhu06/go-grpc-microservices/order-svc/pkg/client" 6 | "github.com/amalmadhu06/go-grpc-microservices/order-svc/pkg/config" 7 | "github.com/amalmadhu06/go-grpc-microservices/order-svc/pkg/db" 8 | "github.com/amalmadhu06/go-grpc-microservices/order-svc/pkg/pb" 9 | "github.com/amalmadhu06/go-grpc-microservices/order-svc/pkg/services" 10 | "google.golang.org/grpc" 11 | "log" 12 | "net" 13 | ) 14 | 15 | func main() { 16 | c, err := config.LoadConfig() 17 | 18 | if err != nil { 19 | log.Fatalln("Failed at config", err) 20 | } 21 | 22 | h := db.Init(c.DBUrl) 23 | 24 | lis, err := net.Listen("tcp", c.Port) 25 | 26 | if err != nil { 27 | log.Fatalln("Failed to listing:", err) 28 | } 29 | 30 | productSvc := client.InitProductServiceClient(c.ProductSvcUrl) 31 | 32 | if err != nil { 33 | log.Fatalln("Failed to listing:", err) 34 | } 35 | 36 | fmt.Println("Order Svc on", c.Port) 37 | 38 | s := services.Server{ 39 | H: h, 40 | ProductSvc: productSvc, 41 | } 42 | 43 | grpcServer := grpc.NewServer() 44 | 45 | pb.RegisterOrderServiceServer(grpcServer, &s) 46 | 47 | if err := grpcServer.Serve(lis); err != nil { 48 | log.Fatalln("Failed to serve:", err) 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /product-svc/pkg/pb/product.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package product; 4 | 5 | option go_package = "./pkg/pb"; 6 | 7 | service ProductService{ 8 | rpc CreateProduct(CreateProductRequest) returns (CreateProductResponse) ; 9 | rpc FindOne(FindOneRequest) returns (FindOneResponse) ; 10 | rpc FindAll(FindAllRequest) returns (FindAllResponse) ; 11 | rpc DecreaseStock(DecreaseStockRequest) returns (DecreaseStockResponse) ; 12 | } 13 | 14 | message CreateProductRequest{ 15 | string name = 1; 16 | int64 stock = 2; 17 | int64 price = 3; 18 | } 19 | message CreateProductResponse{ 20 | int64 status = 1; 21 | string error = 2; 22 | int64 id = 3; 23 | } 24 | 25 | message FindOneData{ 26 | int64 id = 1; 27 | string name = 2; 28 | int64 stock = 3; 29 | int64 price = 4; 30 | } 31 | 32 | message FindOneRequest{ 33 | int64 id = 1; 34 | } 35 | message FindOneResponse{ 36 | int64 status = 1; 37 | string error = 2; 38 | FindOneData data = 3; 39 | } 40 | 41 | 42 | //FindAllRequest 43 | message FindAllRequest{ 44 | } 45 | 46 | //FindAllResponse 47 | message FindAllResponse{ 48 | int64 status = 1; 49 | string error = 2; 50 | repeated FindOneData products = 3; 51 | } 52 | 53 | 54 | message DecreaseStockRequest{ 55 | int64 id = 1; 56 | int64 orderId = 2; 57 | } 58 | message DecreaseStockResponse{ 59 | int64 status = 1; 60 | string error = 2; 61 | } 62 | -------------------------------------------------------------------------------- /order-svc/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/amalmadhu06/go-grpc-microservices/order-svc 2 | 3 | go 1.19 4 | 5 | require ( 6 | github.com/spf13/viper v1.15.0 7 | google.golang.org/grpc v1.55.0 8 | google.golang.org/protobuf v1.30.0 9 | gorm.io/driver/postgres v1.5.0 10 | gorm.io/gorm v1.25.1 11 | ) 12 | 13 | require ( 14 | github.com/fsnotify/fsnotify v1.6.0 // indirect 15 | github.com/golang/protobuf v1.5.3 // indirect 16 | github.com/hashicorp/hcl v1.0.0 // indirect 17 | github.com/jackc/pgpassfile v1.0.0 // indirect 18 | github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect 19 | github.com/jackc/pgx/v5 v5.3.0 // indirect 20 | github.com/jinzhu/inflection v1.0.0 // indirect 21 | github.com/jinzhu/now v1.1.5 // indirect 22 | github.com/magiconair/properties v1.8.7 // indirect 23 | github.com/mitchellh/mapstructure v1.5.0 // indirect 24 | github.com/pelletier/go-toml/v2 v2.0.6 // indirect 25 | github.com/spf13/afero v1.9.3 // indirect 26 | github.com/spf13/cast v1.5.0 // indirect 27 | github.com/spf13/jwalterweatherman v1.1.0 // indirect 28 | github.com/spf13/pflag v1.0.5 // indirect 29 | github.com/subosito/gotenv v1.4.2 // indirect 30 | golang.org/x/crypto v0.6.0 // indirect 31 | golang.org/x/net v0.8.0 // indirect 32 | golang.org/x/sys v0.6.0 // indirect 33 | golang.org/x/text v0.8.0 // indirect 34 | google.golang.org/genproto v0.0.0-20230306155012-7f2fa6fef1f4 // indirect 35 | gopkg.in/ini.v1 v1.67.0 // indirect 36 | gopkg.in/yaml.v3 v3.0.1 // indirect 37 | ) 38 | -------------------------------------------------------------------------------- /product-svc/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/amalmadhu06/go-grpc-microservices/product-svc 2 | 3 | go 1.19 4 | 5 | require ( 6 | github.com/spf13/viper v1.15.0 7 | google.golang.org/grpc v1.55.0 8 | google.golang.org/protobuf v1.30.0 9 | gorm.io/driver/postgres v1.5.0 10 | gorm.io/gorm v1.25.1 11 | ) 12 | 13 | require ( 14 | github.com/fsnotify/fsnotify v1.6.0 // indirect 15 | github.com/golang/protobuf v1.5.3 // indirect 16 | github.com/hashicorp/hcl v1.0.0 // indirect 17 | github.com/jackc/pgpassfile v1.0.0 // indirect 18 | github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect 19 | github.com/jackc/pgx/v5 v5.3.0 // indirect 20 | github.com/jinzhu/inflection v1.0.0 // indirect 21 | github.com/jinzhu/now v1.1.5 // indirect 22 | github.com/magiconair/properties v1.8.7 // indirect 23 | github.com/mitchellh/mapstructure v1.5.0 // indirect 24 | github.com/pelletier/go-toml/v2 v2.0.6 // indirect 25 | github.com/spf13/afero v1.9.3 // indirect 26 | github.com/spf13/cast v1.5.0 // indirect 27 | github.com/spf13/jwalterweatherman v1.1.0 // indirect 28 | github.com/spf13/pflag v1.0.5 // indirect 29 | github.com/subosito/gotenv v1.4.2 // indirect 30 | golang.org/x/crypto v0.6.0 // indirect 31 | golang.org/x/net v0.8.0 // indirect 32 | golang.org/x/sys v0.6.0 // indirect 33 | golang.org/x/text v0.8.0 // indirect 34 | google.golang.org/genproto v0.0.0-20230306155012-7f2fa6fef1f4 // indirect 35 | gopkg.in/ini.v1 v1.67.0 // indirect 36 | gopkg.in/yaml.v3 v3.0.1 // indirect 37 | ) 38 | -------------------------------------------------------------------------------- /auth-svc/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/amalmadhu06/go-grpc-microservices/auth-svc 2 | 3 | go 1.19 4 | 5 | require ( 6 | github.com/golang-jwt/jwt v3.2.2+incompatible 7 | github.com/spf13/viper v1.15.0 8 | golang.org/x/crypto v0.6.0 9 | google.golang.org/grpc v1.55.0 10 | google.golang.org/protobuf v1.30.0 11 | gorm.io/driver/postgres v1.5.0 12 | gorm.io/gorm v1.25.1 13 | ) 14 | 15 | require ( 16 | github.com/fsnotify/fsnotify v1.6.0 // indirect 17 | github.com/golang/protobuf v1.5.3 // indirect 18 | github.com/hashicorp/hcl v1.0.0 // indirect 19 | github.com/jackc/pgpassfile v1.0.0 // indirect 20 | github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect 21 | github.com/jackc/pgx/v5 v5.3.0 // indirect 22 | github.com/jinzhu/inflection v1.0.0 // indirect 23 | github.com/jinzhu/now v1.1.5 // indirect 24 | github.com/magiconair/properties v1.8.7 // indirect 25 | github.com/mitchellh/mapstructure v1.5.0 // indirect 26 | github.com/pelletier/go-toml/v2 v2.0.6 // indirect 27 | github.com/spf13/afero v1.9.3 // indirect 28 | github.com/spf13/cast v1.5.0 // indirect 29 | github.com/spf13/jwalterweatherman v1.1.0 // indirect 30 | github.com/spf13/pflag v1.0.5 // indirect 31 | github.com/subosito/gotenv v1.4.2 // indirect 32 | golang.org/x/net v0.8.0 // indirect 33 | golang.org/x/sys v0.6.0 // indirect 34 | golang.org/x/text v0.8.0 // indirect 35 | google.golang.org/genproto v0.0.0-20230306155012-7f2fa6fef1f4 // indirect 36 | gopkg.in/ini.v1 v1.67.0 // indirect 37 | gopkg.in/yaml.v3 v3.0.1 // indirect 38 | ) 39 | -------------------------------------------------------------------------------- /.github/workflows/deploy.yml: -------------------------------------------------------------------------------- 1 | name: Deploy to production 2 | 3 | on: 4 | push: 5 | branches: [main] 6 | 7 | jobs: 8 | 9 | build: 10 | name: Build images 11 | runs-on: ubuntu-latest 12 | 13 | steps: 14 | - name: Checkout repo 15 | uses: actions/checkout@v3 16 | 17 | - name: Configure AWS credentials 18 | uses: aws-actions/configure-aws-credentials@v2 # More information on this action can be found below in the 'AWS Credentials' section 19 | with: 20 | aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID}} 21 | aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY}} 22 | aws-region: us-east-1 23 | 24 | - name: Login to Amazon ECR 25 | id: login-ecr 26 | uses: aws-actions/amazon-ecr-login@v1 27 | 28 | - name: Build, tag, and push docker image to Amazon ECR 29 | env: 30 | REGISTRY: ${{ steps.login-ecr.outputs.registry }} 31 | REPOSITORY: grpc-ecom 32 | run: | 33 | cd api-gateway && docker build -t $REGISTRY/$REPOSITORY:api-gateway . 34 | docker push $REGISTRY/$REPOSITORY:api-gateway 35 | cd ../auth-svc && docker build -t $REGISTRY/$REPOSITORY:auth-svc . 36 | docker push $REGISTRY/$REPOSITORY:auth-svc 37 | cd ../product-svc && docker build -t $REGISTRY/$REPOSITORY:product-svc . 38 | docker push $REGISTRY/$REPOSITORY:product-svc 39 | cd ../order-svc && docker build -t $REGISTRY/$REPOSITORY:order-svc . 40 | docker push $REGISTRY/$REPOSITORY:order-svc 41 | -------------------------------------------------------------------------------- /api-gateway/pkg/config/config.go: -------------------------------------------------------------------------------- 1 | package config 2 | 3 | import "github.com/spf13/viper" 4 | 5 | // Config represents the application configuration. 6 | // It holds various settings that can be loaded from environment variables or a configuration file. 7 | type Config struct { 8 | Port string `mapstructure:"PORT"` 9 | AuthSuvUrl string `mapstructure:"AUTH_SUV_URL"` 10 | ProductSuvUrl string `mapstructure:"PRODUCT_SUV_URL"` 11 | OrderSuvUrl string `mapstructure:"ORDER_SUV_URL"` 12 | } 13 | 14 | // LoadConfig loads the configuration settings. 15 | // It reads the configuration file, sets up environment variable support, and unmarshal the settings into a Config struct. 16 | // It returns the loaded Config and any error encountered during the process. 17 | func LoadConfig() (c Config, err error) { 18 | 19 | // AddConfigPath adds the directory where the configuration file is located. 20 | viper.AddConfigPath("./pkg/config/envs") 21 | 22 | // SetConfigName sets the name of the configuration file to be read. 23 | viper.SetConfigName("dev") 24 | 25 | // SetConfigType sets the type of the configuration file. 26 | viper.SetConfigType("env") 27 | 28 | // AutomaticEnv enables automatic binding of environment variables to configuration values. 29 | viper.AutomaticEnv() 30 | 31 | // ReadInConfig reads the configuration file with the specified name and type. 32 | err = viper.ReadInConfig() 33 | 34 | // Check if there was an error reading the configuration file. 35 | if err != nil { 36 | return 37 | } 38 | 39 | // Unmarshal reads the configuration settings into the Config struct. 40 | err = viper.Unmarshal(&c) 41 | return 42 | } 43 | -------------------------------------------------------------------------------- /auth-svc/pkg/utils/jwt.go: -------------------------------------------------------------------------------- 1 | package utils 2 | 3 | import ( 4 | "errors" 5 | "github.com/amalmadhu06/go-grpc-microservices/auth-svc/pkg/models" 6 | "github.com/golang-jwt/jwt" 7 | "time" 8 | ) 9 | 10 | type JWTWrapper struct { 11 | SecretKey string 12 | Issuer string 13 | ExpirationHours int64 14 | } 15 | 16 | type jwtClaims struct { 17 | jwt.StandardClaims 18 | Id int64 19 | Email string 20 | Role string 21 | } 22 | 23 | func (w *JWTWrapper) GenerateToken(user models.User, role string) (signedToken string, err error) { 24 | claims := &jwtClaims{ 25 | Id: user.Id, 26 | Email: user.Email, 27 | Role: role, 28 | StandardClaims: jwt.StandardClaims{ 29 | //Audience: "", 30 | ExpiresAt: time.Now().Local().Add(time.Hour * time.Duration(w.ExpirationHours)).Unix(), 31 | //Id: "", 32 | //IssuedAt: 0, 33 | Issuer: w.Issuer, 34 | //NotBefore: 0, 35 | //Subject: "", 36 | }, 37 | } 38 | 39 | token := jwt.NewWithClaims(jwt.SigningMethodHS256, claims) 40 | 41 | signedToken, err = token.SignedString([]byte(w.SecretKey)) 42 | 43 | if err != nil { 44 | return "", err 45 | } 46 | return signedToken, nil 47 | } 48 | 49 | func (w *JWTWrapper) ValidateToken(singedToken string, role string) (claims *jwtClaims, err error) { 50 | token, err := jwt.ParseWithClaims( 51 | singedToken, 52 | &jwtClaims{}, 53 | func(token *jwt.Token) (interface{}, error) { 54 | return []byte(w.SecretKey), nil 55 | }) 56 | if err != nil { 57 | return nil, err 58 | } 59 | 60 | claims, ok := token.Claims.(*jwtClaims) 61 | if !ok { 62 | return nil, errors.New("couldn't parse claims") 63 | } 64 | if claims.Role != role { 65 | return nil, errors.New("role not matching") 66 | } 67 | if claims.ExpiresAt < time.Now().Local().Unix() { 68 | return nil, errors.New("JWT is expired") 69 | } 70 | return claims, nil 71 | } 72 | -------------------------------------------------------------------------------- /order-svc/pkg/services/order.go: -------------------------------------------------------------------------------- 1 | package services 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | "github.com/amalmadhu06/go-grpc-microservices/order-svc/pkg/client" 7 | "github.com/amalmadhu06/go-grpc-microservices/order-svc/pkg/db" 8 | "github.com/amalmadhu06/go-grpc-microservices/order-svc/pkg/models" 9 | "github.com/amalmadhu06/go-grpc-microservices/order-svc/pkg/pb" 10 | "net/http" 11 | ) 12 | 13 | type Server struct { 14 | H db.Handler 15 | ProductSvc client.ProductServiceClient 16 | pb.UnimplementedOrderServiceServer 17 | } 18 | 19 | func (s *Server) CreateOrder(ctx context.Context, req *pb.CreateOrderRequest) (*pb.CreateOrderResponse, error) { 20 | fmt.Println("Order Service : CreateOrder") 21 | product, err := s.ProductSvc.FindOne(req.ProductId) 22 | 23 | if err != nil { 24 | return &pb.CreateOrderResponse{ 25 | Status: http.StatusBadRequest, Error: err.Error(), 26 | }, nil 27 | } else if product.Status >= http.StatusNotFound { 28 | return &pb.CreateOrderResponse{ 29 | Status: product.Status, 30 | Error: product.Error, 31 | }, nil 32 | } else if product.Data.Stock < req.Quantity { 33 | return &pb.CreateOrderResponse{ 34 | Status: http.StatusConflict, 35 | Error: "Stock too less", 36 | }, nil 37 | } 38 | 39 | order := models.Order{ 40 | Price: product.Data.Price, 41 | ProductId: product.Data.Id, 42 | UserId: req.UserId, 43 | } 44 | 45 | s.H.DB.Create(&order) 46 | 47 | res, err := s.ProductSvc.DecreaseStock(req.ProductId, order.Id) 48 | 49 | if err != nil { 50 | return &pb.CreateOrderResponse{Status: http.StatusBadRequest, Error: err.Error()}, nil 51 | } else if res.Status == http.StatusConflict { 52 | s.H.DB.Delete(&models.Order{}, order.Id) 53 | 54 | return &pb.CreateOrderResponse{Status: http.StatusConflict, Error: res.Error}, nil 55 | } 56 | 57 | return &pb.CreateOrderResponse{ 58 | Status: http.StatusCreated, 59 | Id: order.Id, 60 | }, nil 61 | } 62 | -------------------------------------------------------------------------------- /api-gateway/pkg/auth/middleware.go: -------------------------------------------------------------------------------- 1 | package auth 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | "github.com/amalmadhu06/go-grpc-microservices/api-gateway/pkg/auth/pb" 7 | "github.com/gin-gonic/gin" 8 | "net/http" 9 | "strings" 10 | ) 11 | 12 | type AuthMiddlewareConfig struct { 13 | svc *ServiceClient 14 | } 15 | 16 | func InitAuthMiddleware(svc *ServiceClient) AuthMiddlewareConfig { 17 | fmt.Println("API Gateway : InitAuthMiddleware") 18 | return AuthMiddlewareConfig{svc: svc} 19 | } 20 | 21 | func (c *AuthMiddlewareConfig) UserAuth(ctx *gin.Context) { 22 | fmt.Println("API Gateway : AuthRequired") 23 | authorization := ctx.Request.Header.Get("Authorization") 24 | 25 | if authorization == "" { 26 | ctx.AbortWithStatus(http.StatusUnauthorized) 27 | return 28 | } 29 | 30 | token := strings.Split(authorization, "Bearer ") 31 | 32 | if len(token) > 2 { 33 | ctx.AbortWithStatus(http.StatusUnauthorized) 34 | return 35 | } 36 | 37 | res, err := c.svc.Client.Validate(context.Background(), &pb.ValidateRequest{ 38 | Token: token[1], 39 | Role: "user", 40 | }) 41 | 42 | if err != nil || res.Status != http.StatusOK { 43 | ctx.AbortWithStatus(http.StatusUnauthorized) 44 | return 45 | } 46 | 47 | ctx.Set("userId", res.UserId) 48 | 49 | ctx.Next() 50 | } 51 | 52 | func (c *AuthMiddlewareConfig) AdminAuth(ctx *gin.Context) { 53 | fmt.Println("API Gateway : AuthRequired") 54 | authorization := ctx.Request.Header.Get("Authorization") 55 | 56 | if authorization == "" { 57 | ctx.AbortWithStatus(http.StatusUnauthorized) 58 | return 59 | } 60 | 61 | token := strings.Split(authorization, "Bearer ") 62 | 63 | if len(token) > 2 { 64 | ctx.AbortWithStatus(http.StatusUnauthorized) 65 | return 66 | } 67 | 68 | res, err := c.svc.Client.Validate(context.Background(), &pb.ValidateRequest{ 69 | Token: token[1], 70 | Role: "admin", 71 | }) 72 | 73 | if err != nil || res.Status != http.StatusOK { 74 | ctx.AbortWithStatus(http.StatusUnauthorized) 75 | return 76 | } 77 | 78 | ctx.Set("userId", res.UserId) 79 | 80 | ctx.Next() 81 | } 82 | -------------------------------------------------------------------------------- /api-gateway/pkg/auth/pb/auth.proto: -------------------------------------------------------------------------------- 1 | // mention which version of proto are we using 2 | syntax = "proto3"; 3 | 4 | //package name 5 | package auth; 6 | 7 | // mention where to store the auto generated files 8 | option go_package = "./pkg/auth/pb"; 9 | 10 | // This service handles user authentication and provides three methods: Register, Login, and Validate. 11 | service AuthService{ 12 | // Register 13 | // This method allows a user to register by providing their email and password. 14 | // The server will respond with a status indicating the result of the registration 15 | // attempt and an error message if applicable. 16 | rpc Register(RegisterRequest) returns (RegisterResponse){} 17 | 18 | // Login 19 | // This method allows a user to log in by providing their email and password. 20 | // Upon successful login, the server will respond with a status indicating the 21 | // login result, an error message if applicable, and a token that can be used for 22 | // subsequent authenticated requests. 23 | rpc Login(LoginRequest) returns (LoginResponse) {} 24 | 25 | // Validate 26 | // This method is used to validate a token received from a client. 27 | // The client sends the token in a ValidateRequest, and the server responds with 28 | // a status indicating the validation result, an error message if applicable, and 29 | // the user ID associated with the token if the validation is successful. 30 | rpc Validate(ValidateRequest) returns (ValidateResponse) {} 31 | 32 | rpc AdminLogin(LoginRequest) returns (LoginResponse); 33 | } 34 | 35 | message RegisterRequest{ 36 | string email = 1; 37 | string password = 2; 38 | } 39 | 40 | message RegisterResponse{ 41 | int64 status = 1; 42 | string error = 2; 43 | } 44 | 45 | message LoginRequest{ 46 | string email = 1; 47 | string password = 2; 48 | } 49 | 50 | message LoginResponse{ 51 | int64 status = 1; 52 | string error = 2; 53 | string token = 3; 54 | } 55 | 56 | message ValidateRequest{ 57 | string token = 1; 58 | string role = 2; 59 | } 60 | 61 | message ValidateResponse{ 62 | int64 status = 1; 63 | string error = 2; 64 | int64 userId = 3; 65 | } -------------------------------------------------------------------------------- /api-gateway/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/amalmadhu06/go-grpc-microservices/api-gateway 2 | 3 | go 1.19 4 | 5 | require ( 6 | github.com/gin-gonic/gin v1.9.0 7 | github.com/spf13/viper v1.15.0 8 | google.golang.org/grpc v1.55.0 9 | google.golang.org/protobuf v1.30.0 10 | ) 11 | 12 | require ( 13 | github.com/bytedance/sonic v1.8.0 // indirect 14 | github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect 15 | github.com/fsnotify/fsnotify v1.6.0 // indirect 16 | github.com/gin-contrib/sse v0.1.0 // indirect 17 | github.com/go-playground/locales v0.14.1 // indirect 18 | github.com/go-playground/universal-translator v0.18.1 // indirect 19 | github.com/go-playground/validator/v10 v10.11.2 // indirect 20 | github.com/goccy/go-json v0.10.0 // indirect 21 | github.com/golang/protobuf v1.5.3 // indirect 22 | github.com/hashicorp/hcl v1.0.0 // indirect 23 | github.com/json-iterator/go v1.1.12 // indirect 24 | github.com/klauspost/cpuid/v2 v2.0.9 // indirect 25 | github.com/leodido/go-urn v1.2.1 // indirect 26 | github.com/magiconair/properties v1.8.7 // indirect 27 | github.com/mattn/go-isatty v0.0.17 // indirect 28 | github.com/mitchellh/mapstructure v1.5.0 // indirect 29 | github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect 30 | github.com/modern-go/reflect2 v1.0.2 // indirect 31 | github.com/pelletier/go-toml/v2 v2.0.6 // indirect 32 | github.com/spf13/afero v1.9.3 // indirect 33 | github.com/spf13/cast v1.5.0 // indirect 34 | github.com/spf13/jwalterweatherman v1.1.0 // indirect 35 | github.com/spf13/pflag v1.0.5 // indirect 36 | github.com/subosito/gotenv v1.4.2 // indirect 37 | github.com/twitchyliquid64/golang-asm v0.15.1 // indirect 38 | github.com/ugorji/go/codec v1.2.9 // indirect 39 | golang.org/x/arch v0.0.0-20210923205945-b76863e36670 // indirect 40 | golang.org/x/crypto v0.5.0 // indirect 41 | golang.org/x/net v0.8.0 // indirect 42 | golang.org/x/sys v0.6.0 // indirect 43 | golang.org/x/text v0.8.0 // indirect 44 | google.golang.org/genproto v0.0.0-20230306155012-7f2fa6fef1f4 // indirect 45 | gopkg.in/ini.v1 v1.67.0 // indirect 46 | gopkg.in/yaml.v3 v3.0.1 // indirect 47 | ) 48 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3.9" 2 | services: 3 | api-gateway: 4 | image: amalmadhu06/ecom-api-gateway 5 | environment: 6 | - PORT=:3000 7 | - AUTH_SVC_URL=ath-svc:50051 8 | - PRODUCT_SVC_URL=product-svc:50052 9 | - ORDER_SVC_URL=order-svc:50053 10 | ports: 11 | - "3000:3000" 12 | depends_on: 13 | - auth-svc 14 | - product-svc 15 | - order-svc 16 | restart: always 17 | 18 | auth-svc: 19 | image: amalmadhu06/ecom-auth-svc 20 | ports: 21 | - "50051:50051" 22 | environment: 23 | - PORT=:50051 24 | - DB_URL=postgres://postgres:postgres@auth-db:5432/auth_svc 25 | - JWT_SECRET_KEY=h28dh582fcu390 26 | depends_on: 27 | - auth-db 28 | restart: always 29 | 30 | product-svc: 31 | image: amalmadhu06/ecom-product-svc 32 | ports: 33 | - "50052:50052" 34 | environment: 35 | - PORT=:50052 36 | - DB_URL=postgres://postgres:postgres@product-db:5432/product_svc 37 | depends_on: 38 | - product-db 39 | restart: always 40 | 41 | order-svc: 42 | image: amalmadhu06/ecom-order-svc 43 | ports: 44 | - "50053:50053" 45 | environment: 46 | - PORT=:50053 47 | - DB_URL=postgres://postgres:postgres@order-db:5432/order_svc 48 | - PRODUCT_SVC_URL=product-svc:50052 49 | depends_on: 50 | - order-db 51 | - product-svc 52 | restart: always 53 | 54 | auth-db: 55 | image: postgres:latest 56 | ports: 57 | - "5433:5432" 58 | environment: 59 | - POSTGRES_DB=auth_svc 60 | - POSTGRES_USER=postgres 61 | - POSTGRES_PASSWORD=postgres 62 | restart: always 63 | 64 | product-db: 65 | image: postgres:latest 66 | ports: 67 | - "5434:5432" 68 | environment: 69 | - POSTGRES_DB=product_svc 70 | - POSTGRES_USER=postgres 71 | - POSTGRES_PASSWORD=postgres 72 | restart: always 73 | 74 | order-db: 75 | image: postgres:latest 76 | ports: 77 | - "5435:5432" 78 | environment: 79 | - POSTGRES_DB=order_svc 80 | - POSTGRES_USER=postgres 81 | - POSTGRES_PASSWORD=postgres 82 | restart: always -------------------------------------------------------------------------------- /auth-svc/pkg/services/auth.go: -------------------------------------------------------------------------------- 1 | package services 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | "github.com/amalmadhu06/go-grpc-microservices/auth-svc/pkg/db" 7 | "github.com/amalmadhu06/go-grpc-microservices/auth-svc/pkg/models" 8 | "github.com/amalmadhu06/go-grpc-microservices/auth-svc/pkg/pb" 9 | "github.com/amalmadhu06/go-grpc-microservices/auth-svc/pkg/utils" 10 | "net/http" 11 | ) 12 | 13 | type Server struct { 14 | H db.Handler // handler 15 | Jwt utils.JWTWrapper // jwt wrapper 16 | pb.UnimplementedAuthServiceServer //need to embed this for implementing 17 | } 18 | 19 | func (s *Server) Register(ctx context.Context, req *pb.RegisterRequest) (*pb.RegisterResponse, error) { 20 | fmt.Println("Auth Service : Register") 21 | var user models.User 22 | 23 | if result := s.H.DB.Where(&models.User{Email: req.Email}).First(&user); result.Error == nil { 24 | return &pb.RegisterResponse{ 25 | Status: http.StatusConflict, 26 | Error: "E-Mail already exists", 27 | }, nil 28 | } 29 | 30 | user.Email = req.Email 31 | user.Password = utils.HashPassword(req.Password) 32 | 33 | s.H.DB.Create(&user) 34 | 35 | return &pb.RegisterResponse{ 36 | Status: http.StatusCreated, 37 | }, nil 38 | } 39 | 40 | func (s *Server) Login(ctx context.Context, req *pb.LoginRequest) (*pb.LoginResponse, error) { 41 | fmt.Println("Auth Service : Login") 42 | var user models.User 43 | 44 | if result := s.H.DB.Where(&models.User{Email: req.Email}).First(&user); result.Error != nil { 45 | return &pb.LoginResponse{ 46 | Status: http.StatusNotFound, 47 | Error: "User not found", 48 | }, nil 49 | } 50 | 51 | match := utils.CheckPasswordHash(req.Password, user.Password) 52 | 53 | if !match { 54 | return &pb.LoginResponse{ 55 | Status: http.StatusNotFound, 56 | Error: "User not found", 57 | }, nil 58 | } 59 | 60 | token, _ := s.Jwt.GenerateToken(user, "user") 61 | 62 | return &pb.LoginResponse{ 63 | Status: http.StatusOK, 64 | Token: token, 65 | }, nil 66 | } 67 | 68 | func (s *Server) Validate(ctx context.Context, req *pb.ValidateRequest) (*pb.ValidateResponse, error) { 69 | fmt.Println("Auth Service : Validate") 70 | claims, err := s.Jwt.ValidateToken(req.Token, req.Role) 71 | 72 | if err != nil { 73 | return &pb.ValidateResponse{ 74 | Status: http.StatusBadRequest, 75 | Error: err.Error(), 76 | }, nil 77 | } 78 | 79 | var user models.User 80 | fmt.Println(req.Role) 81 | if req.Role == "user" { 82 | if result := s.H.DB.Where(&models.User{Email: claims.Email}).First(&user); result.Error != nil { 83 | return &pb.ValidateResponse{ 84 | Status: http.StatusNotFound, 85 | Error: "User not found", 86 | }, nil 87 | } 88 | } 89 | if req.Role == "admin" { 90 | sql := `SELECT * FROM admins WHERE email = $1 LIMIT 1;` 91 | if result := s.H.DB.Raw(sql, claims.Email).Scan(&user); result.Error != nil { 92 | return &pb.ValidateResponse{ 93 | Status: http.StatusNotFound, 94 | Error: "admin not found", 95 | }, nil 96 | } 97 | } 98 | 99 | return &pb.ValidateResponse{ 100 | Status: http.StatusOK, 101 | UserId: user.Id, 102 | }, nil 103 | } 104 | -------------------------------------------------------------------------------- /api-gateway/pkg/product/pb/product.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package product; 4 | 5 | option go_package = "./pkg/product/pb"; 6 | 7 | // ProductService is a service that handles product-related operations. 8 | service ProductService{ 9 | 10 | // CreateProduct is an RPC method that allows the creation of a new product. 11 | // It takes a CreateProductRequest message as input, containing the name, 12 | // SKU, stock, and price of the product. The server will respond with a 13 | // CreateProductResponse message, which includes a status indicating the result 14 | // of the product creation, an error message if applicable, and the ID of the newly 15 | // created product. 16 | rpc CreateProduct(CreateProductRequest) returns (CreateProductResponse); 17 | 18 | // FindOne is an RPC method that retrieves the details of a specific product 19 | // based on the provided ID. It takes a FindOneRequest message with the ID of 20 | // the product to be found. The server responds with a FindOneResponse message, 21 | // which includes a status indicating the result of the search, an error message 22 | // if applicable, and the data of the found product. 23 | rpc FindOne(FindOneRequest) returns (FindOneResponse); 24 | 25 | rpc FindAll(FindAllRequest) returns (FindAllResponse); 26 | 27 | // DecreaseStock is an RPC method that decrements the stock of a product when an 28 | // order is placed. It takes a DecreaseStockRequest message with the ID of the 29 | // product and the associated order ID. The server responds with a 30 | // DecreaseStockResponse message, which includes a status indicating the result 31 | // of the stock decrease operation, and an error message if applicable. 32 | rpc DecreaseStock(DecreaseStockRequest) returns (DecreaseStockResponse); 33 | } 34 | 35 | // CreateProductRequest is a message that carries the necessary data to create a product. 36 | message CreateProductRequest{ 37 | string name = 1; 38 | int64 stock = 2; 39 | int64 price = 3; 40 | } 41 | 42 | // CreateProductResponse is a message that carries the response after attempting to create a product. 43 | message CreateProductResponse{ 44 | int64 status = 1; 45 | string error = 2; 46 | int64 id = 3; 47 | } 48 | 49 | // FindOneData is a message that represents the data of a single product. 50 | message FindOneData{ 51 | int64 id = 1; 52 | string name = 2; 53 | int64 stock = 3; 54 | int64 price = 4; 55 | } 56 | 57 | // FindOneRequest is a message that carries the ID of the product to be found. 58 | message FindOneRequest{ 59 | int64 id = 1; 60 | } 61 | 62 | // FindOneResponse is a message that carries the response after attempting to find a product. 63 | message FindOneResponse{ 64 | int64 status = 1; 65 | string error = 2; 66 | FindOneData data = 3; 67 | } 68 | 69 | //FindAllRequest 70 | message FindAllRequest{ 71 | } 72 | 73 | //FindAllResponse 74 | message FindAllResponse{ 75 | int64 status = 1; 76 | string error = 2; 77 | repeated FindOneData products = 3; 78 | } 79 | 80 | // DecreaseStockRequest is a message that carries the necessary data to decrease the stock of a product. 81 | message DecreaseStockRequest{ 82 | int64 id = 1; 83 | int64 orderId = 2; 84 | } 85 | 86 | // DecreaseStockResponse is a message that carries the response after attempting to decrease the stock of a product. 87 | message DecreaseStockResponse{ 88 | int64 status = 1; 89 | string error = 2; 90 | } -------------------------------------------------------------------------------- /product-svc/pkg/services/product.go: -------------------------------------------------------------------------------- 1 | package services 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | "github.com/amalmadhu06/go-grpc-microservices/product-svc/pkg/db" 7 | "github.com/amalmadhu06/go-grpc-microservices/product-svc/pkg/models" 8 | "github.com/amalmadhu06/go-grpc-microservices/product-svc/pkg/pb" 9 | "net/http" 10 | ) 11 | 12 | type Server struct { 13 | H db.Handler 14 | pb.UnimplementedProductServiceServer 15 | } 16 | 17 | func (s *Server) CreateProduct(ctx context.Context, req *pb.CreateProductRequest) (*pb.CreateProductResponse, error) { 18 | fmt.Println("Product Service : CreateProduct") 19 | var product models.Product 20 | fmt.Println("repository") 21 | fmt.Println(req) 22 | fmt.Println("----------------") 23 | product.Name = req.Name 24 | product.Stock = req.Stock 25 | product.Price = req.Price 26 | 27 | if result := s.H.DB.Create(&product); result.Error != nil { 28 | return &pb.CreateProductResponse{ 29 | Status: http.StatusConflict, 30 | Error: result.Error.Error(), 31 | }, nil 32 | } 33 | 34 | return &pb.CreateProductResponse{ 35 | Status: http.StatusCreated, 36 | Id: product.Id, 37 | }, nil 38 | } 39 | 40 | func (s *Server) FindOne(ctx context.Context, req *pb.FindOneRequest) (*pb.FindOneResponse, error) { 41 | var product models.Product 42 | 43 | if result := s.H.DB.First(&product, req.Id); result.Error != nil { 44 | return &pb.FindOneResponse{ 45 | Status: http.StatusNotFound, 46 | Error: result.Error.Error(), 47 | }, nil 48 | } 49 | 50 | data := &pb.FindOneData{ 51 | Id: product.Id, 52 | Name: product.Name, 53 | Stock: product.Stock, 54 | Price: product.Price, 55 | } 56 | 57 | return &pb.FindOneResponse{ 58 | Status: http.StatusOK, 59 | Data: data, 60 | }, nil 61 | } 62 | 63 | func (s *Server) FindAll(ctx context.Context, req *pb.FindAllRequest) (*pb.FindAllResponse, error) { 64 | var products []models.Product 65 | 66 | rows, err := s.H.DB.Model(&models.Product{}).Where("stock > 0").Rows() 67 | defer rows.Close() 68 | if err != nil { 69 | return &pb.FindAllResponse{}, err 70 | } 71 | 72 | for rows.Next() { 73 | var product models.Product 74 | err := s.H.DB.ScanRows(rows, &product) 75 | if err != nil { 76 | return nil, err 77 | } 78 | products = append(products, product) 79 | } 80 | 81 | var outProducts []*pb.FindOneData 82 | for _, v := range products { 83 | var p pb.FindOneData 84 | p.Id = v.Id 85 | p.Name = v.Name 86 | p.Price = v.Price 87 | p.Stock = v.Stock 88 | 89 | outProducts = append(outProducts, &p) 90 | } 91 | 92 | return &pb.FindAllResponse{ 93 | Status: http.StatusOK, 94 | Products: outProducts, 95 | }, nil 96 | } 97 | 98 | func (s *Server) DecreaseStock(ctx context.Context, req *pb.DecreaseStockRequest) (*pb.DecreaseStockResponse, error) { 99 | fmt.Println("Product Service : DecreaseStock") 100 | var product models.Product 101 | 102 | if result := s.H.DB.First(&product, req.Id); result.Error != nil { 103 | return &pb.DecreaseStockResponse{ 104 | Status: http.StatusNotFound, 105 | Error: result.Error.Error(), 106 | }, nil 107 | } 108 | 109 | if product.Stock <= 0 { 110 | return &pb.DecreaseStockResponse{ 111 | Status: http.StatusConflict, 112 | Error: "Stock too low", 113 | }, nil 114 | } 115 | 116 | var log models.StockDecreaseLog 117 | 118 | if result := s.H.DB.Where(&models.StockDecreaseLog{OrderId: req.OrderId}).First(&log); result.Error == nil { 119 | return &pb.DecreaseStockResponse{ 120 | Status: http.StatusConflict, 121 | Error: "Stock already decreased", 122 | }, nil 123 | } 124 | 125 | product.Stock = product.Stock - 1 126 | 127 | s.H.DB.Save(&product) 128 | 129 | log.OrderId = req.OrderId 130 | log.ProductRefer = product.Id 131 | 132 | s.H.DB.Create(&log) 133 | 134 | return &pb.DecreaseStockResponse{ 135 | Status: http.StatusOK, 136 | }, nil 137 | } 138 | -------------------------------------------------------------------------------- /order-svc/pkg/pb/order_grpc.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go-grpc. DO NOT EDIT. 2 | // versions: 3 | // - protoc-gen-go-grpc v1.2.0 4 | // - protoc v4.22.4 5 | // source: pkg/pb/order.proto 6 | 7 | package pb 8 | 9 | import ( 10 | context "context" 11 | grpc "google.golang.org/grpc" 12 | codes "google.golang.org/grpc/codes" 13 | status "google.golang.org/grpc/status" 14 | ) 15 | 16 | // This is a compile-time assertion to ensure that this generated file 17 | // is compatible with the grpc package it is being compiled against. 18 | // Requires gRPC-Go v1.32.0 or later. 19 | const _ = grpc.SupportPackageIsVersion7 20 | 21 | // OrderServiceClient is the client API for OrderService service. 22 | // 23 | // 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. 24 | type OrderServiceClient interface { 25 | CreateOrder(ctx context.Context, in *CreateOrderRequest, opts ...grpc.CallOption) (*CreateOrderResponse, error) 26 | } 27 | 28 | type orderServiceClient struct { 29 | cc grpc.ClientConnInterface 30 | } 31 | 32 | func NewOrderServiceClient(cc grpc.ClientConnInterface) OrderServiceClient { 33 | return &orderServiceClient{cc} 34 | } 35 | 36 | func (c *orderServiceClient) CreateOrder(ctx context.Context, in *CreateOrderRequest, opts ...grpc.CallOption) (*CreateOrderResponse, error) { 37 | out := new(CreateOrderResponse) 38 | err := c.cc.Invoke(ctx, "/order.OrderService/CreateOrder", in, out, opts...) 39 | if err != nil { 40 | return nil, err 41 | } 42 | return out, nil 43 | } 44 | 45 | // OrderServiceServer is the server API for OrderService service. 46 | // All implementations must embed UnimplementedOrderServiceServer 47 | // for forward compatibility 48 | type OrderServiceServer interface { 49 | CreateOrder(context.Context, *CreateOrderRequest) (*CreateOrderResponse, error) 50 | mustEmbedUnimplementedOrderServiceServer() 51 | } 52 | 53 | // UnimplementedOrderServiceServer must be embedded to have forward compatible implementations. 54 | type UnimplementedOrderServiceServer struct { 55 | } 56 | 57 | func (UnimplementedOrderServiceServer) CreateOrder(context.Context, *CreateOrderRequest) (*CreateOrderResponse, error) { 58 | return nil, status.Errorf(codes.Unimplemented, "method CreateOrder not implemented") 59 | } 60 | func (UnimplementedOrderServiceServer) mustEmbedUnimplementedOrderServiceServer() {} 61 | 62 | // UnsafeOrderServiceServer may be embedded to opt out of forward compatibility for this service. 63 | // Use of this interface is not recommended, as added methods to OrderServiceServer will 64 | // result in compilation errors. 65 | type UnsafeOrderServiceServer interface { 66 | mustEmbedUnimplementedOrderServiceServer() 67 | } 68 | 69 | func RegisterOrderServiceServer(s grpc.ServiceRegistrar, srv OrderServiceServer) { 70 | s.RegisterService(&OrderService_ServiceDesc, srv) 71 | } 72 | 73 | func _OrderService_CreateOrder_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 74 | in := new(CreateOrderRequest) 75 | if err := dec(in); err != nil { 76 | return nil, err 77 | } 78 | if interceptor == nil { 79 | return srv.(OrderServiceServer).CreateOrder(ctx, in) 80 | } 81 | info := &grpc.UnaryServerInfo{ 82 | Server: srv, 83 | FullMethod: "/order.OrderService/CreateOrder", 84 | } 85 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 86 | return srv.(OrderServiceServer).CreateOrder(ctx, req.(*CreateOrderRequest)) 87 | } 88 | return interceptor(ctx, in, info, handler) 89 | } 90 | 91 | // OrderService_ServiceDesc is the grpc.ServiceDesc for OrderService service. 92 | // It's only intended for direct use with grpc.RegisterService, 93 | // and not to be introspected or modified (even as a copy) 94 | var OrderService_ServiceDesc = grpc.ServiceDesc{ 95 | ServiceName: "order.OrderService", 96 | HandlerType: (*OrderServiceServer)(nil), 97 | Methods: []grpc.MethodDesc{ 98 | { 99 | MethodName: "CreateOrder", 100 | Handler: _OrderService_CreateOrder_Handler, 101 | }, 102 | }, 103 | Streams: []grpc.StreamDesc{}, 104 | Metadata: "pkg/pb/order.proto", 105 | } 106 | -------------------------------------------------------------------------------- /api-gateway/pkg/order/pb/order_grpc.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go-grpc. DO NOT EDIT. 2 | // versions: 3 | // - protoc-gen-go-grpc v1.2.0 4 | // - protoc v4.22.4 5 | // source: pkg/order/pb/order.proto 6 | 7 | package pb 8 | 9 | import ( 10 | context "context" 11 | grpc "google.golang.org/grpc" 12 | codes "google.golang.org/grpc/codes" 13 | status "google.golang.org/grpc/status" 14 | ) 15 | 16 | // This is a compile-time assertion to ensure that this generated file 17 | // is compatible with the grpc package it is being compiled against. 18 | // Requires gRPC-Go v1.32.0 or later. 19 | const _ = grpc.SupportPackageIsVersion7 20 | 21 | // OrderServiceClient is the client API for OrderService service. 22 | // 23 | // 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. 24 | type OrderServiceClient interface { 25 | // CreateOrder is an RPC method that allows the creation of a new order. 26 | // It takes a CreateOrderRequest message as input, containing the product ID, 27 | // quantity, and user ID associated with the order. The server will respond with 28 | // a CreateOrderResponse message, which includes a status indicating the result 29 | // of the order creation, an error message if applicable, and the ID of the newly 30 | // created order. 31 | CreateOrder(ctx context.Context, in *CreateOrderRequest, opts ...grpc.CallOption) (*CreateOrderResponse, error) 32 | } 33 | 34 | type orderServiceClient struct { 35 | cc grpc.ClientConnInterface 36 | } 37 | 38 | func NewOrderServiceClient(cc grpc.ClientConnInterface) OrderServiceClient { 39 | return &orderServiceClient{cc} 40 | } 41 | 42 | func (c *orderServiceClient) CreateOrder(ctx context.Context, in *CreateOrderRequest, opts ...grpc.CallOption) (*CreateOrderResponse, error) { 43 | out := new(CreateOrderResponse) 44 | err := c.cc.Invoke(ctx, "/order.OrderService/CreateOrder", in, out, opts...) 45 | if err != nil { 46 | return nil, err 47 | } 48 | return out, nil 49 | } 50 | 51 | // OrderServiceServer is the server API for OrderService service. 52 | // All implementations must embed UnimplementedOrderServiceServer 53 | // for forward compatibility 54 | type OrderServiceServer interface { 55 | // CreateOrder is an RPC method that allows the creation of a new order. 56 | // It takes a CreateOrderRequest message as input, containing the product ID, 57 | // quantity, and user ID associated with the order. The server will respond with 58 | // a CreateOrderResponse message, which includes a status indicating the result 59 | // of the order creation, an error message if applicable, and the ID of the newly 60 | // created order. 61 | CreateOrder(context.Context, *CreateOrderRequest) (*CreateOrderResponse, error) 62 | mustEmbedUnimplementedOrderServiceServer() 63 | } 64 | 65 | // UnimplementedOrderServiceServer must be embedded to have forward compatible implementations. 66 | type UnimplementedOrderServiceServer struct { 67 | } 68 | 69 | func (UnimplementedOrderServiceServer) CreateOrder(context.Context, *CreateOrderRequest) (*CreateOrderResponse, error) { 70 | return nil, status.Errorf(codes.Unimplemented, "method CreateOrder not implemented") 71 | } 72 | func (UnimplementedOrderServiceServer) mustEmbedUnimplementedOrderServiceServer() {} 73 | 74 | // UnsafeOrderServiceServer may be embedded to opt out of forward compatibility for this service. 75 | // Use of this interface is not recommended, as added methods to OrderServiceServer will 76 | // result in compilation errors. 77 | type UnsafeOrderServiceServer interface { 78 | mustEmbedUnimplementedOrderServiceServer() 79 | } 80 | 81 | func RegisterOrderServiceServer(s grpc.ServiceRegistrar, srv OrderServiceServer) { 82 | s.RegisterService(&OrderService_ServiceDesc, srv) 83 | } 84 | 85 | func _OrderService_CreateOrder_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 86 | in := new(CreateOrderRequest) 87 | if err := dec(in); err != nil { 88 | return nil, err 89 | } 90 | if interceptor == nil { 91 | return srv.(OrderServiceServer).CreateOrder(ctx, in) 92 | } 93 | info := &grpc.UnaryServerInfo{ 94 | Server: srv, 95 | FullMethod: "/order.OrderService/CreateOrder", 96 | } 97 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 98 | return srv.(OrderServiceServer).CreateOrder(ctx, req.(*CreateOrderRequest)) 99 | } 100 | return interceptor(ctx, in, info, handler) 101 | } 102 | 103 | // OrderService_ServiceDesc is the grpc.ServiceDesc for OrderService service. 104 | // It's only intended for direct use with grpc.RegisterService, 105 | // and not to be introspected or modified (even as a copy) 106 | var OrderService_ServiceDesc = grpc.ServiceDesc{ 107 | ServiceName: "order.OrderService", 108 | HandlerType: (*OrderServiceServer)(nil), 109 | Methods: []grpc.MethodDesc{ 110 | { 111 | MethodName: "CreateOrder", 112 | Handler: _OrderService_CreateOrder_Handler, 113 | }, 114 | }, 115 | Streams: []grpc.StreamDesc{}, 116 | Metadata: "pkg/order/pb/order.proto", 117 | } 118 | -------------------------------------------------------------------------------- /order-svc/pkg/pb/product_grpc.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go-grpc. DO NOT EDIT. 2 | // versions: 3 | // - protoc-gen-go-grpc v1.2.0 4 | // - protoc v4.22.4 5 | // source: pkg/pb/product.proto 6 | 7 | package pb 8 | 9 | import ( 10 | context "context" 11 | grpc "google.golang.org/grpc" 12 | codes "google.golang.org/grpc/codes" 13 | status "google.golang.org/grpc/status" 14 | ) 15 | 16 | // This is a compile-time assertion to ensure that this generated file 17 | // is compatible with the grpc package it is being compiled against. 18 | // Requires gRPC-Go v1.32.0 or later. 19 | const _ = grpc.SupportPackageIsVersion7 20 | 21 | // ProductServiceClient is the client API for ProductService service. 22 | // 23 | // 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. 24 | type ProductServiceClient interface { 25 | CreateProduct(ctx context.Context, in *CreateProductRequest, opts ...grpc.CallOption) (*CreateProductResponse, error) 26 | FindOne(ctx context.Context, in *FindOneRequest, opts ...grpc.CallOption) (*FindOneResponse, error) 27 | DecreaseStock(ctx context.Context, in *DecreaseStockRequest, opts ...grpc.CallOption) (*DecreaseStockResponse, error) 28 | } 29 | 30 | type productServiceClient struct { 31 | cc grpc.ClientConnInterface 32 | } 33 | 34 | func NewProductServiceClient(cc grpc.ClientConnInterface) ProductServiceClient { 35 | return &productServiceClient{cc} 36 | } 37 | 38 | func (c *productServiceClient) CreateProduct(ctx context.Context, in *CreateProductRequest, opts ...grpc.CallOption) (*CreateProductResponse, error) { 39 | out := new(CreateProductResponse) 40 | err := c.cc.Invoke(ctx, "/product.ProductService/CreateProduct", in, out, opts...) 41 | if err != nil { 42 | return nil, err 43 | } 44 | return out, nil 45 | } 46 | 47 | func (c *productServiceClient) FindOne(ctx context.Context, in *FindOneRequest, opts ...grpc.CallOption) (*FindOneResponse, error) { 48 | out := new(FindOneResponse) 49 | err := c.cc.Invoke(ctx, "/product.ProductService/FindOne", in, out, opts...) 50 | if err != nil { 51 | return nil, err 52 | } 53 | return out, nil 54 | } 55 | 56 | func (c *productServiceClient) DecreaseStock(ctx context.Context, in *DecreaseStockRequest, opts ...grpc.CallOption) (*DecreaseStockResponse, error) { 57 | out := new(DecreaseStockResponse) 58 | err := c.cc.Invoke(ctx, "/product.ProductService/DecreaseStock", in, out, opts...) 59 | if err != nil { 60 | return nil, err 61 | } 62 | return out, nil 63 | } 64 | 65 | // ProductServiceServer is the server API for ProductService service. 66 | // All implementations must embed UnimplementedProductServiceServer 67 | // for forward compatibility 68 | type ProductServiceServer interface { 69 | CreateProduct(context.Context, *CreateProductRequest) (*CreateProductResponse, error) 70 | FindOne(context.Context, *FindOneRequest) (*FindOneResponse, error) 71 | DecreaseStock(context.Context, *DecreaseStockRequest) (*DecreaseStockResponse, error) 72 | mustEmbedUnimplementedProductServiceServer() 73 | } 74 | 75 | // UnimplementedProductServiceServer must be embedded to have forward compatible implementations. 76 | type UnimplementedProductServiceServer struct { 77 | } 78 | 79 | func (UnimplementedProductServiceServer) CreateProduct(context.Context, *CreateProductRequest) (*CreateProductResponse, error) { 80 | return nil, status.Errorf(codes.Unimplemented, "method CreateProduct not implemented") 81 | } 82 | func (UnimplementedProductServiceServer) FindOne(context.Context, *FindOneRequest) (*FindOneResponse, error) { 83 | return nil, status.Errorf(codes.Unimplemented, "method FindOne not implemented") 84 | } 85 | func (UnimplementedProductServiceServer) DecreaseStock(context.Context, *DecreaseStockRequest) (*DecreaseStockResponse, error) { 86 | return nil, status.Errorf(codes.Unimplemented, "method DecreaseStock not implemented") 87 | } 88 | func (UnimplementedProductServiceServer) mustEmbedUnimplementedProductServiceServer() {} 89 | 90 | // UnsafeProductServiceServer may be embedded to opt out of forward compatibility for this service. 91 | // Use of this interface is not recommended, as added methods to ProductServiceServer will 92 | // result in compilation errors. 93 | type UnsafeProductServiceServer interface { 94 | mustEmbedUnimplementedProductServiceServer() 95 | } 96 | 97 | func RegisterProductServiceServer(s grpc.ServiceRegistrar, srv ProductServiceServer) { 98 | s.RegisterService(&ProductService_ServiceDesc, srv) 99 | } 100 | 101 | func _ProductService_CreateProduct_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 102 | in := new(CreateProductRequest) 103 | if err := dec(in); err != nil { 104 | return nil, err 105 | } 106 | if interceptor == nil { 107 | return srv.(ProductServiceServer).CreateProduct(ctx, in) 108 | } 109 | info := &grpc.UnaryServerInfo{ 110 | Server: srv, 111 | FullMethod: "/product.ProductService/CreateProduct", 112 | } 113 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 114 | return srv.(ProductServiceServer).CreateProduct(ctx, req.(*CreateProductRequest)) 115 | } 116 | return interceptor(ctx, in, info, handler) 117 | } 118 | 119 | func _ProductService_FindOne_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 120 | in := new(FindOneRequest) 121 | if err := dec(in); err != nil { 122 | return nil, err 123 | } 124 | if interceptor == nil { 125 | return srv.(ProductServiceServer).FindOne(ctx, in) 126 | } 127 | info := &grpc.UnaryServerInfo{ 128 | Server: srv, 129 | FullMethod: "/product.ProductService/FindOne", 130 | } 131 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 132 | return srv.(ProductServiceServer).FindOne(ctx, req.(*FindOneRequest)) 133 | } 134 | return interceptor(ctx, in, info, handler) 135 | } 136 | 137 | func _ProductService_DecreaseStock_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 138 | in := new(DecreaseStockRequest) 139 | if err := dec(in); err != nil { 140 | return nil, err 141 | } 142 | if interceptor == nil { 143 | return srv.(ProductServiceServer).DecreaseStock(ctx, in) 144 | } 145 | info := &grpc.UnaryServerInfo{ 146 | Server: srv, 147 | FullMethod: "/product.ProductService/DecreaseStock", 148 | } 149 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 150 | return srv.(ProductServiceServer).DecreaseStock(ctx, req.(*DecreaseStockRequest)) 151 | } 152 | return interceptor(ctx, in, info, handler) 153 | } 154 | 155 | // ProductService_ServiceDesc is the grpc.ServiceDesc for ProductService service. 156 | // It's only intended for direct use with grpc.RegisterService, 157 | // and not to be introspected or modified (even as a copy) 158 | var ProductService_ServiceDesc = grpc.ServiceDesc{ 159 | ServiceName: "product.ProductService", 160 | HandlerType: (*ProductServiceServer)(nil), 161 | Methods: []grpc.MethodDesc{ 162 | { 163 | MethodName: "CreateProduct", 164 | Handler: _ProductService_CreateProduct_Handler, 165 | }, 166 | { 167 | MethodName: "FindOne", 168 | Handler: _ProductService_FindOne_Handler, 169 | }, 170 | { 171 | MethodName: "DecreaseStock", 172 | Handler: _ProductService_DecreaseStock_Handler, 173 | }, 174 | }, 175 | Streams: []grpc.StreamDesc{}, 176 | Metadata: "pkg/pb/product.proto", 177 | } 178 | -------------------------------------------------------------------------------- /auth-svc/pkg/pb/auth_grpc.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go-grpc. DO NOT EDIT. 2 | // versions: 3 | // - protoc-gen-go-grpc v1.2.0 4 | // - protoc v4.22.4 5 | // source: pkg/pb/auth.proto 6 | 7 | package pb 8 | 9 | import ( 10 | context "context" 11 | grpc "google.golang.org/grpc" 12 | codes "google.golang.org/grpc/codes" 13 | status "google.golang.org/grpc/status" 14 | ) 15 | 16 | // This is a compile-time assertion to ensure that this generated file 17 | // is compatible with the grpc package it is being compiled against. 18 | // Requires gRPC-Go v1.32.0 or later. 19 | const _ = grpc.SupportPackageIsVersion7 20 | 21 | // AuthServiceClient is the client API for AuthService service. 22 | // 23 | // 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. 24 | type AuthServiceClient interface { 25 | Register(ctx context.Context, in *RegisterRequest, opts ...grpc.CallOption) (*RegisterResponse, error) 26 | Login(ctx context.Context, in *LoginRequest, opts ...grpc.CallOption) (*LoginResponse, error) 27 | Validate(ctx context.Context, in *ValidateRequest, opts ...grpc.CallOption) (*ValidateResponse, error) 28 | AdminLogin(ctx context.Context, in *LoginRequest, opts ...grpc.CallOption) (*LoginResponse, error) 29 | } 30 | 31 | type authServiceClient struct { 32 | cc grpc.ClientConnInterface 33 | } 34 | 35 | func NewAuthServiceClient(cc grpc.ClientConnInterface) AuthServiceClient { 36 | return &authServiceClient{cc} 37 | } 38 | 39 | func (c *authServiceClient) Register(ctx context.Context, in *RegisterRequest, opts ...grpc.CallOption) (*RegisterResponse, error) { 40 | out := new(RegisterResponse) 41 | err := c.cc.Invoke(ctx, "/auth.AuthService/Register", in, out, opts...) 42 | if err != nil { 43 | return nil, err 44 | } 45 | return out, nil 46 | } 47 | 48 | func (c *authServiceClient) Login(ctx context.Context, in *LoginRequest, opts ...grpc.CallOption) (*LoginResponse, error) { 49 | out := new(LoginResponse) 50 | err := c.cc.Invoke(ctx, "/auth.AuthService/Login", in, out, opts...) 51 | if err != nil { 52 | return nil, err 53 | } 54 | return out, nil 55 | } 56 | 57 | func (c *authServiceClient) Validate(ctx context.Context, in *ValidateRequest, opts ...grpc.CallOption) (*ValidateResponse, error) { 58 | out := new(ValidateResponse) 59 | err := c.cc.Invoke(ctx, "/auth.AuthService/Validate", in, out, opts...) 60 | if err != nil { 61 | return nil, err 62 | } 63 | return out, nil 64 | } 65 | 66 | func (c *authServiceClient) AdminLogin(ctx context.Context, in *LoginRequest, opts ...grpc.CallOption) (*LoginResponse, error) { 67 | out := new(LoginResponse) 68 | err := c.cc.Invoke(ctx, "/auth.AuthService/AdminLogin", in, out, opts...) 69 | if err != nil { 70 | return nil, err 71 | } 72 | return out, nil 73 | } 74 | 75 | // AuthServiceServer is the server API for AuthService service. 76 | // All implementations must embed UnimplementedAuthServiceServer 77 | // for forward compatibility 78 | type AuthServiceServer interface { 79 | Register(context.Context, *RegisterRequest) (*RegisterResponse, error) 80 | Login(context.Context, *LoginRequest) (*LoginResponse, error) 81 | Validate(context.Context, *ValidateRequest) (*ValidateResponse, error) 82 | AdminLogin(context.Context, *LoginRequest) (*LoginResponse, error) 83 | mustEmbedUnimplementedAuthServiceServer() 84 | } 85 | 86 | // UnimplementedAuthServiceServer must be embedded to have forward compatible implementations. 87 | type UnimplementedAuthServiceServer struct { 88 | } 89 | 90 | func (UnimplementedAuthServiceServer) Register(context.Context, *RegisterRequest) (*RegisterResponse, error) { 91 | return nil, status.Errorf(codes.Unimplemented, "method Register not implemented") 92 | } 93 | func (UnimplementedAuthServiceServer) Login(context.Context, *LoginRequest) (*LoginResponse, error) { 94 | return nil, status.Errorf(codes.Unimplemented, "method Login not implemented") 95 | } 96 | func (UnimplementedAuthServiceServer) Validate(context.Context, *ValidateRequest) (*ValidateResponse, error) { 97 | return nil, status.Errorf(codes.Unimplemented, "method Validate not implemented") 98 | } 99 | func (UnimplementedAuthServiceServer) AdminLogin(context.Context, *LoginRequest) (*LoginResponse, error) { 100 | return nil, status.Errorf(codes.Unimplemented, "method AdminLogin not implemented") 101 | } 102 | func (UnimplementedAuthServiceServer) mustEmbedUnimplementedAuthServiceServer() {} 103 | 104 | // UnsafeAuthServiceServer may be embedded to opt out of forward compatibility for this service. 105 | // Use of this interface is not recommended, as added methods to AuthServiceServer will 106 | // result in compilation errors. 107 | type UnsafeAuthServiceServer interface { 108 | mustEmbedUnimplementedAuthServiceServer() 109 | } 110 | 111 | func RegisterAuthServiceServer(s grpc.ServiceRegistrar, srv AuthServiceServer) { 112 | s.RegisterService(&AuthService_ServiceDesc, srv) 113 | } 114 | 115 | func _AuthService_Register_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 116 | in := new(RegisterRequest) 117 | if err := dec(in); err != nil { 118 | return nil, err 119 | } 120 | if interceptor == nil { 121 | return srv.(AuthServiceServer).Register(ctx, in) 122 | } 123 | info := &grpc.UnaryServerInfo{ 124 | Server: srv, 125 | FullMethod: "/auth.AuthService/Register", 126 | } 127 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 128 | return srv.(AuthServiceServer).Register(ctx, req.(*RegisterRequest)) 129 | } 130 | return interceptor(ctx, in, info, handler) 131 | } 132 | 133 | func _AuthService_Login_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 134 | in := new(LoginRequest) 135 | if err := dec(in); err != nil { 136 | return nil, err 137 | } 138 | if interceptor == nil { 139 | return srv.(AuthServiceServer).Login(ctx, in) 140 | } 141 | info := &grpc.UnaryServerInfo{ 142 | Server: srv, 143 | FullMethod: "/auth.AuthService/Login", 144 | } 145 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 146 | return srv.(AuthServiceServer).Login(ctx, req.(*LoginRequest)) 147 | } 148 | return interceptor(ctx, in, info, handler) 149 | } 150 | 151 | func _AuthService_Validate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 152 | in := new(ValidateRequest) 153 | if err := dec(in); err != nil { 154 | return nil, err 155 | } 156 | if interceptor == nil { 157 | return srv.(AuthServiceServer).Validate(ctx, in) 158 | } 159 | info := &grpc.UnaryServerInfo{ 160 | Server: srv, 161 | FullMethod: "/auth.AuthService/Validate", 162 | } 163 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 164 | return srv.(AuthServiceServer).Validate(ctx, req.(*ValidateRequest)) 165 | } 166 | return interceptor(ctx, in, info, handler) 167 | } 168 | 169 | func _AuthService_AdminLogin_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 170 | in := new(LoginRequest) 171 | if err := dec(in); err != nil { 172 | return nil, err 173 | } 174 | if interceptor == nil { 175 | return srv.(AuthServiceServer).AdminLogin(ctx, in) 176 | } 177 | info := &grpc.UnaryServerInfo{ 178 | Server: srv, 179 | FullMethod: "/auth.AuthService/AdminLogin", 180 | } 181 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 182 | return srv.(AuthServiceServer).AdminLogin(ctx, req.(*LoginRequest)) 183 | } 184 | return interceptor(ctx, in, info, handler) 185 | } 186 | 187 | // AuthService_ServiceDesc is the grpc.ServiceDesc for AuthService service. 188 | // It's only intended for direct use with grpc.RegisterService, 189 | // and not to be introspected or modified (even as a copy) 190 | var AuthService_ServiceDesc = grpc.ServiceDesc{ 191 | ServiceName: "auth.AuthService", 192 | HandlerType: (*AuthServiceServer)(nil), 193 | Methods: []grpc.MethodDesc{ 194 | { 195 | MethodName: "Register", 196 | Handler: _AuthService_Register_Handler, 197 | }, 198 | { 199 | MethodName: "Login", 200 | Handler: _AuthService_Login_Handler, 201 | }, 202 | { 203 | MethodName: "Validate", 204 | Handler: _AuthService_Validate_Handler, 205 | }, 206 | { 207 | MethodName: "AdminLogin", 208 | Handler: _AuthService_AdminLogin_Handler, 209 | }, 210 | }, 211 | Streams: []grpc.StreamDesc{}, 212 | Metadata: "pkg/pb/auth.proto", 213 | } 214 | -------------------------------------------------------------------------------- /product-svc/pkg/pb/product_grpc.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go-grpc. DO NOT EDIT. 2 | // versions: 3 | // - protoc-gen-go-grpc v1.2.0 4 | // - protoc v4.22.4 5 | // source: pkg/pb/product.proto 6 | 7 | package pb 8 | 9 | import ( 10 | context "context" 11 | grpc "google.golang.org/grpc" 12 | codes "google.golang.org/grpc/codes" 13 | status "google.golang.org/grpc/status" 14 | ) 15 | 16 | // This is a compile-time assertion to ensure that this generated file 17 | // is compatible with the grpc package it is being compiled against. 18 | // Requires gRPC-Go v1.32.0 or later. 19 | const _ = grpc.SupportPackageIsVersion7 20 | 21 | // ProductServiceClient is the client API for ProductService service. 22 | // 23 | // 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. 24 | type ProductServiceClient interface { 25 | CreateProduct(ctx context.Context, in *CreateProductRequest, opts ...grpc.CallOption) (*CreateProductResponse, error) 26 | FindOne(ctx context.Context, in *FindOneRequest, opts ...grpc.CallOption) (*FindOneResponse, error) 27 | FindAll(ctx context.Context, in *FindAllRequest, opts ...grpc.CallOption) (*FindAllResponse, error) 28 | DecreaseStock(ctx context.Context, in *DecreaseStockRequest, opts ...grpc.CallOption) (*DecreaseStockResponse, error) 29 | } 30 | 31 | type productServiceClient struct { 32 | cc grpc.ClientConnInterface 33 | } 34 | 35 | func NewProductServiceClient(cc grpc.ClientConnInterface) ProductServiceClient { 36 | return &productServiceClient{cc} 37 | } 38 | 39 | func (c *productServiceClient) CreateProduct(ctx context.Context, in *CreateProductRequest, opts ...grpc.CallOption) (*CreateProductResponse, error) { 40 | out := new(CreateProductResponse) 41 | err := c.cc.Invoke(ctx, "/product.ProductService/CreateProduct", in, out, opts...) 42 | if err != nil { 43 | return nil, err 44 | } 45 | return out, nil 46 | } 47 | 48 | func (c *productServiceClient) FindOne(ctx context.Context, in *FindOneRequest, opts ...grpc.CallOption) (*FindOneResponse, error) { 49 | out := new(FindOneResponse) 50 | err := c.cc.Invoke(ctx, "/product.ProductService/FindOne", in, out, opts...) 51 | if err != nil { 52 | return nil, err 53 | } 54 | return out, nil 55 | } 56 | 57 | func (c *productServiceClient) FindAll(ctx context.Context, in *FindAllRequest, opts ...grpc.CallOption) (*FindAllResponse, error) { 58 | out := new(FindAllResponse) 59 | err := c.cc.Invoke(ctx, "/product.ProductService/FindAll", in, out, opts...) 60 | if err != nil { 61 | return nil, err 62 | } 63 | return out, nil 64 | } 65 | 66 | func (c *productServiceClient) DecreaseStock(ctx context.Context, in *DecreaseStockRequest, opts ...grpc.CallOption) (*DecreaseStockResponse, error) { 67 | out := new(DecreaseStockResponse) 68 | err := c.cc.Invoke(ctx, "/product.ProductService/DecreaseStock", in, out, opts...) 69 | if err != nil { 70 | return nil, err 71 | } 72 | return out, nil 73 | } 74 | 75 | // ProductServiceServer is the server API for ProductService service. 76 | // All implementations must embed UnimplementedProductServiceServer 77 | // for forward compatibility 78 | type ProductServiceServer interface { 79 | CreateProduct(context.Context, *CreateProductRequest) (*CreateProductResponse, error) 80 | FindOne(context.Context, *FindOneRequest) (*FindOneResponse, error) 81 | FindAll(context.Context, *FindAllRequest) (*FindAllResponse, error) 82 | DecreaseStock(context.Context, *DecreaseStockRequest) (*DecreaseStockResponse, error) 83 | mustEmbedUnimplementedProductServiceServer() 84 | } 85 | 86 | // UnimplementedProductServiceServer must be embedded to have forward compatible implementations. 87 | type UnimplementedProductServiceServer struct { 88 | } 89 | 90 | func (UnimplementedProductServiceServer) CreateProduct(context.Context, *CreateProductRequest) (*CreateProductResponse, error) { 91 | return nil, status.Errorf(codes.Unimplemented, "method CreateProduct not implemented") 92 | } 93 | func (UnimplementedProductServiceServer) FindOne(context.Context, *FindOneRequest) (*FindOneResponse, error) { 94 | return nil, status.Errorf(codes.Unimplemented, "method FindOne not implemented") 95 | } 96 | func (UnimplementedProductServiceServer) FindAll(context.Context, *FindAllRequest) (*FindAllResponse, error) { 97 | return nil, status.Errorf(codes.Unimplemented, "method FindAll not implemented") 98 | } 99 | func (UnimplementedProductServiceServer) DecreaseStock(context.Context, *DecreaseStockRequest) (*DecreaseStockResponse, error) { 100 | return nil, status.Errorf(codes.Unimplemented, "method DecreaseStock not implemented") 101 | } 102 | func (UnimplementedProductServiceServer) mustEmbedUnimplementedProductServiceServer() {} 103 | 104 | // UnsafeProductServiceServer may be embedded to opt out of forward compatibility for this service. 105 | // Use of this interface is not recommended, as added methods to ProductServiceServer will 106 | // result in compilation errors. 107 | type UnsafeProductServiceServer interface { 108 | mustEmbedUnimplementedProductServiceServer() 109 | } 110 | 111 | func RegisterProductServiceServer(s grpc.ServiceRegistrar, srv ProductServiceServer) { 112 | s.RegisterService(&ProductService_ServiceDesc, srv) 113 | } 114 | 115 | func _ProductService_CreateProduct_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 116 | in := new(CreateProductRequest) 117 | if err := dec(in); err != nil { 118 | return nil, err 119 | } 120 | if interceptor == nil { 121 | return srv.(ProductServiceServer).CreateProduct(ctx, in) 122 | } 123 | info := &grpc.UnaryServerInfo{ 124 | Server: srv, 125 | FullMethod: "/product.ProductService/CreateProduct", 126 | } 127 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 128 | return srv.(ProductServiceServer).CreateProduct(ctx, req.(*CreateProductRequest)) 129 | } 130 | return interceptor(ctx, in, info, handler) 131 | } 132 | 133 | func _ProductService_FindOne_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 134 | in := new(FindOneRequest) 135 | if err := dec(in); err != nil { 136 | return nil, err 137 | } 138 | if interceptor == nil { 139 | return srv.(ProductServiceServer).FindOne(ctx, in) 140 | } 141 | info := &grpc.UnaryServerInfo{ 142 | Server: srv, 143 | FullMethod: "/product.ProductService/FindOne", 144 | } 145 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 146 | return srv.(ProductServiceServer).FindOne(ctx, req.(*FindOneRequest)) 147 | } 148 | return interceptor(ctx, in, info, handler) 149 | } 150 | 151 | func _ProductService_FindAll_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 152 | in := new(FindAllRequest) 153 | if err := dec(in); err != nil { 154 | return nil, err 155 | } 156 | if interceptor == nil { 157 | return srv.(ProductServiceServer).FindAll(ctx, in) 158 | } 159 | info := &grpc.UnaryServerInfo{ 160 | Server: srv, 161 | FullMethod: "/product.ProductService/FindAll", 162 | } 163 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 164 | return srv.(ProductServiceServer).FindAll(ctx, req.(*FindAllRequest)) 165 | } 166 | return interceptor(ctx, in, info, handler) 167 | } 168 | 169 | func _ProductService_DecreaseStock_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 170 | in := new(DecreaseStockRequest) 171 | if err := dec(in); err != nil { 172 | return nil, err 173 | } 174 | if interceptor == nil { 175 | return srv.(ProductServiceServer).DecreaseStock(ctx, in) 176 | } 177 | info := &grpc.UnaryServerInfo{ 178 | Server: srv, 179 | FullMethod: "/product.ProductService/DecreaseStock", 180 | } 181 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 182 | return srv.(ProductServiceServer).DecreaseStock(ctx, req.(*DecreaseStockRequest)) 183 | } 184 | return interceptor(ctx, in, info, handler) 185 | } 186 | 187 | // ProductService_ServiceDesc is the grpc.ServiceDesc for ProductService service. 188 | // It's only intended for direct use with grpc.RegisterService, 189 | // and not to be introspected or modified (even as a copy) 190 | var ProductService_ServiceDesc = grpc.ServiceDesc{ 191 | ServiceName: "product.ProductService", 192 | HandlerType: (*ProductServiceServer)(nil), 193 | Methods: []grpc.MethodDesc{ 194 | { 195 | MethodName: "CreateProduct", 196 | Handler: _ProductService_CreateProduct_Handler, 197 | }, 198 | { 199 | MethodName: "FindOne", 200 | Handler: _ProductService_FindOne_Handler, 201 | }, 202 | { 203 | MethodName: "FindAll", 204 | Handler: _ProductService_FindAll_Handler, 205 | }, 206 | { 207 | MethodName: "DecreaseStock", 208 | Handler: _ProductService_DecreaseStock_Handler, 209 | }, 210 | }, 211 | Streams: []grpc.StreamDesc{}, 212 | Metadata: "pkg/pb/product.proto", 213 | } 214 | -------------------------------------------------------------------------------- /order-svc/pkg/pb/order.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go. DO NOT EDIT. 2 | // versions: 3 | // protoc-gen-go v1.28.1 4 | // protoc v4.22.4 5 | // source: pkg/pb/order.proto 6 | 7 | package pb 8 | 9 | import ( 10 | protoreflect "google.golang.org/protobuf/reflect/protoreflect" 11 | protoimpl "google.golang.org/protobuf/runtime/protoimpl" 12 | reflect "reflect" 13 | sync "sync" 14 | ) 15 | 16 | const ( 17 | // Verify that this generated code is sufficiently up-to-date. 18 | _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) 19 | // Verify that runtime/protoimpl is sufficiently up-to-date. 20 | _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) 21 | ) 22 | 23 | type CreateOrderRequest struct { 24 | state protoimpl.MessageState 25 | sizeCache protoimpl.SizeCache 26 | unknownFields protoimpl.UnknownFields 27 | 28 | ProductId int64 `protobuf:"varint,1,opt,name=productId,proto3" json:"productId,omitempty"` 29 | Quantity int64 `protobuf:"varint,2,opt,name=quantity,proto3" json:"quantity,omitempty"` 30 | UserId int64 `protobuf:"varint,3,opt,name=userId,proto3" json:"userId,omitempty"` 31 | } 32 | 33 | func (x *CreateOrderRequest) Reset() { 34 | *x = CreateOrderRequest{} 35 | if protoimpl.UnsafeEnabled { 36 | mi := &file_pkg_pb_order_proto_msgTypes[0] 37 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 38 | ms.StoreMessageInfo(mi) 39 | } 40 | } 41 | 42 | func (x *CreateOrderRequest) String() string { 43 | return protoimpl.X.MessageStringOf(x) 44 | } 45 | 46 | func (*CreateOrderRequest) ProtoMessage() {} 47 | 48 | func (x *CreateOrderRequest) ProtoReflect() protoreflect.Message { 49 | mi := &file_pkg_pb_order_proto_msgTypes[0] 50 | if protoimpl.UnsafeEnabled && x != nil { 51 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 52 | if ms.LoadMessageInfo() == nil { 53 | ms.StoreMessageInfo(mi) 54 | } 55 | return ms 56 | } 57 | return mi.MessageOf(x) 58 | } 59 | 60 | // Deprecated: Use CreateOrderRequest.ProtoReflect.Descriptor instead. 61 | func (*CreateOrderRequest) Descriptor() ([]byte, []int) { 62 | return file_pkg_pb_order_proto_rawDescGZIP(), []int{0} 63 | } 64 | 65 | func (x *CreateOrderRequest) GetProductId() int64 { 66 | if x != nil { 67 | return x.ProductId 68 | } 69 | return 0 70 | } 71 | 72 | func (x *CreateOrderRequest) GetQuantity() int64 { 73 | if x != nil { 74 | return x.Quantity 75 | } 76 | return 0 77 | } 78 | 79 | func (x *CreateOrderRequest) GetUserId() int64 { 80 | if x != nil { 81 | return x.UserId 82 | } 83 | return 0 84 | } 85 | 86 | type CreateOrderResponse struct { 87 | state protoimpl.MessageState 88 | sizeCache protoimpl.SizeCache 89 | unknownFields protoimpl.UnknownFields 90 | 91 | Status int64 `protobuf:"varint,1,opt,name=status,proto3" json:"status,omitempty"` 92 | Error string `protobuf:"bytes,2,opt,name=error,proto3" json:"error,omitempty"` 93 | Id int64 `protobuf:"varint,3,opt,name=id,proto3" json:"id,omitempty"` 94 | } 95 | 96 | func (x *CreateOrderResponse) Reset() { 97 | *x = CreateOrderResponse{} 98 | if protoimpl.UnsafeEnabled { 99 | mi := &file_pkg_pb_order_proto_msgTypes[1] 100 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 101 | ms.StoreMessageInfo(mi) 102 | } 103 | } 104 | 105 | func (x *CreateOrderResponse) String() string { 106 | return protoimpl.X.MessageStringOf(x) 107 | } 108 | 109 | func (*CreateOrderResponse) ProtoMessage() {} 110 | 111 | func (x *CreateOrderResponse) ProtoReflect() protoreflect.Message { 112 | mi := &file_pkg_pb_order_proto_msgTypes[1] 113 | if protoimpl.UnsafeEnabled && x != nil { 114 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 115 | if ms.LoadMessageInfo() == nil { 116 | ms.StoreMessageInfo(mi) 117 | } 118 | return ms 119 | } 120 | return mi.MessageOf(x) 121 | } 122 | 123 | // Deprecated: Use CreateOrderResponse.ProtoReflect.Descriptor instead. 124 | func (*CreateOrderResponse) Descriptor() ([]byte, []int) { 125 | return file_pkg_pb_order_proto_rawDescGZIP(), []int{1} 126 | } 127 | 128 | func (x *CreateOrderResponse) GetStatus() int64 { 129 | if x != nil { 130 | return x.Status 131 | } 132 | return 0 133 | } 134 | 135 | func (x *CreateOrderResponse) GetError() string { 136 | if x != nil { 137 | return x.Error 138 | } 139 | return "" 140 | } 141 | 142 | func (x *CreateOrderResponse) GetId() int64 { 143 | if x != nil { 144 | return x.Id 145 | } 146 | return 0 147 | } 148 | 149 | var File_pkg_pb_order_proto protoreflect.FileDescriptor 150 | 151 | var file_pkg_pb_order_proto_rawDesc = []byte{ 152 | 0x0a, 0x12, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x62, 0x2f, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x2e, 0x70, 153 | 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x05, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x22, 0x66, 0x0a, 0x12, 0x43, 154 | 0x72, 0x65, 0x61, 0x74, 0x65, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 155 | 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x49, 0x64, 0x18, 0x01, 156 | 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x49, 0x64, 0x12, 157 | 0x1a, 0x0a, 0x08, 0x71, 0x75, 0x61, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 158 | 0x03, 0x52, 0x08, 0x71, 0x75, 0x61, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x12, 0x16, 0x0a, 0x06, 0x75, 159 | 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x75, 0x73, 0x65, 160 | 0x72, 0x49, 0x64, 0x22, 0x53, 0x0a, 0x13, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4f, 0x72, 0x64, 161 | 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 162 | 0x61, 0x74, 0x75, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 163 | 0x75, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 164 | 0x09, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x03, 165 | 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x32, 0x54, 0x0a, 0x0c, 0x4f, 0x72, 0x64, 0x65, 166 | 0x72, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x44, 0x0a, 0x0b, 0x43, 0x72, 0x65, 0x61, 167 | 0x74, 0x65, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x12, 0x19, 0x2e, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x2e, 168 | 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 169 | 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 170 | 0x65, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x0a, 171 | 0x5a, 0x08, 0x2e, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 172 | 0x6f, 0x33, 173 | } 174 | 175 | var ( 176 | file_pkg_pb_order_proto_rawDescOnce sync.Once 177 | file_pkg_pb_order_proto_rawDescData = file_pkg_pb_order_proto_rawDesc 178 | ) 179 | 180 | func file_pkg_pb_order_proto_rawDescGZIP() []byte { 181 | file_pkg_pb_order_proto_rawDescOnce.Do(func() { 182 | file_pkg_pb_order_proto_rawDescData = protoimpl.X.CompressGZIP(file_pkg_pb_order_proto_rawDescData) 183 | }) 184 | return file_pkg_pb_order_proto_rawDescData 185 | } 186 | 187 | var file_pkg_pb_order_proto_msgTypes = make([]protoimpl.MessageInfo, 2) 188 | var file_pkg_pb_order_proto_goTypes = []interface{}{ 189 | (*CreateOrderRequest)(nil), // 0: order.CreateOrderRequest 190 | (*CreateOrderResponse)(nil), // 1: order.CreateOrderResponse 191 | } 192 | var file_pkg_pb_order_proto_depIdxs = []int32{ 193 | 0, // 0: order.OrderService.CreateOrder:input_type -> order.CreateOrderRequest 194 | 1, // 1: order.OrderService.CreateOrder:output_type -> order.CreateOrderResponse 195 | 1, // [1:2] is the sub-list for method output_type 196 | 0, // [0:1] is the sub-list for method input_type 197 | 0, // [0:0] is the sub-list for extension type_name 198 | 0, // [0:0] is the sub-list for extension extendee 199 | 0, // [0:0] is the sub-list for field type_name 200 | } 201 | 202 | func init() { file_pkg_pb_order_proto_init() } 203 | func file_pkg_pb_order_proto_init() { 204 | if File_pkg_pb_order_proto != nil { 205 | return 206 | } 207 | if !protoimpl.UnsafeEnabled { 208 | file_pkg_pb_order_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { 209 | switch v := v.(*CreateOrderRequest); i { 210 | case 0: 211 | return &v.state 212 | case 1: 213 | return &v.sizeCache 214 | case 2: 215 | return &v.unknownFields 216 | default: 217 | return nil 218 | } 219 | } 220 | file_pkg_pb_order_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { 221 | switch v := v.(*CreateOrderResponse); i { 222 | case 0: 223 | return &v.state 224 | case 1: 225 | return &v.sizeCache 226 | case 2: 227 | return &v.unknownFields 228 | default: 229 | return nil 230 | } 231 | } 232 | } 233 | type x struct{} 234 | out := protoimpl.TypeBuilder{ 235 | File: protoimpl.DescBuilder{ 236 | GoPackagePath: reflect.TypeOf(x{}).PkgPath(), 237 | RawDescriptor: file_pkg_pb_order_proto_rawDesc, 238 | NumEnums: 0, 239 | NumMessages: 2, 240 | NumExtensions: 0, 241 | NumServices: 1, 242 | }, 243 | GoTypes: file_pkg_pb_order_proto_goTypes, 244 | DependencyIndexes: file_pkg_pb_order_proto_depIdxs, 245 | MessageInfos: file_pkg_pb_order_proto_msgTypes, 246 | }.Build() 247 | File_pkg_pb_order_proto = out.File 248 | file_pkg_pb_order_proto_rawDesc = nil 249 | file_pkg_pb_order_proto_goTypes = nil 250 | file_pkg_pb_order_proto_depIdxs = nil 251 | } 252 | -------------------------------------------------------------------------------- /api-gateway/pkg/order/pb/order.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go. DO NOT EDIT. 2 | // versions: 3 | // protoc-gen-go v1.28.1 4 | // protoc v4.22.4 5 | // source: pkg/order/pb/order.proto 6 | 7 | package pb 8 | 9 | import ( 10 | protoreflect "google.golang.org/protobuf/reflect/protoreflect" 11 | protoimpl "google.golang.org/protobuf/runtime/protoimpl" 12 | reflect "reflect" 13 | sync "sync" 14 | ) 15 | 16 | const ( 17 | // Verify that this generated code is sufficiently up-to-date. 18 | _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) 19 | // Verify that runtime/protoimpl is sufficiently up-to-date. 20 | _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) 21 | ) 22 | 23 | // CreateOrderRequest is a message that carries the necessary data to create an order. 24 | type CreateOrderRequest struct { 25 | state protoimpl.MessageState 26 | sizeCache protoimpl.SizeCache 27 | unknownFields protoimpl.UnknownFields 28 | 29 | ProductID int64 `protobuf:"varint,1,opt,name=productID,proto3" json:"productID,omitempty"` 30 | Quantity int64 `protobuf:"varint,2,opt,name=quantity,proto3" json:"quantity,omitempty"` 31 | UserId int64 `protobuf:"varint,3,opt,name=userId,proto3" json:"userId,omitempty"` 32 | } 33 | 34 | func (x *CreateOrderRequest) Reset() { 35 | *x = CreateOrderRequest{} 36 | if protoimpl.UnsafeEnabled { 37 | mi := &file_pkg_order_pb_order_proto_msgTypes[0] 38 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 39 | ms.StoreMessageInfo(mi) 40 | } 41 | } 42 | 43 | func (x *CreateOrderRequest) String() string { 44 | return protoimpl.X.MessageStringOf(x) 45 | } 46 | 47 | func (*CreateOrderRequest) ProtoMessage() {} 48 | 49 | func (x *CreateOrderRequest) ProtoReflect() protoreflect.Message { 50 | mi := &file_pkg_order_pb_order_proto_msgTypes[0] 51 | if protoimpl.UnsafeEnabled && x != nil { 52 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 53 | if ms.LoadMessageInfo() == nil { 54 | ms.StoreMessageInfo(mi) 55 | } 56 | return ms 57 | } 58 | return mi.MessageOf(x) 59 | } 60 | 61 | // Deprecated: Use CreateOrderRequest.ProtoReflect.Descriptor instead. 62 | func (*CreateOrderRequest) Descriptor() ([]byte, []int) { 63 | return file_pkg_order_pb_order_proto_rawDescGZIP(), []int{0} 64 | } 65 | 66 | func (x *CreateOrderRequest) GetProductID() int64 { 67 | if x != nil { 68 | return x.ProductID 69 | } 70 | return 0 71 | } 72 | 73 | func (x *CreateOrderRequest) GetQuantity() int64 { 74 | if x != nil { 75 | return x.Quantity 76 | } 77 | return 0 78 | } 79 | 80 | func (x *CreateOrderRequest) GetUserId() int64 { 81 | if x != nil { 82 | return x.UserId 83 | } 84 | return 0 85 | } 86 | 87 | // CreateOrderResponse is a message that carries the response after attempting to create an order. 88 | type CreateOrderResponse struct { 89 | state protoimpl.MessageState 90 | sizeCache protoimpl.SizeCache 91 | unknownFields protoimpl.UnknownFields 92 | 93 | Status int64 `protobuf:"varint,1,opt,name=status,proto3" json:"status,omitempty"` 94 | Error string `protobuf:"bytes,2,opt,name=error,proto3" json:"error,omitempty"` 95 | Id int64 `protobuf:"varint,3,opt,name=id,proto3" json:"id,omitempty"` 96 | } 97 | 98 | func (x *CreateOrderResponse) Reset() { 99 | *x = CreateOrderResponse{} 100 | if protoimpl.UnsafeEnabled { 101 | mi := &file_pkg_order_pb_order_proto_msgTypes[1] 102 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 103 | ms.StoreMessageInfo(mi) 104 | } 105 | } 106 | 107 | func (x *CreateOrderResponse) String() string { 108 | return protoimpl.X.MessageStringOf(x) 109 | } 110 | 111 | func (*CreateOrderResponse) ProtoMessage() {} 112 | 113 | func (x *CreateOrderResponse) ProtoReflect() protoreflect.Message { 114 | mi := &file_pkg_order_pb_order_proto_msgTypes[1] 115 | if protoimpl.UnsafeEnabled && x != nil { 116 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 117 | if ms.LoadMessageInfo() == nil { 118 | ms.StoreMessageInfo(mi) 119 | } 120 | return ms 121 | } 122 | return mi.MessageOf(x) 123 | } 124 | 125 | // Deprecated: Use CreateOrderResponse.ProtoReflect.Descriptor instead. 126 | func (*CreateOrderResponse) Descriptor() ([]byte, []int) { 127 | return file_pkg_order_pb_order_proto_rawDescGZIP(), []int{1} 128 | } 129 | 130 | func (x *CreateOrderResponse) GetStatus() int64 { 131 | if x != nil { 132 | return x.Status 133 | } 134 | return 0 135 | } 136 | 137 | func (x *CreateOrderResponse) GetError() string { 138 | if x != nil { 139 | return x.Error 140 | } 141 | return "" 142 | } 143 | 144 | func (x *CreateOrderResponse) GetId() int64 { 145 | if x != nil { 146 | return x.Id 147 | } 148 | return 0 149 | } 150 | 151 | var File_pkg_order_pb_order_proto protoreflect.FileDescriptor 152 | 153 | var file_pkg_order_pb_order_proto_rawDesc = []byte{ 154 | 0x0a, 0x18, 0x70, 0x6b, 0x67, 0x2f, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x2f, 0x70, 0x62, 0x2f, 0x6f, 155 | 0x72, 0x64, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x05, 0x6f, 0x72, 0x64, 0x65, 156 | 0x72, 0x22, 0x66, 0x0a, 0x12, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4f, 0x72, 0x64, 0x65, 0x72, 157 | 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x70, 0x72, 0x6f, 0x64, 0x75, 158 | 0x63, 0x74, 0x49, 0x44, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x70, 0x72, 0x6f, 0x64, 159 | 0x75, 0x63, 0x74, 0x49, 0x44, 0x12, 0x1a, 0x0a, 0x08, 0x71, 0x75, 0x61, 0x6e, 0x74, 0x69, 0x74, 160 | 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x71, 0x75, 0x61, 0x6e, 0x74, 0x69, 0x74, 161 | 0x79, 0x12, 0x16, 0x0a, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 162 | 0x03, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x22, 0x53, 0x0a, 0x13, 0x43, 0x72, 0x65, 163 | 0x61, 0x74, 0x65, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 164 | 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 165 | 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 166 | 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x12, 0x0e, 167 | 0x0a, 0x02, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x32, 0x56, 168 | 0x0a, 0x0c, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x46, 169 | 0x0a, 0x0b, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x12, 0x19, 0x2e, 170 | 0x6f, 0x72, 0x64, 0x65, 0x72, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4f, 0x72, 0x64, 0x65, 171 | 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x6f, 0x72, 0x64, 0x65, 0x72, 172 | 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 173 | 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x10, 0x5a, 0x0e, 0x2e, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 174 | 0x6f, 0x72, 0x64, 0x65, 0x72, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 175 | } 176 | 177 | var ( 178 | file_pkg_order_pb_order_proto_rawDescOnce sync.Once 179 | file_pkg_order_pb_order_proto_rawDescData = file_pkg_order_pb_order_proto_rawDesc 180 | ) 181 | 182 | func file_pkg_order_pb_order_proto_rawDescGZIP() []byte { 183 | file_pkg_order_pb_order_proto_rawDescOnce.Do(func() { 184 | file_pkg_order_pb_order_proto_rawDescData = protoimpl.X.CompressGZIP(file_pkg_order_pb_order_proto_rawDescData) 185 | }) 186 | return file_pkg_order_pb_order_proto_rawDescData 187 | } 188 | 189 | var file_pkg_order_pb_order_proto_msgTypes = make([]protoimpl.MessageInfo, 2) 190 | var file_pkg_order_pb_order_proto_goTypes = []interface{}{ 191 | (*CreateOrderRequest)(nil), // 0: order.CreateOrderRequest 192 | (*CreateOrderResponse)(nil), // 1: order.CreateOrderResponse 193 | } 194 | var file_pkg_order_pb_order_proto_depIdxs = []int32{ 195 | 0, // 0: order.OrderService.CreateOrder:input_type -> order.CreateOrderRequest 196 | 1, // 1: order.OrderService.CreateOrder:output_type -> order.CreateOrderResponse 197 | 1, // [1:2] is the sub-list for method output_type 198 | 0, // [0:1] is the sub-list for method input_type 199 | 0, // [0:0] is the sub-list for extension type_name 200 | 0, // [0:0] is the sub-list for extension extendee 201 | 0, // [0:0] is the sub-list for field type_name 202 | } 203 | 204 | func init() { file_pkg_order_pb_order_proto_init() } 205 | func file_pkg_order_pb_order_proto_init() { 206 | if File_pkg_order_pb_order_proto != nil { 207 | return 208 | } 209 | if !protoimpl.UnsafeEnabled { 210 | file_pkg_order_pb_order_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { 211 | switch v := v.(*CreateOrderRequest); i { 212 | case 0: 213 | return &v.state 214 | case 1: 215 | return &v.sizeCache 216 | case 2: 217 | return &v.unknownFields 218 | default: 219 | return nil 220 | } 221 | } 222 | file_pkg_order_pb_order_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { 223 | switch v := v.(*CreateOrderResponse); i { 224 | case 0: 225 | return &v.state 226 | case 1: 227 | return &v.sizeCache 228 | case 2: 229 | return &v.unknownFields 230 | default: 231 | return nil 232 | } 233 | } 234 | } 235 | type x struct{} 236 | out := protoimpl.TypeBuilder{ 237 | File: protoimpl.DescBuilder{ 238 | GoPackagePath: reflect.TypeOf(x{}).PkgPath(), 239 | RawDescriptor: file_pkg_order_pb_order_proto_rawDesc, 240 | NumEnums: 0, 241 | NumMessages: 2, 242 | NumExtensions: 0, 243 | NumServices: 1, 244 | }, 245 | GoTypes: file_pkg_order_pb_order_proto_goTypes, 246 | DependencyIndexes: file_pkg_order_pb_order_proto_depIdxs, 247 | MessageInfos: file_pkg_order_pb_order_proto_msgTypes, 248 | }.Build() 249 | File_pkg_order_pb_order_proto = out.File 250 | file_pkg_order_pb_order_proto_rawDesc = nil 251 | file_pkg_order_pb_order_proto_goTypes = nil 252 | file_pkg_order_pb_order_proto_depIdxs = nil 253 | } 254 | -------------------------------------------------------------------------------- /api-gateway/pkg/auth/pb/auth_grpc.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go-grpc. DO NOT EDIT. 2 | // versions: 3 | // - protoc-gen-go-grpc v1.2.0 4 | // - protoc v4.22.4 5 | // source: pkg/auth/pb/auth.proto 6 | 7 | package pb 8 | 9 | import ( 10 | context "context" 11 | grpc "google.golang.org/grpc" 12 | codes "google.golang.org/grpc/codes" 13 | status "google.golang.org/grpc/status" 14 | ) 15 | 16 | // This is a compile-time assertion to ensure that this generated file 17 | // is compatible with the grpc package it is being compiled against. 18 | // Requires gRPC-Go v1.32.0 or later. 19 | const _ = grpc.SupportPackageIsVersion7 20 | 21 | // AuthServiceClient is the client API for AuthService service. 22 | // 23 | // 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. 24 | type AuthServiceClient interface { 25 | // Register 26 | // This method allows a user to register by providing their email and password. 27 | // The server will respond with a status indicating the result of the registration 28 | // attempt and an error message if applicable. 29 | Register(ctx context.Context, in *RegisterRequest, opts ...grpc.CallOption) (*RegisterResponse, error) 30 | // Login 31 | // This method allows a user to log in by providing their email and password. 32 | // Upon successful login, the server will respond with a status indicating the 33 | // login result, an error message if applicable, and a token that can be used for 34 | // subsequent authenticated requests. 35 | Login(ctx context.Context, in *LoginRequest, opts ...grpc.CallOption) (*LoginResponse, error) 36 | // Validate 37 | // This method is used to validate a token received from a client. 38 | // The client sends the token in a ValidateRequest, and the server responds with 39 | // a status indicating the validation result, an error message if applicable, and 40 | // the user ID associated with the token if the validation is successful. 41 | Validate(ctx context.Context, in *ValidateRequest, opts ...grpc.CallOption) (*ValidateResponse, error) 42 | AdminLogin(ctx context.Context, in *LoginRequest, opts ...grpc.CallOption) (*LoginResponse, error) 43 | } 44 | 45 | type authServiceClient struct { 46 | cc grpc.ClientConnInterface 47 | } 48 | 49 | func NewAuthServiceClient(cc grpc.ClientConnInterface) AuthServiceClient { 50 | return &authServiceClient{cc} 51 | } 52 | 53 | func (c *authServiceClient) Register(ctx context.Context, in *RegisterRequest, opts ...grpc.CallOption) (*RegisterResponse, error) { 54 | out := new(RegisterResponse) 55 | err := c.cc.Invoke(ctx, "/auth.AuthService/Register", in, out, opts...) 56 | if err != nil { 57 | return nil, err 58 | } 59 | return out, nil 60 | } 61 | 62 | func (c *authServiceClient) Login(ctx context.Context, in *LoginRequest, opts ...grpc.CallOption) (*LoginResponse, error) { 63 | out := new(LoginResponse) 64 | err := c.cc.Invoke(ctx, "/auth.AuthService/Login", in, out, opts...) 65 | if err != nil { 66 | return nil, err 67 | } 68 | return out, nil 69 | } 70 | 71 | func (c *authServiceClient) Validate(ctx context.Context, in *ValidateRequest, opts ...grpc.CallOption) (*ValidateResponse, error) { 72 | out := new(ValidateResponse) 73 | err := c.cc.Invoke(ctx, "/auth.AuthService/Validate", in, out, opts...) 74 | if err != nil { 75 | return nil, err 76 | } 77 | return out, nil 78 | } 79 | 80 | func (c *authServiceClient) AdminLogin(ctx context.Context, in *LoginRequest, opts ...grpc.CallOption) (*LoginResponse, error) { 81 | out := new(LoginResponse) 82 | err := c.cc.Invoke(ctx, "/auth.AuthService/AdminLogin", in, out, opts...) 83 | if err != nil { 84 | return nil, err 85 | } 86 | return out, nil 87 | } 88 | 89 | // AuthServiceServer is the server API for AuthService service. 90 | // All implementations must embed UnimplementedAuthServiceServer 91 | // for forward compatibility 92 | type AuthServiceServer interface { 93 | // Register 94 | // This method allows a user to register by providing their email and password. 95 | // The server will respond with a status indicating the result of the registration 96 | // attempt and an error message if applicable. 97 | Register(context.Context, *RegisterRequest) (*RegisterResponse, error) 98 | // Login 99 | // This method allows a user to log in by providing their email and password. 100 | // Upon successful login, the server will respond with a status indicating the 101 | // login result, an error message if applicable, and a token that can be used for 102 | // subsequent authenticated requests. 103 | Login(context.Context, *LoginRequest) (*LoginResponse, error) 104 | // Validate 105 | // This method is used to validate a token received from a client. 106 | // The client sends the token in a ValidateRequest, and the server responds with 107 | // a status indicating the validation result, an error message if applicable, and 108 | // the user ID associated with the token if the validation is successful. 109 | Validate(context.Context, *ValidateRequest) (*ValidateResponse, error) 110 | AdminLogin(context.Context, *LoginRequest) (*LoginResponse, error) 111 | mustEmbedUnimplementedAuthServiceServer() 112 | } 113 | 114 | // UnimplementedAuthServiceServer must be embedded to have forward compatible implementations. 115 | type UnimplementedAuthServiceServer struct { 116 | } 117 | 118 | func (UnimplementedAuthServiceServer) Register(context.Context, *RegisterRequest) (*RegisterResponse, error) { 119 | return nil, status.Errorf(codes.Unimplemented, "method Register not implemented") 120 | } 121 | func (UnimplementedAuthServiceServer) Login(context.Context, *LoginRequest) (*LoginResponse, error) { 122 | return nil, status.Errorf(codes.Unimplemented, "method Login not implemented") 123 | } 124 | func (UnimplementedAuthServiceServer) Validate(context.Context, *ValidateRequest) (*ValidateResponse, error) { 125 | return nil, status.Errorf(codes.Unimplemented, "method Validate not implemented") 126 | } 127 | func (UnimplementedAuthServiceServer) AdminLogin(context.Context, *LoginRequest) (*LoginResponse, error) { 128 | return nil, status.Errorf(codes.Unimplemented, "method AdminLogin not implemented") 129 | } 130 | func (UnimplementedAuthServiceServer) mustEmbedUnimplementedAuthServiceServer() {} 131 | 132 | // UnsafeAuthServiceServer may be embedded to opt out of forward compatibility for this service. 133 | // Use of this interface is not recommended, as added methods to AuthServiceServer will 134 | // result in compilation errors. 135 | type UnsafeAuthServiceServer interface { 136 | mustEmbedUnimplementedAuthServiceServer() 137 | } 138 | 139 | func RegisterAuthServiceServer(s grpc.ServiceRegistrar, srv AuthServiceServer) { 140 | s.RegisterService(&AuthService_ServiceDesc, srv) 141 | } 142 | 143 | func _AuthService_Register_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 144 | in := new(RegisterRequest) 145 | if err := dec(in); err != nil { 146 | return nil, err 147 | } 148 | if interceptor == nil { 149 | return srv.(AuthServiceServer).Register(ctx, in) 150 | } 151 | info := &grpc.UnaryServerInfo{ 152 | Server: srv, 153 | FullMethod: "/auth.AuthService/Register", 154 | } 155 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 156 | return srv.(AuthServiceServer).Register(ctx, req.(*RegisterRequest)) 157 | } 158 | return interceptor(ctx, in, info, handler) 159 | } 160 | 161 | func _AuthService_Login_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 162 | in := new(LoginRequest) 163 | if err := dec(in); err != nil { 164 | return nil, err 165 | } 166 | if interceptor == nil { 167 | return srv.(AuthServiceServer).Login(ctx, in) 168 | } 169 | info := &grpc.UnaryServerInfo{ 170 | Server: srv, 171 | FullMethod: "/auth.AuthService/Login", 172 | } 173 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 174 | return srv.(AuthServiceServer).Login(ctx, req.(*LoginRequest)) 175 | } 176 | return interceptor(ctx, in, info, handler) 177 | } 178 | 179 | func _AuthService_Validate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 180 | in := new(ValidateRequest) 181 | if err := dec(in); err != nil { 182 | return nil, err 183 | } 184 | if interceptor == nil { 185 | return srv.(AuthServiceServer).Validate(ctx, in) 186 | } 187 | info := &grpc.UnaryServerInfo{ 188 | Server: srv, 189 | FullMethod: "/auth.AuthService/Validate", 190 | } 191 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 192 | return srv.(AuthServiceServer).Validate(ctx, req.(*ValidateRequest)) 193 | } 194 | return interceptor(ctx, in, info, handler) 195 | } 196 | 197 | func _AuthService_AdminLogin_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 198 | in := new(LoginRequest) 199 | if err := dec(in); err != nil { 200 | return nil, err 201 | } 202 | if interceptor == nil { 203 | return srv.(AuthServiceServer).AdminLogin(ctx, in) 204 | } 205 | info := &grpc.UnaryServerInfo{ 206 | Server: srv, 207 | FullMethod: "/auth.AuthService/AdminLogin", 208 | } 209 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 210 | return srv.(AuthServiceServer).AdminLogin(ctx, req.(*LoginRequest)) 211 | } 212 | return interceptor(ctx, in, info, handler) 213 | } 214 | 215 | // AuthService_ServiceDesc is the grpc.ServiceDesc for AuthService service. 216 | // It's only intended for direct use with grpc.RegisterService, 217 | // and not to be introspected or modified (even as a copy) 218 | var AuthService_ServiceDesc = grpc.ServiceDesc{ 219 | ServiceName: "auth.AuthService", 220 | HandlerType: (*AuthServiceServer)(nil), 221 | Methods: []grpc.MethodDesc{ 222 | { 223 | MethodName: "Register", 224 | Handler: _AuthService_Register_Handler, 225 | }, 226 | { 227 | MethodName: "Login", 228 | Handler: _AuthService_Login_Handler, 229 | }, 230 | { 231 | MethodName: "Validate", 232 | Handler: _AuthService_Validate_Handler, 233 | }, 234 | { 235 | MethodName: "AdminLogin", 236 | Handler: _AuthService_AdminLogin_Handler, 237 | }, 238 | }, 239 | Streams: []grpc.StreamDesc{}, 240 | Metadata: "pkg/auth/pb/auth.proto", 241 | } 242 | -------------------------------------------------------------------------------- /api-gateway/pkg/product/pb/product_grpc.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go-grpc. DO NOT EDIT. 2 | // versions: 3 | // - protoc-gen-go-grpc v1.2.0 4 | // - protoc v4.22.4 5 | // source: pkg/product/pb/product.proto 6 | 7 | package pb 8 | 9 | import ( 10 | context "context" 11 | grpc "google.golang.org/grpc" 12 | codes "google.golang.org/grpc/codes" 13 | status "google.golang.org/grpc/status" 14 | ) 15 | 16 | // This is a compile-time assertion to ensure that this generated file 17 | // is compatible with the grpc package it is being compiled against. 18 | // Requires gRPC-Go v1.32.0 or later. 19 | const _ = grpc.SupportPackageIsVersion7 20 | 21 | // ProductServiceClient is the client API for ProductService service. 22 | // 23 | // 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. 24 | type ProductServiceClient interface { 25 | // CreateProduct is an RPC method that allows the creation of a new product. 26 | // It takes a CreateProductRequest message as input, containing the name, 27 | // SKU, stock, and price of the product. The server will respond with a 28 | // CreateProductResponse message, which includes a status indicating the result 29 | // of the product creation, an error message if applicable, and the ID of the newly 30 | // created product. 31 | CreateProduct(ctx context.Context, in *CreateProductRequest, opts ...grpc.CallOption) (*CreateProductResponse, error) 32 | // FindOne is an RPC method that retrieves the details of a specific product 33 | // based on the provided ID. It takes a FindOneRequest message with the ID of 34 | // the product to be found. The server responds with a FindOneResponse message, 35 | // which includes a status indicating the result of the search, an error message 36 | // if applicable, and the data of the found product. 37 | FindOne(ctx context.Context, in *FindOneRequest, opts ...grpc.CallOption) (*FindOneResponse, error) 38 | FindAll(ctx context.Context, in *FindAllRequest, opts ...grpc.CallOption) (*FindAllResponse, error) 39 | // DecreaseStock is an RPC method that decrements the stock of a product when an 40 | // order is placed. It takes a DecreaseStockRequest message with the ID of the 41 | // product and the associated order ID. The server responds with a 42 | // DecreaseStockResponse message, which includes a status indicating the result 43 | // of the stock decrease operation, and an error message if applicable. 44 | DecreaseStock(ctx context.Context, in *DecreaseStockRequest, opts ...grpc.CallOption) (*DecreaseStockResponse, error) 45 | } 46 | 47 | type productServiceClient struct { 48 | cc grpc.ClientConnInterface 49 | } 50 | 51 | func NewProductServiceClient(cc grpc.ClientConnInterface) ProductServiceClient { 52 | return &productServiceClient{cc} 53 | } 54 | 55 | func (c *productServiceClient) CreateProduct(ctx context.Context, in *CreateProductRequest, opts ...grpc.CallOption) (*CreateProductResponse, error) { 56 | out := new(CreateProductResponse) 57 | err := c.cc.Invoke(ctx, "/product.ProductService/CreateProduct", in, out, opts...) 58 | if err != nil { 59 | return nil, err 60 | } 61 | return out, nil 62 | } 63 | 64 | func (c *productServiceClient) FindOne(ctx context.Context, in *FindOneRequest, opts ...grpc.CallOption) (*FindOneResponse, error) { 65 | out := new(FindOneResponse) 66 | err := c.cc.Invoke(ctx, "/product.ProductService/FindOne", in, out, opts...) 67 | if err != nil { 68 | return nil, err 69 | } 70 | return out, nil 71 | } 72 | 73 | func (c *productServiceClient) FindAll(ctx context.Context, in *FindAllRequest, opts ...grpc.CallOption) (*FindAllResponse, error) { 74 | out := new(FindAllResponse) 75 | err := c.cc.Invoke(ctx, "/product.ProductService/FindAll", in, out, opts...) 76 | if err != nil { 77 | return nil, err 78 | } 79 | return out, nil 80 | } 81 | 82 | func (c *productServiceClient) DecreaseStock(ctx context.Context, in *DecreaseStockRequest, opts ...grpc.CallOption) (*DecreaseStockResponse, error) { 83 | out := new(DecreaseStockResponse) 84 | err := c.cc.Invoke(ctx, "/product.ProductService/DecreaseStock", in, out, opts...) 85 | if err != nil { 86 | return nil, err 87 | } 88 | return out, nil 89 | } 90 | 91 | // ProductServiceServer is the server API for ProductService service. 92 | // All implementations must embed UnimplementedProductServiceServer 93 | // for forward compatibility 94 | type ProductServiceServer interface { 95 | // CreateProduct is an RPC method that allows the creation of a new product. 96 | // It takes a CreateProductRequest message as input, containing the name, 97 | // SKU, stock, and price of the product. The server will respond with a 98 | // CreateProductResponse message, which includes a status indicating the result 99 | // of the product creation, an error message if applicable, and the ID of the newly 100 | // created product. 101 | CreateProduct(context.Context, *CreateProductRequest) (*CreateProductResponse, error) 102 | // FindOne is an RPC method that retrieves the details of a specific product 103 | // based on the provided ID. It takes a FindOneRequest message with the ID of 104 | // the product to be found. The server responds with a FindOneResponse message, 105 | // which includes a status indicating the result of the search, an error message 106 | // if applicable, and the data of the found product. 107 | FindOne(context.Context, *FindOneRequest) (*FindOneResponse, error) 108 | FindAll(context.Context, *FindAllRequest) (*FindAllResponse, error) 109 | // DecreaseStock is an RPC method that decrements the stock of a product when an 110 | // order is placed. It takes a DecreaseStockRequest message with the ID of the 111 | // product and the associated order ID. The server responds with a 112 | // DecreaseStockResponse message, which includes a status indicating the result 113 | // of the stock decrease operation, and an error message if applicable. 114 | DecreaseStock(context.Context, *DecreaseStockRequest) (*DecreaseStockResponse, error) 115 | mustEmbedUnimplementedProductServiceServer() 116 | } 117 | 118 | // UnimplementedProductServiceServer must be embedded to have forward compatible implementations. 119 | type UnimplementedProductServiceServer struct { 120 | } 121 | 122 | func (UnimplementedProductServiceServer) CreateProduct(context.Context, *CreateProductRequest) (*CreateProductResponse, error) { 123 | return nil, status.Errorf(codes.Unimplemented, "method CreateProduct not implemented") 124 | } 125 | func (UnimplementedProductServiceServer) FindOne(context.Context, *FindOneRequest) (*FindOneResponse, error) { 126 | return nil, status.Errorf(codes.Unimplemented, "method FindOne not implemented") 127 | } 128 | func (UnimplementedProductServiceServer) FindAll(context.Context, *FindAllRequest) (*FindAllResponse, error) { 129 | return nil, status.Errorf(codes.Unimplemented, "method FindAll not implemented") 130 | } 131 | func (UnimplementedProductServiceServer) DecreaseStock(context.Context, *DecreaseStockRequest) (*DecreaseStockResponse, error) { 132 | return nil, status.Errorf(codes.Unimplemented, "method DecreaseStock not implemented") 133 | } 134 | func (UnimplementedProductServiceServer) mustEmbedUnimplementedProductServiceServer() {} 135 | 136 | // UnsafeProductServiceServer may be embedded to opt out of forward compatibility for this service. 137 | // Use of this interface is not recommended, as added methods to ProductServiceServer will 138 | // result in compilation errors. 139 | type UnsafeProductServiceServer interface { 140 | mustEmbedUnimplementedProductServiceServer() 141 | } 142 | 143 | func RegisterProductServiceServer(s grpc.ServiceRegistrar, srv ProductServiceServer) { 144 | s.RegisterService(&ProductService_ServiceDesc, srv) 145 | } 146 | 147 | func _ProductService_CreateProduct_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 148 | in := new(CreateProductRequest) 149 | if err := dec(in); err != nil { 150 | return nil, err 151 | } 152 | if interceptor == nil { 153 | return srv.(ProductServiceServer).CreateProduct(ctx, in) 154 | } 155 | info := &grpc.UnaryServerInfo{ 156 | Server: srv, 157 | FullMethod: "/product.ProductService/CreateProduct", 158 | } 159 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 160 | return srv.(ProductServiceServer).CreateProduct(ctx, req.(*CreateProductRequest)) 161 | } 162 | return interceptor(ctx, in, info, handler) 163 | } 164 | 165 | func _ProductService_FindOne_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 166 | in := new(FindOneRequest) 167 | if err := dec(in); err != nil { 168 | return nil, err 169 | } 170 | if interceptor == nil { 171 | return srv.(ProductServiceServer).FindOne(ctx, in) 172 | } 173 | info := &grpc.UnaryServerInfo{ 174 | Server: srv, 175 | FullMethod: "/product.ProductService/FindOne", 176 | } 177 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 178 | return srv.(ProductServiceServer).FindOne(ctx, req.(*FindOneRequest)) 179 | } 180 | return interceptor(ctx, in, info, handler) 181 | } 182 | 183 | func _ProductService_FindAll_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 184 | in := new(FindAllRequest) 185 | if err := dec(in); err != nil { 186 | return nil, err 187 | } 188 | if interceptor == nil { 189 | return srv.(ProductServiceServer).FindAll(ctx, in) 190 | } 191 | info := &grpc.UnaryServerInfo{ 192 | Server: srv, 193 | FullMethod: "/product.ProductService/FindAll", 194 | } 195 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 196 | return srv.(ProductServiceServer).FindAll(ctx, req.(*FindAllRequest)) 197 | } 198 | return interceptor(ctx, in, info, handler) 199 | } 200 | 201 | func _ProductService_DecreaseStock_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { 202 | in := new(DecreaseStockRequest) 203 | if err := dec(in); err != nil { 204 | return nil, err 205 | } 206 | if interceptor == nil { 207 | return srv.(ProductServiceServer).DecreaseStock(ctx, in) 208 | } 209 | info := &grpc.UnaryServerInfo{ 210 | Server: srv, 211 | FullMethod: "/product.ProductService/DecreaseStock", 212 | } 213 | handler := func(ctx context.Context, req interface{}) (interface{}, error) { 214 | return srv.(ProductServiceServer).DecreaseStock(ctx, req.(*DecreaseStockRequest)) 215 | } 216 | return interceptor(ctx, in, info, handler) 217 | } 218 | 219 | // ProductService_ServiceDesc is the grpc.ServiceDesc for ProductService service. 220 | // It's only intended for direct use with grpc.RegisterService, 221 | // and not to be introspected or modified (even as a copy) 222 | var ProductService_ServiceDesc = grpc.ServiceDesc{ 223 | ServiceName: "product.ProductService", 224 | HandlerType: (*ProductServiceServer)(nil), 225 | Methods: []grpc.MethodDesc{ 226 | { 227 | MethodName: "CreateProduct", 228 | Handler: _ProductService_CreateProduct_Handler, 229 | }, 230 | { 231 | MethodName: "FindOne", 232 | Handler: _ProductService_FindOne_Handler, 233 | }, 234 | { 235 | MethodName: "FindAll", 236 | Handler: _ProductService_FindAll_Handler, 237 | }, 238 | { 239 | MethodName: "DecreaseStock", 240 | Handler: _ProductService_DecreaseStock_Handler, 241 | }, 242 | }, 243 | Streams: []grpc.StreamDesc{}, 244 | Metadata: "pkg/product/pb/product.proto", 245 | } 246 | -------------------------------------------------------------------------------- /auth-svc/pkg/pb/auth.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go. DO NOT EDIT. 2 | // versions: 3 | // protoc-gen-go v1.28.1 4 | // protoc v4.22.4 5 | // source: pkg/pb/auth.proto 6 | 7 | package pb 8 | 9 | import ( 10 | protoreflect "google.golang.org/protobuf/reflect/protoreflect" 11 | protoimpl "google.golang.org/protobuf/runtime/protoimpl" 12 | reflect "reflect" 13 | sync "sync" 14 | ) 15 | 16 | const ( 17 | // Verify that this generated code is sufficiently up-to-date. 18 | _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) 19 | // Verify that runtime/protoimpl is sufficiently up-to-date. 20 | _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) 21 | ) 22 | 23 | type RegisterRequest struct { 24 | state protoimpl.MessageState 25 | sizeCache protoimpl.SizeCache 26 | unknownFields protoimpl.UnknownFields 27 | 28 | Email string `protobuf:"bytes,1,opt,name=email,proto3" json:"email,omitempty"` 29 | Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"` 30 | } 31 | 32 | func (x *RegisterRequest) Reset() { 33 | *x = RegisterRequest{} 34 | if protoimpl.UnsafeEnabled { 35 | mi := &file_pkg_pb_auth_proto_msgTypes[0] 36 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 37 | ms.StoreMessageInfo(mi) 38 | } 39 | } 40 | 41 | func (x *RegisterRequest) String() string { 42 | return protoimpl.X.MessageStringOf(x) 43 | } 44 | 45 | func (*RegisterRequest) ProtoMessage() {} 46 | 47 | func (x *RegisterRequest) ProtoReflect() protoreflect.Message { 48 | mi := &file_pkg_pb_auth_proto_msgTypes[0] 49 | if protoimpl.UnsafeEnabled && x != nil { 50 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 51 | if ms.LoadMessageInfo() == nil { 52 | ms.StoreMessageInfo(mi) 53 | } 54 | return ms 55 | } 56 | return mi.MessageOf(x) 57 | } 58 | 59 | // Deprecated: Use RegisterRequest.ProtoReflect.Descriptor instead. 60 | func (*RegisterRequest) Descriptor() ([]byte, []int) { 61 | return file_pkg_pb_auth_proto_rawDescGZIP(), []int{0} 62 | } 63 | 64 | func (x *RegisterRequest) GetEmail() string { 65 | if x != nil { 66 | return x.Email 67 | } 68 | return "" 69 | } 70 | 71 | func (x *RegisterRequest) GetPassword() string { 72 | if x != nil { 73 | return x.Password 74 | } 75 | return "" 76 | } 77 | 78 | type RegisterResponse struct { 79 | state protoimpl.MessageState 80 | sizeCache protoimpl.SizeCache 81 | unknownFields protoimpl.UnknownFields 82 | 83 | Status int64 `protobuf:"varint,1,opt,name=status,proto3" json:"status,omitempty"` 84 | Error string `protobuf:"bytes,2,opt,name=error,proto3" json:"error,omitempty"` 85 | } 86 | 87 | func (x *RegisterResponse) Reset() { 88 | *x = RegisterResponse{} 89 | if protoimpl.UnsafeEnabled { 90 | mi := &file_pkg_pb_auth_proto_msgTypes[1] 91 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 92 | ms.StoreMessageInfo(mi) 93 | } 94 | } 95 | 96 | func (x *RegisterResponse) String() string { 97 | return protoimpl.X.MessageStringOf(x) 98 | } 99 | 100 | func (*RegisterResponse) ProtoMessage() {} 101 | 102 | func (x *RegisterResponse) ProtoReflect() protoreflect.Message { 103 | mi := &file_pkg_pb_auth_proto_msgTypes[1] 104 | if protoimpl.UnsafeEnabled && x != nil { 105 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 106 | if ms.LoadMessageInfo() == nil { 107 | ms.StoreMessageInfo(mi) 108 | } 109 | return ms 110 | } 111 | return mi.MessageOf(x) 112 | } 113 | 114 | // Deprecated: Use RegisterResponse.ProtoReflect.Descriptor instead. 115 | func (*RegisterResponse) Descriptor() ([]byte, []int) { 116 | return file_pkg_pb_auth_proto_rawDescGZIP(), []int{1} 117 | } 118 | 119 | func (x *RegisterResponse) GetStatus() int64 { 120 | if x != nil { 121 | return x.Status 122 | } 123 | return 0 124 | } 125 | 126 | func (x *RegisterResponse) GetError() string { 127 | if x != nil { 128 | return x.Error 129 | } 130 | return "" 131 | } 132 | 133 | type LoginRequest struct { 134 | state protoimpl.MessageState 135 | sizeCache protoimpl.SizeCache 136 | unknownFields protoimpl.UnknownFields 137 | 138 | Email string `protobuf:"bytes,1,opt,name=email,proto3" json:"email,omitempty"` 139 | Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"` 140 | } 141 | 142 | func (x *LoginRequest) Reset() { 143 | *x = LoginRequest{} 144 | if protoimpl.UnsafeEnabled { 145 | mi := &file_pkg_pb_auth_proto_msgTypes[2] 146 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 147 | ms.StoreMessageInfo(mi) 148 | } 149 | } 150 | 151 | func (x *LoginRequest) String() string { 152 | return protoimpl.X.MessageStringOf(x) 153 | } 154 | 155 | func (*LoginRequest) ProtoMessage() {} 156 | 157 | func (x *LoginRequest) ProtoReflect() protoreflect.Message { 158 | mi := &file_pkg_pb_auth_proto_msgTypes[2] 159 | if protoimpl.UnsafeEnabled && x != nil { 160 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 161 | if ms.LoadMessageInfo() == nil { 162 | ms.StoreMessageInfo(mi) 163 | } 164 | return ms 165 | } 166 | return mi.MessageOf(x) 167 | } 168 | 169 | // Deprecated: Use LoginRequest.ProtoReflect.Descriptor instead. 170 | func (*LoginRequest) Descriptor() ([]byte, []int) { 171 | return file_pkg_pb_auth_proto_rawDescGZIP(), []int{2} 172 | } 173 | 174 | func (x *LoginRequest) GetEmail() string { 175 | if x != nil { 176 | return x.Email 177 | } 178 | return "" 179 | } 180 | 181 | func (x *LoginRequest) GetPassword() string { 182 | if x != nil { 183 | return x.Password 184 | } 185 | return "" 186 | } 187 | 188 | type LoginResponse struct { 189 | state protoimpl.MessageState 190 | sizeCache protoimpl.SizeCache 191 | unknownFields protoimpl.UnknownFields 192 | 193 | Status int64 `protobuf:"varint,1,opt,name=status,proto3" json:"status,omitempty"` 194 | Error string `protobuf:"bytes,2,opt,name=error,proto3" json:"error,omitempty"` 195 | Token string `protobuf:"bytes,3,opt,name=token,proto3" json:"token,omitempty"` 196 | } 197 | 198 | func (x *LoginResponse) Reset() { 199 | *x = LoginResponse{} 200 | if protoimpl.UnsafeEnabled { 201 | mi := &file_pkg_pb_auth_proto_msgTypes[3] 202 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 203 | ms.StoreMessageInfo(mi) 204 | } 205 | } 206 | 207 | func (x *LoginResponse) String() string { 208 | return protoimpl.X.MessageStringOf(x) 209 | } 210 | 211 | func (*LoginResponse) ProtoMessage() {} 212 | 213 | func (x *LoginResponse) ProtoReflect() protoreflect.Message { 214 | mi := &file_pkg_pb_auth_proto_msgTypes[3] 215 | if protoimpl.UnsafeEnabled && x != nil { 216 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 217 | if ms.LoadMessageInfo() == nil { 218 | ms.StoreMessageInfo(mi) 219 | } 220 | return ms 221 | } 222 | return mi.MessageOf(x) 223 | } 224 | 225 | // Deprecated: Use LoginResponse.ProtoReflect.Descriptor instead. 226 | func (*LoginResponse) Descriptor() ([]byte, []int) { 227 | return file_pkg_pb_auth_proto_rawDescGZIP(), []int{3} 228 | } 229 | 230 | func (x *LoginResponse) GetStatus() int64 { 231 | if x != nil { 232 | return x.Status 233 | } 234 | return 0 235 | } 236 | 237 | func (x *LoginResponse) GetError() string { 238 | if x != nil { 239 | return x.Error 240 | } 241 | return "" 242 | } 243 | 244 | func (x *LoginResponse) GetToken() string { 245 | if x != nil { 246 | return x.Token 247 | } 248 | return "" 249 | } 250 | 251 | type ValidateRequest struct { 252 | state protoimpl.MessageState 253 | sizeCache protoimpl.SizeCache 254 | unknownFields protoimpl.UnknownFields 255 | 256 | Token string `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"` 257 | Role string `protobuf:"bytes,2,opt,name=role,proto3" json:"role,omitempty"` 258 | } 259 | 260 | func (x *ValidateRequest) Reset() { 261 | *x = ValidateRequest{} 262 | if protoimpl.UnsafeEnabled { 263 | mi := &file_pkg_pb_auth_proto_msgTypes[4] 264 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 265 | ms.StoreMessageInfo(mi) 266 | } 267 | } 268 | 269 | func (x *ValidateRequest) String() string { 270 | return protoimpl.X.MessageStringOf(x) 271 | } 272 | 273 | func (*ValidateRequest) ProtoMessage() {} 274 | 275 | func (x *ValidateRequest) ProtoReflect() protoreflect.Message { 276 | mi := &file_pkg_pb_auth_proto_msgTypes[4] 277 | if protoimpl.UnsafeEnabled && x != nil { 278 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 279 | if ms.LoadMessageInfo() == nil { 280 | ms.StoreMessageInfo(mi) 281 | } 282 | return ms 283 | } 284 | return mi.MessageOf(x) 285 | } 286 | 287 | // Deprecated: Use ValidateRequest.ProtoReflect.Descriptor instead. 288 | func (*ValidateRequest) Descriptor() ([]byte, []int) { 289 | return file_pkg_pb_auth_proto_rawDescGZIP(), []int{4} 290 | } 291 | 292 | func (x *ValidateRequest) GetToken() string { 293 | if x != nil { 294 | return x.Token 295 | } 296 | return "" 297 | } 298 | 299 | func (x *ValidateRequest) GetRole() string { 300 | if x != nil { 301 | return x.Role 302 | } 303 | return "" 304 | } 305 | 306 | type ValidateResponse struct { 307 | state protoimpl.MessageState 308 | sizeCache protoimpl.SizeCache 309 | unknownFields protoimpl.UnknownFields 310 | 311 | Status int64 `protobuf:"varint,1,opt,name=status,proto3" json:"status,omitempty"` 312 | Error string `protobuf:"bytes,2,opt,name=error,proto3" json:"error,omitempty"` 313 | UserId int64 `protobuf:"varint,3,opt,name=userId,proto3" json:"userId,omitempty"` 314 | } 315 | 316 | func (x *ValidateResponse) Reset() { 317 | *x = ValidateResponse{} 318 | if protoimpl.UnsafeEnabled { 319 | mi := &file_pkg_pb_auth_proto_msgTypes[5] 320 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 321 | ms.StoreMessageInfo(mi) 322 | } 323 | } 324 | 325 | func (x *ValidateResponse) String() string { 326 | return protoimpl.X.MessageStringOf(x) 327 | } 328 | 329 | func (*ValidateResponse) ProtoMessage() {} 330 | 331 | func (x *ValidateResponse) ProtoReflect() protoreflect.Message { 332 | mi := &file_pkg_pb_auth_proto_msgTypes[5] 333 | if protoimpl.UnsafeEnabled && x != nil { 334 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 335 | if ms.LoadMessageInfo() == nil { 336 | ms.StoreMessageInfo(mi) 337 | } 338 | return ms 339 | } 340 | return mi.MessageOf(x) 341 | } 342 | 343 | // Deprecated: Use ValidateResponse.ProtoReflect.Descriptor instead. 344 | func (*ValidateResponse) Descriptor() ([]byte, []int) { 345 | return file_pkg_pb_auth_proto_rawDescGZIP(), []int{5} 346 | } 347 | 348 | func (x *ValidateResponse) GetStatus() int64 { 349 | if x != nil { 350 | return x.Status 351 | } 352 | return 0 353 | } 354 | 355 | func (x *ValidateResponse) GetError() string { 356 | if x != nil { 357 | return x.Error 358 | } 359 | return "" 360 | } 361 | 362 | func (x *ValidateResponse) GetUserId() int64 { 363 | if x != nil { 364 | return x.UserId 365 | } 366 | return 0 367 | } 368 | 369 | var File_pkg_pb_auth_proto protoreflect.FileDescriptor 370 | 371 | var file_pkg_pb_auth_proto_rawDesc = []byte{ 372 | 0x0a, 0x11, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x62, 0x2f, 0x61, 0x75, 0x74, 0x68, 0x2e, 0x70, 0x72, 373 | 0x6f, 0x74, 0x6f, 0x12, 0x04, 0x61, 0x75, 0x74, 0x68, 0x22, 0x43, 0x0a, 0x0f, 0x52, 0x65, 0x67, 374 | 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 375 | 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x6d, 0x61, 376 | 0x69, 0x6c, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x02, 377 | 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x22, 0x40, 378 | 0x0a, 0x10, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 379 | 0x73, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x01, 0x20, 0x01, 380 | 0x28, 0x03, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x72, 381 | 0x72, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 382 | 0x22, 0x40, 0x0a, 0x0c, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 383 | 0x12, 0x14, 0x0a, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 384 | 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 385 | 0x72, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 386 | 0x72, 0x64, 0x22, 0x53, 0x0a, 0x0d, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 387 | 0x6e, 0x73, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x01, 0x20, 388 | 0x01, 0x28, 0x03, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x65, 389 | 0x72, 0x72, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 390 | 0x72, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 391 | 0x52, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x3b, 0x0a, 0x0f, 0x56, 0x61, 0x6c, 0x69, 0x64, 392 | 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x6f, 393 | 0x6b, 0x65, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 394 | 0x12, 0x12, 0x0a, 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 395 | 0x72, 0x6f, 0x6c, 0x65, 0x22, 0x58, 0x0a, 0x10, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 396 | 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 397 | 0x75, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 398 | 0x12, 0x14, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 399 | 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x12, 0x16, 0x0a, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 400 | 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x32, 0xec, 401 | 0x01, 0x0a, 0x0b, 0x41, 0x75, 0x74, 0x68, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x39, 402 | 0x0a, 0x08, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x12, 0x15, 0x2e, 0x61, 0x75, 0x74, 403 | 0x68, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 404 | 0x74, 0x1a, 0x16, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 405 | 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x30, 0x0a, 0x05, 0x4c, 0x6f, 0x67, 406 | 0x69, 0x6e, 0x12, 0x12, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x2e, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 407 | 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x13, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x2e, 0x4c, 0x6f, 408 | 0x67, 0x69, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x39, 0x0a, 0x08, 0x56, 409 | 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x12, 0x15, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x2e, 0x56, 410 | 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 411 | 0x2e, 0x61, 0x75, 0x74, 0x68, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 412 | 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x35, 0x0a, 0x0a, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x4c, 413 | 0x6f, 0x67, 0x69, 0x6e, 0x12, 0x12, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x2e, 0x4c, 0x6f, 0x67, 0x69, 414 | 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x13, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x2e, 415 | 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x0a, 0x5a, 416 | 0x08, 0x2e, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 417 | 0x33, 418 | } 419 | 420 | var ( 421 | file_pkg_pb_auth_proto_rawDescOnce sync.Once 422 | file_pkg_pb_auth_proto_rawDescData = file_pkg_pb_auth_proto_rawDesc 423 | ) 424 | 425 | func file_pkg_pb_auth_proto_rawDescGZIP() []byte { 426 | file_pkg_pb_auth_proto_rawDescOnce.Do(func() { 427 | file_pkg_pb_auth_proto_rawDescData = protoimpl.X.CompressGZIP(file_pkg_pb_auth_proto_rawDescData) 428 | }) 429 | return file_pkg_pb_auth_proto_rawDescData 430 | } 431 | 432 | var file_pkg_pb_auth_proto_msgTypes = make([]protoimpl.MessageInfo, 6) 433 | var file_pkg_pb_auth_proto_goTypes = []interface{}{ 434 | (*RegisterRequest)(nil), // 0: auth.RegisterRequest 435 | (*RegisterResponse)(nil), // 1: auth.RegisterResponse 436 | (*LoginRequest)(nil), // 2: auth.LoginRequest 437 | (*LoginResponse)(nil), // 3: auth.LoginResponse 438 | (*ValidateRequest)(nil), // 4: auth.ValidateRequest 439 | (*ValidateResponse)(nil), // 5: auth.ValidateResponse 440 | } 441 | var file_pkg_pb_auth_proto_depIdxs = []int32{ 442 | 0, // 0: auth.AuthService.Register:input_type -> auth.RegisterRequest 443 | 2, // 1: auth.AuthService.Login:input_type -> auth.LoginRequest 444 | 4, // 2: auth.AuthService.Validate:input_type -> auth.ValidateRequest 445 | 2, // 3: auth.AuthService.AdminLogin:input_type -> auth.LoginRequest 446 | 1, // 4: auth.AuthService.Register:output_type -> auth.RegisterResponse 447 | 3, // 5: auth.AuthService.Login:output_type -> auth.LoginResponse 448 | 5, // 6: auth.AuthService.Validate:output_type -> auth.ValidateResponse 449 | 3, // 7: auth.AuthService.AdminLogin:output_type -> auth.LoginResponse 450 | 4, // [4:8] is the sub-list for method output_type 451 | 0, // [0:4] is the sub-list for method input_type 452 | 0, // [0:0] is the sub-list for extension type_name 453 | 0, // [0:0] is the sub-list for extension extendee 454 | 0, // [0:0] is the sub-list for field type_name 455 | } 456 | 457 | func init() { file_pkg_pb_auth_proto_init() } 458 | func file_pkg_pb_auth_proto_init() { 459 | if File_pkg_pb_auth_proto != nil { 460 | return 461 | } 462 | if !protoimpl.UnsafeEnabled { 463 | file_pkg_pb_auth_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { 464 | switch v := v.(*RegisterRequest); i { 465 | case 0: 466 | return &v.state 467 | case 1: 468 | return &v.sizeCache 469 | case 2: 470 | return &v.unknownFields 471 | default: 472 | return nil 473 | } 474 | } 475 | file_pkg_pb_auth_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { 476 | switch v := v.(*RegisterResponse); i { 477 | case 0: 478 | return &v.state 479 | case 1: 480 | return &v.sizeCache 481 | case 2: 482 | return &v.unknownFields 483 | default: 484 | return nil 485 | } 486 | } 487 | file_pkg_pb_auth_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { 488 | switch v := v.(*LoginRequest); i { 489 | case 0: 490 | return &v.state 491 | case 1: 492 | return &v.sizeCache 493 | case 2: 494 | return &v.unknownFields 495 | default: 496 | return nil 497 | } 498 | } 499 | file_pkg_pb_auth_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { 500 | switch v := v.(*LoginResponse); i { 501 | case 0: 502 | return &v.state 503 | case 1: 504 | return &v.sizeCache 505 | case 2: 506 | return &v.unknownFields 507 | default: 508 | return nil 509 | } 510 | } 511 | file_pkg_pb_auth_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { 512 | switch v := v.(*ValidateRequest); i { 513 | case 0: 514 | return &v.state 515 | case 1: 516 | return &v.sizeCache 517 | case 2: 518 | return &v.unknownFields 519 | default: 520 | return nil 521 | } 522 | } 523 | file_pkg_pb_auth_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { 524 | switch v := v.(*ValidateResponse); i { 525 | case 0: 526 | return &v.state 527 | case 1: 528 | return &v.sizeCache 529 | case 2: 530 | return &v.unknownFields 531 | default: 532 | return nil 533 | } 534 | } 535 | } 536 | type x struct{} 537 | out := protoimpl.TypeBuilder{ 538 | File: protoimpl.DescBuilder{ 539 | GoPackagePath: reflect.TypeOf(x{}).PkgPath(), 540 | RawDescriptor: file_pkg_pb_auth_proto_rawDesc, 541 | NumEnums: 0, 542 | NumMessages: 6, 543 | NumExtensions: 0, 544 | NumServices: 1, 545 | }, 546 | GoTypes: file_pkg_pb_auth_proto_goTypes, 547 | DependencyIndexes: file_pkg_pb_auth_proto_depIdxs, 548 | MessageInfos: file_pkg_pb_auth_proto_msgTypes, 549 | }.Build() 550 | File_pkg_pb_auth_proto = out.File 551 | file_pkg_pb_auth_proto_rawDesc = nil 552 | file_pkg_pb_auth_proto_goTypes = nil 553 | file_pkg_pb_auth_proto_depIdxs = nil 554 | } 555 | -------------------------------------------------------------------------------- /api-gateway/pkg/auth/pb/auth.pb.go: -------------------------------------------------------------------------------- 1 | // mention which version of proto are we using 2 | 3 | // Code generated by protoc-gen-go. DO NOT EDIT. 4 | // versions: 5 | // protoc-gen-go v1.28.1 6 | // protoc v4.22.4 7 | // source: pkg/auth/pb/auth.proto 8 | 9 | //package name 10 | 11 | package pb 12 | 13 | import ( 14 | protoreflect "google.golang.org/protobuf/reflect/protoreflect" 15 | protoimpl "google.golang.org/protobuf/runtime/protoimpl" 16 | reflect "reflect" 17 | sync "sync" 18 | ) 19 | 20 | const ( 21 | // Verify that this generated code is sufficiently up-to-date. 22 | _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) 23 | // Verify that runtime/protoimpl is sufficiently up-to-date. 24 | _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) 25 | ) 26 | 27 | type RegisterRequest struct { 28 | state protoimpl.MessageState 29 | sizeCache protoimpl.SizeCache 30 | unknownFields protoimpl.UnknownFields 31 | 32 | Email string `protobuf:"bytes,1,opt,name=email,proto3" json:"email,omitempty"` 33 | Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"` 34 | } 35 | 36 | func (x *RegisterRequest) Reset() { 37 | *x = RegisterRequest{} 38 | if protoimpl.UnsafeEnabled { 39 | mi := &file_pkg_auth_pb_auth_proto_msgTypes[0] 40 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 41 | ms.StoreMessageInfo(mi) 42 | } 43 | } 44 | 45 | func (x *RegisterRequest) String() string { 46 | return protoimpl.X.MessageStringOf(x) 47 | } 48 | 49 | func (*RegisterRequest) ProtoMessage() {} 50 | 51 | func (x *RegisterRequest) ProtoReflect() protoreflect.Message { 52 | mi := &file_pkg_auth_pb_auth_proto_msgTypes[0] 53 | if protoimpl.UnsafeEnabled && x != nil { 54 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 55 | if ms.LoadMessageInfo() == nil { 56 | ms.StoreMessageInfo(mi) 57 | } 58 | return ms 59 | } 60 | return mi.MessageOf(x) 61 | } 62 | 63 | // Deprecated: Use RegisterRequest.ProtoReflect.Descriptor instead. 64 | func (*RegisterRequest) Descriptor() ([]byte, []int) { 65 | return file_pkg_auth_pb_auth_proto_rawDescGZIP(), []int{0} 66 | } 67 | 68 | func (x *RegisterRequest) GetEmail() string { 69 | if x != nil { 70 | return x.Email 71 | } 72 | return "" 73 | } 74 | 75 | func (x *RegisterRequest) GetPassword() string { 76 | if x != nil { 77 | return x.Password 78 | } 79 | return "" 80 | } 81 | 82 | type RegisterResponse struct { 83 | state protoimpl.MessageState 84 | sizeCache protoimpl.SizeCache 85 | unknownFields protoimpl.UnknownFields 86 | 87 | Status int64 `protobuf:"varint,1,opt,name=status,proto3" json:"status,omitempty"` 88 | Error string `protobuf:"bytes,2,opt,name=error,proto3" json:"error,omitempty"` 89 | } 90 | 91 | func (x *RegisterResponse) Reset() { 92 | *x = RegisterResponse{} 93 | if protoimpl.UnsafeEnabled { 94 | mi := &file_pkg_auth_pb_auth_proto_msgTypes[1] 95 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 96 | ms.StoreMessageInfo(mi) 97 | } 98 | } 99 | 100 | func (x *RegisterResponse) String() string { 101 | return protoimpl.X.MessageStringOf(x) 102 | } 103 | 104 | func (*RegisterResponse) ProtoMessage() {} 105 | 106 | func (x *RegisterResponse) ProtoReflect() protoreflect.Message { 107 | mi := &file_pkg_auth_pb_auth_proto_msgTypes[1] 108 | if protoimpl.UnsafeEnabled && x != nil { 109 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 110 | if ms.LoadMessageInfo() == nil { 111 | ms.StoreMessageInfo(mi) 112 | } 113 | return ms 114 | } 115 | return mi.MessageOf(x) 116 | } 117 | 118 | // Deprecated: Use RegisterResponse.ProtoReflect.Descriptor instead. 119 | func (*RegisterResponse) Descriptor() ([]byte, []int) { 120 | return file_pkg_auth_pb_auth_proto_rawDescGZIP(), []int{1} 121 | } 122 | 123 | func (x *RegisterResponse) GetStatus() int64 { 124 | if x != nil { 125 | return x.Status 126 | } 127 | return 0 128 | } 129 | 130 | func (x *RegisterResponse) GetError() string { 131 | if x != nil { 132 | return x.Error 133 | } 134 | return "" 135 | } 136 | 137 | type LoginRequest struct { 138 | state protoimpl.MessageState 139 | sizeCache protoimpl.SizeCache 140 | unknownFields protoimpl.UnknownFields 141 | 142 | Email string `protobuf:"bytes,1,opt,name=email,proto3" json:"email,omitempty"` 143 | Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"` 144 | } 145 | 146 | func (x *LoginRequest) Reset() { 147 | *x = LoginRequest{} 148 | if protoimpl.UnsafeEnabled { 149 | mi := &file_pkg_auth_pb_auth_proto_msgTypes[2] 150 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 151 | ms.StoreMessageInfo(mi) 152 | } 153 | } 154 | 155 | func (x *LoginRequest) String() string { 156 | return protoimpl.X.MessageStringOf(x) 157 | } 158 | 159 | func (*LoginRequest) ProtoMessage() {} 160 | 161 | func (x *LoginRequest) ProtoReflect() protoreflect.Message { 162 | mi := &file_pkg_auth_pb_auth_proto_msgTypes[2] 163 | if protoimpl.UnsafeEnabled && x != nil { 164 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 165 | if ms.LoadMessageInfo() == nil { 166 | ms.StoreMessageInfo(mi) 167 | } 168 | return ms 169 | } 170 | return mi.MessageOf(x) 171 | } 172 | 173 | // Deprecated: Use LoginRequest.ProtoReflect.Descriptor instead. 174 | func (*LoginRequest) Descriptor() ([]byte, []int) { 175 | return file_pkg_auth_pb_auth_proto_rawDescGZIP(), []int{2} 176 | } 177 | 178 | func (x *LoginRequest) GetEmail() string { 179 | if x != nil { 180 | return x.Email 181 | } 182 | return "" 183 | } 184 | 185 | func (x *LoginRequest) GetPassword() string { 186 | if x != nil { 187 | return x.Password 188 | } 189 | return "" 190 | } 191 | 192 | type LoginResponse struct { 193 | state protoimpl.MessageState 194 | sizeCache protoimpl.SizeCache 195 | unknownFields protoimpl.UnknownFields 196 | 197 | Status int64 `protobuf:"varint,1,opt,name=status,proto3" json:"status,omitempty"` 198 | Error string `protobuf:"bytes,2,opt,name=error,proto3" json:"error,omitempty"` 199 | Token string `protobuf:"bytes,3,opt,name=token,proto3" json:"token,omitempty"` 200 | } 201 | 202 | func (x *LoginResponse) Reset() { 203 | *x = LoginResponse{} 204 | if protoimpl.UnsafeEnabled { 205 | mi := &file_pkg_auth_pb_auth_proto_msgTypes[3] 206 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 207 | ms.StoreMessageInfo(mi) 208 | } 209 | } 210 | 211 | func (x *LoginResponse) String() string { 212 | return protoimpl.X.MessageStringOf(x) 213 | } 214 | 215 | func (*LoginResponse) ProtoMessage() {} 216 | 217 | func (x *LoginResponse) ProtoReflect() protoreflect.Message { 218 | mi := &file_pkg_auth_pb_auth_proto_msgTypes[3] 219 | if protoimpl.UnsafeEnabled && x != nil { 220 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 221 | if ms.LoadMessageInfo() == nil { 222 | ms.StoreMessageInfo(mi) 223 | } 224 | return ms 225 | } 226 | return mi.MessageOf(x) 227 | } 228 | 229 | // Deprecated: Use LoginResponse.ProtoReflect.Descriptor instead. 230 | func (*LoginResponse) Descriptor() ([]byte, []int) { 231 | return file_pkg_auth_pb_auth_proto_rawDescGZIP(), []int{3} 232 | } 233 | 234 | func (x *LoginResponse) GetStatus() int64 { 235 | if x != nil { 236 | return x.Status 237 | } 238 | return 0 239 | } 240 | 241 | func (x *LoginResponse) GetError() string { 242 | if x != nil { 243 | return x.Error 244 | } 245 | return "" 246 | } 247 | 248 | func (x *LoginResponse) GetToken() string { 249 | if x != nil { 250 | return x.Token 251 | } 252 | return "" 253 | } 254 | 255 | type ValidateRequest struct { 256 | state protoimpl.MessageState 257 | sizeCache protoimpl.SizeCache 258 | unknownFields protoimpl.UnknownFields 259 | 260 | Token string `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"` 261 | Role string `protobuf:"bytes,2,opt,name=role,proto3" json:"role,omitempty"` 262 | } 263 | 264 | func (x *ValidateRequest) Reset() { 265 | *x = ValidateRequest{} 266 | if protoimpl.UnsafeEnabled { 267 | mi := &file_pkg_auth_pb_auth_proto_msgTypes[4] 268 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 269 | ms.StoreMessageInfo(mi) 270 | } 271 | } 272 | 273 | func (x *ValidateRequest) String() string { 274 | return protoimpl.X.MessageStringOf(x) 275 | } 276 | 277 | func (*ValidateRequest) ProtoMessage() {} 278 | 279 | func (x *ValidateRequest) ProtoReflect() protoreflect.Message { 280 | mi := &file_pkg_auth_pb_auth_proto_msgTypes[4] 281 | if protoimpl.UnsafeEnabled && x != nil { 282 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 283 | if ms.LoadMessageInfo() == nil { 284 | ms.StoreMessageInfo(mi) 285 | } 286 | return ms 287 | } 288 | return mi.MessageOf(x) 289 | } 290 | 291 | // Deprecated: Use ValidateRequest.ProtoReflect.Descriptor instead. 292 | func (*ValidateRequest) Descriptor() ([]byte, []int) { 293 | return file_pkg_auth_pb_auth_proto_rawDescGZIP(), []int{4} 294 | } 295 | 296 | func (x *ValidateRequest) GetToken() string { 297 | if x != nil { 298 | return x.Token 299 | } 300 | return "" 301 | } 302 | 303 | func (x *ValidateRequest) GetRole() string { 304 | if x != nil { 305 | return x.Role 306 | } 307 | return "" 308 | } 309 | 310 | type ValidateResponse struct { 311 | state protoimpl.MessageState 312 | sizeCache protoimpl.SizeCache 313 | unknownFields protoimpl.UnknownFields 314 | 315 | Status int64 `protobuf:"varint,1,opt,name=status,proto3" json:"status,omitempty"` 316 | Error string `protobuf:"bytes,2,opt,name=error,proto3" json:"error,omitempty"` 317 | UserId int64 `protobuf:"varint,3,opt,name=userId,proto3" json:"userId,omitempty"` 318 | } 319 | 320 | func (x *ValidateResponse) Reset() { 321 | *x = ValidateResponse{} 322 | if protoimpl.UnsafeEnabled { 323 | mi := &file_pkg_auth_pb_auth_proto_msgTypes[5] 324 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 325 | ms.StoreMessageInfo(mi) 326 | } 327 | } 328 | 329 | func (x *ValidateResponse) String() string { 330 | return protoimpl.X.MessageStringOf(x) 331 | } 332 | 333 | func (*ValidateResponse) ProtoMessage() {} 334 | 335 | func (x *ValidateResponse) ProtoReflect() protoreflect.Message { 336 | mi := &file_pkg_auth_pb_auth_proto_msgTypes[5] 337 | if protoimpl.UnsafeEnabled && x != nil { 338 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 339 | if ms.LoadMessageInfo() == nil { 340 | ms.StoreMessageInfo(mi) 341 | } 342 | return ms 343 | } 344 | return mi.MessageOf(x) 345 | } 346 | 347 | // Deprecated: Use ValidateResponse.ProtoReflect.Descriptor instead. 348 | func (*ValidateResponse) Descriptor() ([]byte, []int) { 349 | return file_pkg_auth_pb_auth_proto_rawDescGZIP(), []int{5} 350 | } 351 | 352 | func (x *ValidateResponse) GetStatus() int64 { 353 | if x != nil { 354 | return x.Status 355 | } 356 | return 0 357 | } 358 | 359 | func (x *ValidateResponse) GetError() string { 360 | if x != nil { 361 | return x.Error 362 | } 363 | return "" 364 | } 365 | 366 | func (x *ValidateResponse) GetUserId() int64 { 367 | if x != nil { 368 | return x.UserId 369 | } 370 | return 0 371 | } 372 | 373 | var File_pkg_auth_pb_auth_proto protoreflect.FileDescriptor 374 | 375 | var file_pkg_auth_pb_auth_proto_rawDesc = []byte{ 376 | 0x0a, 0x16, 0x70, 0x6b, 0x67, 0x2f, 0x61, 0x75, 0x74, 0x68, 0x2f, 0x70, 0x62, 0x2f, 0x61, 0x75, 377 | 0x74, 0x68, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x04, 0x61, 0x75, 0x74, 0x68, 0x22, 0x43, 378 | 0x0a, 0x0f, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 379 | 0x74, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 380 | 0x52, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 381 | 0x6f, 0x72, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 382 | 0x6f, 0x72, 0x64, 0x22, 0x40, 0x0a, 0x10, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 383 | 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 384 | 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 385 | 0x14, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 386 | 0x65, 0x72, 0x72, 0x6f, 0x72, 0x22, 0x40, 0x0a, 0x0c, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 387 | 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x18, 0x01, 388 | 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x12, 0x1a, 0x0a, 0x08, 0x70, 389 | 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 390 | 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x22, 0x53, 0x0a, 0x0d, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 391 | 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 392 | 0x75, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 393 | 0x12, 0x14, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 394 | 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 395 | 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x3b, 0x0a, 0x0f, 396 | 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 397 | 0x14, 0x0a, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 398 | 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x18, 0x02, 0x20, 399 | 0x01, 0x28, 0x09, 0x52, 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x22, 0x58, 0x0a, 0x10, 0x56, 0x61, 0x6c, 400 | 0x69, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x16, 0x0a, 401 | 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x73, 402 | 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x02, 403 | 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x12, 0x16, 0x0a, 0x06, 0x75, 404 | 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x75, 0x73, 0x65, 405 | 0x72, 0x49, 0x64, 0x32, 0xf2, 0x01, 0x0a, 0x0b, 0x41, 0x75, 0x74, 0x68, 0x53, 0x65, 0x72, 0x76, 406 | 0x69, 0x63, 0x65, 0x12, 0x3b, 0x0a, 0x08, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x12, 407 | 0x15, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 408 | 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x2e, 0x52, 0x65, 409 | 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 410 | 0x12, 0x32, 0x0a, 0x05, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x12, 0x12, 0x2e, 0x61, 0x75, 0x74, 0x68, 411 | 0x2e, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x13, 0x2e, 412 | 0x61, 0x75, 0x74, 0x68, 0x2e, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 413 | 0x73, 0x65, 0x22, 0x00, 0x12, 0x3b, 0x0a, 0x08, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 414 | 0x12, 0x15, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 415 | 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x2e, 0x56, 416 | 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 417 | 0x00, 0x12, 0x35, 0x0a, 0x0a, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x12, 418 | 0x12, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x2e, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x75, 419 | 0x65, 0x73, 0x74, 0x1a, 0x13, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x2e, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 420 | 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x0f, 0x5a, 0x0d, 0x2e, 0x2f, 0x70, 0x6b, 421 | 0x67, 0x2f, 0x61, 0x75, 0x74, 0x68, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 422 | 0x33, 423 | } 424 | 425 | var ( 426 | file_pkg_auth_pb_auth_proto_rawDescOnce sync.Once 427 | file_pkg_auth_pb_auth_proto_rawDescData = file_pkg_auth_pb_auth_proto_rawDesc 428 | ) 429 | 430 | func file_pkg_auth_pb_auth_proto_rawDescGZIP() []byte { 431 | file_pkg_auth_pb_auth_proto_rawDescOnce.Do(func() { 432 | file_pkg_auth_pb_auth_proto_rawDescData = protoimpl.X.CompressGZIP(file_pkg_auth_pb_auth_proto_rawDescData) 433 | }) 434 | return file_pkg_auth_pb_auth_proto_rawDescData 435 | } 436 | 437 | var file_pkg_auth_pb_auth_proto_msgTypes = make([]protoimpl.MessageInfo, 6) 438 | var file_pkg_auth_pb_auth_proto_goTypes = []interface{}{ 439 | (*RegisterRequest)(nil), // 0: auth.RegisterRequest 440 | (*RegisterResponse)(nil), // 1: auth.RegisterResponse 441 | (*LoginRequest)(nil), // 2: auth.LoginRequest 442 | (*LoginResponse)(nil), // 3: auth.LoginResponse 443 | (*ValidateRequest)(nil), // 4: auth.ValidateRequest 444 | (*ValidateResponse)(nil), // 5: auth.ValidateResponse 445 | } 446 | var file_pkg_auth_pb_auth_proto_depIdxs = []int32{ 447 | 0, // 0: auth.AuthService.Register:input_type -> auth.RegisterRequest 448 | 2, // 1: auth.AuthService.Login:input_type -> auth.LoginRequest 449 | 4, // 2: auth.AuthService.Validate:input_type -> auth.ValidateRequest 450 | 2, // 3: auth.AuthService.AdminLogin:input_type -> auth.LoginRequest 451 | 1, // 4: auth.AuthService.Register:output_type -> auth.RegisterResponse 452 | 3, // 5: auth.AuthService.Login:output_type -> auth.LoginResponse 453 | 5, // 6: auth.AuthService.Validate:output_type -> auth.ValidateResponse 454 | 3, // 7: auth.AuthService.AdminLogin:output_type -> auth.LoginResponse 455 | 4, // [4:8] is the sub-list for method output_type 456 | 0, // [0:4] is the sub-list for method input_type 457 | 0, // [0:0] is the sub-list for extension type_name 458 | 0, // [0:0] is the sub-list for extension extendee 459 | 0, // [0:0] is the sub-list for field type_name 460 | } 461 | 462 | func init() { file_pkg_auth_pb_auth_proto_init() } 463 | func file_pkg_auth_pb_auth_proto_init() { 464 | if File_pkg_auth_pb_auth_proto != nil { 465 | return 466 | } 467 | if !protoimpl.UnsafeEnabled { 468 | file_pkg_auth_pb_auth_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { 469 | switch v := v.(*RegisterRequest); i { 470 | case 0: 471 | return &v.state 472 | case 1: 473 | return &v.sizeCache 474 | case 2: 475 | return &v.unknownFields 476 | default: 477 | return nil 478 | } 479 | } 480 | file_pkg_auth_pb_auth_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { 481 | switch v := v.(*RegisterResponse); i { 482 | case 0: 483 | return &v.state 484 | case 1: 485 | return &v.sizeCache 486 | case 2: 487 | return &v.unknownFields 488 | default: 489 | return nil 490 | } 491 | } 492 | file_pkg_auth_pb_auth_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { 493 | switch v := v.(*LoginRequest); i { 494 | case 0: 495 | return &v.state 496 | case 1: 497 | return &v.sizeCache 498 | case 2: 499 | return &v.unknownFields 500 | default: 501 | return nil 502 | } 503 | } 504 | file_pkg_auth_pb_auth_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { 505 | switch v := v.(*LoginResponse); i { 506 | case 0: 507 | return &v.state 508 | case 1: 509 | return &v.sizeCache 510 | case 2: 511 | return &v.unknownFields 512 | default: 513 | return nil 514 | } 515 | } 516 | file_pkg_auth_pb_auth_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { 517 | switch v := v.(*ValidateRequest); i { 518 | case 0: 519 | return &v.state 520 | case 1: 521 | return &v.sizeCache 522 | case 2: 523 | return &v.unknownFields 524 | default: 525 | return nil 526 | } 527 | } 528 | file_pkg_auth_pb_auth_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { 529 | switch v := v.(*ValidateResponse); i { 530 | case 0: 531 | return &v.state 532 | case 1: 533 | return &v.sizeCache 534 | case 2: 535 | return &v.unknownFields 536 | default: 537 | return nil 538 | } 539 | } 540 | } 541 | type x struct{} 542 | out := protoimpl.TypeBuilder{ 543 | File: protoimpl.DescBuilder{ 544 | GoPackagePath: reflect.TypeOf(x{}).PkgPath(), 545 | RawDescriptor: file_pkg_auth_pb_auth_proto_rawDesc, 546 | NumEnums: 0, 547 | NumMessages: 6, 548 | NumExtensions: 0, 549 | NumServices: 1, 550 | }, 551 | GoTypes: file_pkg_auth_pb_auth_proto_goTypes, 552 | DependencyIndexes: file_pkg_auth_pb_auth_proto_depIdxs, 553 | MessageInfos: file_pkg_auth_pb_auth_proto_msgTypes, 554 | }.Build() 555 | File_pkg_auth_pb_auth_proto = out.File 556 | file_pkg_auth_pb_auth_proto_rawDesc = nil 557 | file_pkg_auth_pb_auth_proto_goTypes = nil 558 | file_pkg_auth_pb_auth_proto_depIdxs = nil 559 | } 560 | -------------------------------------------------------------------------------- /order-svc/pkg/pb/product.pb.go: -------------------------------------------------------------------------------- 1 | // Code generated by protoc-gen-go. DO NOT EDIT. 2 | // versions: 3 | // protoc-gen-go v1.28.1 4 | // protoc v4.22.4 5 | // source: pkg/pb/product.proto 6 | 7 | package pb 8 | 9 | import ( 10 | protoreflect "google.golang.org/protobuf/reflect/protoreflect" 11 | protoimpl "google.golang.org/protobuf/runtime/protoimpl" 12 | reflect "reflect" 13 | sync "sync" 14 | ) 15 | 16 | const ( 17 | // Verify that this generated code is sufficiently up-to-date. 18 | _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) 19 | // Verify that runtime/protoimpl is sufficiently up-to-date. 20 | _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) 21 | ) 22 | 23 | type CreateProductRequest struct { 24 | state protoimpl.MessageState 25 | sizeCache protoimpl.SizeCache 26 | unknownFields protoimpl.UnknownFields 27 | 28 | Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` 29 | Stock int64 `protobuf:"varint,2,opt,name=stock,proto3" json:"stock,omitempty"` 30 | Price int64 `protobuf:"varint,3,opt,name=price,proto3" json:"price,omitempty"` 31 | } 32 | 33 | func (x *CreateProductRequest) Reset() { 34 | *x = CreateProductRequest{} 35 | if protoimpl.UnsafeEnabled { 36 | mi := &file_pkg_pb_product_proto_msgTypes[0] 37 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 38 | ms.StoreMessageInfo(mi) 39 | } 40 | } 41 | 42 | func (x *CreateProductRequest) String() string { 43 | return protoimpl.X.MessageStringOf(x) 44 | } 45 | 46 | func (*CreateProductRequest) ProtoMessage() {} 47 | 48 | func (x *CreateProductRequest) ProtoReflect() protoreflect.Message { 49 | mi := &file_pkg_pb_product_proto_msgTypes[0] 50 | if protoimpl.UnsafeEnabled && x != nil { 51 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 52 | if ms.LoadMessageInfo() == nil { 53 | ms.StoreMessageInfo(mi) 54 | } 55 | return ms 56 | } 57 | return mi.MessageOf(x) 58 | } 59 | 60 | // Deprecated: Use CreateProductRequest.ProtoReflect.Descriptor instead. 61 | func (*CreateProductRequest) Descriptor() ([]byte, []int) { 62 | return file_pkg_pb_product_proto_rawDescGZIP(), []int{0} 63 | } 64 | 65 | func (x *CreateProductRequest) GetName() string { 66 | if x != nil { 67 | return x.Name 68 | } 69 | return "" 70 | } 71 | 72 | func (x *CreateProductRequest) GetStock() int64 { 73 | if x != nil { 74 | return x.Stock 75 | } 76 | return 0 77 | } 78 | 79 | func (x *CreateProductRequest) GetPrice() int64 { 80 | if x != nil { 81 | return x.Price 82 | } 83 | return 0 84 | } 85 | 86 | type CreateProductResponse struct { 87 | state protoimpl.MessageState 88 | sizeCache protoimpl.SizeCache 89 | unknownFields protoimpl.UnknownFields 90 | 91 | Status int64 `protobuf:"varint,1,opt,name=status,proto3" json:"status,omitempty"` 92 | Error string `protobuf:"bytes,2,opt,name=error,proto3" json:"error,omitempty"` 93 | Id int64 `protobuf:"varint,3,opt,name=id,proto3" json:"id,omitempty"` 94 | } 95 | 96 | func (x *CreateProductResponse) Reset() { 97 | *x = CreateProductResponse{} 98 | if protoimpl.UnsafeEnabled { 99 | mi := &file_pkg_pb_product_proto_msgTypes[1] 100 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 101 | ms.StoreMessageInfo(mi) 102 | } 103 | } 104 | 105 | func (x *CreateProductResponse) String() string { 106 | return protoimpl.X.MessageStringOf(x) 107 | } 108 | 109 | func (*CreateProductResponse) ProtoMessage() {} 110 | 111 | func (x *CreateProductResponse) ProtoReflect() protoreflect.Message { 112 | mi := &file_pkg_pb_product_proto_msgTypes[1] 113 | if protoimpl.UnsafeEnabled && x != nil { 114 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 115 | if ms.LoadMessageInfo() == nil { 116 | ms.StoreMessageInfo(mi) 117 | } 118 | return ms 119 | } 120 | return mi.MessageOf(x) 121 | } 122 | 123 | // Deprecated: Use CreateProductResponse.ProtoReflect.Descriptor instead. 124 | func (*CreateProductResponse) Descriptor() ([]byte, []int) { 125 | return file_pkg_pb_product_proto_rawDescGZIP(), []int{1} 126 | } 127 | 128 | func (x *CreateProductResponse) GetStatus() int64 { 129 | if x != nil { 130 | return x.Status 131 | } 132 | return 0 133 | } 134 | 135 | func (x *CreateProductResponse) GetError() string { 136 | if x != nil { 137 | return x.Error 138 | } 139 | return "" 140 | } 141 | 142 | func (x *CreateProductResponse) GetId() int64 { 143 | if x != nil { 144 | return x.Id 145 | } 146 | return 0 147 | } 148 | 149 | type FindOneData struct { 150 | state protoimpl.MessageState 151 | sizeCache protoimpl.SizeCache 152 | unknownFields protoimpl.UnknownFields 153 | 154 | Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` 155 | Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` 156 | Stock int64 `protobuf:"varint,3,opt,name=stock,proto3" json:"stock,omitempty"` 157 | Price int64 `protobuf:"varint,4,opt,name=price,proto3" json:"price,omitempty"` 158 | } 159 | 160 | func (x *FindOneData) Reset() { 161 | *x = FindOneData{} 162 | if protoimpl.UnsafeEnabled { 163 | mi := &file_pkg_pb_product_proto_msgTypes[2] 164 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 165 | ms.StoreMessageInfo(mi) 166 | } 167 | } 168 | 169 | func (x *FindOneData) String() string { 170 | return protoimpl.X.MessageStringOf(x) 171 | } 172 | 173 | func (*FindOneData) ProtoMessage() {} 174 | 175 | func (x *FindOneData) ProtoReflect() protoreflect.Message { 176 | mi := &file_pkg_pb_product_proto_msgTypes[2] 177 | if protoimpl.UnsafeEnabled && x != nil { 178 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 179 | if ms.LoadMessageInfo() == nil { 180 | ms.StoreMessageInfo(mi) 181 | } 182 | return ms 183 | } 184 | return mi.MessageOf(x) 185 | } 186 | 187 | // Deprecated: Use FindOneData.ProtoReflect.Descriptor instead. 188 | func (*FindOneData) Descriptor() ([]byte, []int) { 189 | return file_pkg_pb_product_proto_rawDescGZIP(), []int{2} 190 | } 191 | 192 | func (x *FindOneData) GetId() int64 { 193 | if x != nil { 194 | return x.Id 195 | } 196 | return 0 197 | } 198 | 199 | func (x *FindOneData) GetName() string { 200 | if x != nil { 201 | return x.Name 202 | } 203 | return "" 204 | } 205 | 206 | func (x *FindOneData) GetStock() int64 { 207 | if x != nil { 208 | return x.Stock 209 | } 210 | return 0 211 | } 212 | 213 | func (x *FindOneData) GetPrice() int64 { 214 | if x != nil { 215 | return x.Price 216 | } 217 | return 0 218 | } 219 | 220 | type FindOneRequest struct { 221 | state protoimpl.MessageState 222 | sizeCache protoimpl.SizeCache 223 | unknownFields protoimpl.UnknownFields 224 | 225 | Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` 226 | } 227 | 228 | func (x *FindOneRequest) Reset() { 229 | *x = FindOneRequest{} 230 | if protoimpl.UnsafeEnabled { 231 | mi := &file_pkg_pb_product_proto_msgTypes[3] 232 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 233 | ms.StoreMessageInfo(mi) 234 | } 235 | } 236 | 237 | func (x *FindOneRequest) String() string { 238 | return protoimpl.X.MessageStringOf(x) 239 | } 240 | 241 | func (*FindOneRequest) ProtoMessage() {} 242 | 243 | func (x *FindOneRequest) ProtoReflect() protoreflect.Message { 244 | mi := &file_pkg_pb_product_proto_msgTypes[3] 245 | if protoimpl.UnsafeEnabled && x != nil { 246 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 247 | if ms.LoadMessageInfo() == nil { 248 | ms.StoreMessageInfo(mi) 249 | } 250 | return ms 251 | } 252 | return mi.MessageOf(x) 253 | } 254 | 255 | // Deprecated: Use FindOneRequest.ProtoReflect.Descriptor instead. 256 | func (*FindOneRequest) Descriptor() ([]byte, []int) { 257 | return file_pkg_pb_product_proto_rawDescGZIP(), []int{3} 258 | } 259 | 260 | func (x *FindOneRequest) GetId() int64 { 261 | if x != nil { 262 | return x.Id 263 | } 264 | return 0 265 | } 266 | 267 | type FindOneResponse struct { 268 | state protoimpl.MessageState 269 | sizeCache protoimpl.SizeCache 270 | unknownFields protoimpl.UnknownFields 271 | 272 | Status int64 `protobuf:"varint,1,opt,name=status,proto3" json:"status,omitempty"` 273 | Error string `protobuf:"bytes,2,opt,name=error,proto3" json:"error,omitempty"` 274 | Data *FindOneData `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"` 275 | } 276 | 277 | func (x *FindOneResponse) Reset() { 278 | *x = FindOneResponse{} 279 | if protoimpl.UnsafeEnabled { 280 | mi := &file_pkg_pb_product_proto_msgTypes[4] 281 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 282 | ms.StoreMessageInfo(mi) 283 | } 284 | } 285 | 286 | func (x *FindOneResponse) String() string { 287 | return protoimpl.X.MessageStringOf(x) 288 | } 289 | 290 | func (*FindOneResponse) ProtoMessage() {} 291 | 292 | func (x *FindOneResponse) ProtoReflect() protoreflect.Message { 293 | mi := &file_pkg_pb_product_proto_msgTypes[4] 294 | if protoimpl.UnsafeEnabled && x != nil { 295 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 296 | if ms.LoadMessageInfo() == nil { 297 | ms.StoreMessageInfo(mi) 298 | } 299 | return ms 300 | } 301 | return mi.MessageOf(x) 302 | } 303 | 304 | // Deprecated: Use FindOneResponse.ProtoReflect.Descriptor instead. 305 | func (*FindOneResponse) Descriptor() ([]byte, []int) { 306 | return file_pkg_pb_product_proto_rawDescGZIP(), []int{4} 307 | } 308 | 309 | func (x *FindOneResponse) GetStatus() int64 { 310 | if x != nil { 311 | return x.Status 312 | } 313 | return 0 314 | } 315 | 316 | func (x *FindOneResponse) GetError() string { 317 | if x != nil { 318 | return x.Error 319 | } 320 | return "" 321 | } 322 | 323 | func (x *FindOneResponse) GetData() *FindOneData { 324 | if x != nil { 325 | return x.Data 326 | } 327 | return nil 328 | } 329 | 330 | type DecreaseStockRequest struct { 331 | state protoimpl.MessageState 332 | sizeCache protoimpl.SizeCache 333 | unknownFields protoimpl.UnknownFields 334 | 335 | Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` 336 | OrderId int64 `protobuf:"varint,2,opt,name=orderId,proto3" json:"orderId,omitempty"` 337 | } 338 | 339 | func (x *DecreaseStockRequest) Reset() { 340 | *x = DecreaseStockRequest{} 341 | if protoimpl.UnsafeEnabled { 342 | mi := &file_pkg_pb_product_proto_msgTypes[5] 343 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 344 | ms.StoreMessageInfo(mi) 345 | } 346 | } 347 | 348 | func (x *DecreaseStockRequest) String() string { 349 | return protoimpl.X.MessageStringOf(x) 350 | } 351 | 352 | func (*DecreaseStockRequest) ProtoMessage() {} 353 | 354 | func (x *DecreaseStockRequest) ProtoReflect() protoreflect.Message { 355 | mi := &file_pkg_pb_product_proto_msgTypes[5] 356 | if protoimpl.UnsafeEnabled && x != nil { 357 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 358 | if ms.LoadMessageInfo() == nil { 359 | ms.StoreMessageInfo(mi) 360 | } 361 | return ms 362 | } 363 | return mi.MessageOf(x) 364 | } 365 | 366 | // Deprecated: Use DecreaseStockRequest.ProtoReflect.Descriptor instead. 367 | func (*DecreaseStockRequest) Descriptor() ([]byte, []int) { 368 | return file_pkg_pb_product_proto_rawDescGZIP(), []int{5} 369 | } 370 | 371 | func (x *DecreaseStockRequest) GetId() int64 { 372 | if x != nil { 373 | return x.Id 374 | } 375 | return 0 376 | } 377 | 378 | func (x *DecreaseStockRequest) GetOrderId() int64 { 379 | if x != nil { 380 | return x.OrderId 381 | } 382 | return 0 383 | } 384 | 385 | type DecreaseStockResponse struct { 386 | state protoimpl.MessageState 387 | sizeCache protoimpl.SizeCache 388 | unknownFields protoimpl.UnknownFields 389 | 390 | Status int64 `protobuf:"varint,1,opt,name=status,proto3" json:"status,omitempty"` 391 | Error string `protobuf:"bytes,2,opt,name=error,proto3" json:"error,omitempty"` 392 | } 393 | 394 | func (x *DecreaseStockResponse) Reset() { 395 | *x = DecreaseStockResponse{} 396 | if protoimpl.UnsafeEnabled { 397 | mi := &file_pkg_pb_product_proto_msgTypes[6] 398 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 399 | ms.StoreMessageInfo(mi) 400 | } 401 | } 402 | 403 | func (x *DecreaseStockResponse) String() string { 404 | return protoimpl.X.MessageStringOf(x) 405 | } 406 | 407 | func (*DecreaseStockResponse) ProtoMessage() {} 408 | 409 | func (x *DecreaseStockResponse) ProtoReflect() protoreflect.Message { 410 | mi := &file_pkg_pb_product_proto_msgTypes[6] 411 | if protoimpl.UnsafeEnabled && x != nil { 412 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) 413 | if ms.LoadMessageInfo() == nil { 414 | ms.StoreMessageInfo(mi) 415 | } 416 | return ms 417 | } 418 | return mi.MessageOf(x) 419 | } 420 | 421 | // Deprecated: Use DecreaseStockResponse.ProtoReflect.Descriptor instead. 422 | func (*DecreaseStockResponse) Descriptor() ([]byte, []int) { 423 | return file_pkg_pb_product_proto_rawDescGZIP(), []int{6} 424 | } 425 | 426 | func (x *DecreaseStockResponse) GetStatus() int64 { 427 | if x != nil { 428 | return x.Status 429 | } 430 | return 0 431 | } 432 | 433 | func (x *DecreaseStockResponse) GetError() string { 434 | if x != nil { 435 | return x.Error 436 | } 437 | return "" 438 | } 439 | 440 | var File_pkg_pb_product_proto protoreflect.FileDescriptor 441 | 442 | var file_pkg_pb_product_proto_rawDesc = []byte{ 443 | 0x0a, 0x14, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x62, 0x2f, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 444 | 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x07, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x22, 445 | 0x56, 0x0a, 0x14, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 446 | 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 447 | 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x73, 448 | 0x74, 0x6f, 0x63, 0x6b, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x73, 0x74, 0x6f, 0x63, 449 | 0x6b, 0x12, 0x14, 0x0a, 0x05, 0x70, 0x72, 0x69, 0x63, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 450 | 0x52, 0x05, 0x70, 0x72, 0x69, 0x63, 0x65, 0x22, 0x55, 0x0a, 0x15, 0x43, 0x72, 0x65, 0x61, 0x74, 451 | 0x65, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 452 | 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 453 | 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 454 | 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x12, 0x0e, 455 | 0x0a, 0x02, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x22, 0x5d, 456 | 0x0a, 0x0b, 0x46, 0x69, 0x6e, 0x64, 0x4f, 0x6e, 0x65, 0x44, 0x61, 0x74, 0x61, 0x12, 0x0e, 0x0a, 457 | 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 458 | 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 459 | 0x65, 0x12, 0x14, 0x0a, 0x05, 0x73, 0x74, 0x6f, 0x63, 0x6b, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 460 | 0x52, 0x05, 0x73, 0x74, 0x6f, 0x63, 0x6b, 0x12, 0x14, 0x0a, 0x05, 0x70, 0x72, 0x69, 0x63, 0x65, 461 | 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x70, 0x72, 0x69, 0x63, 0x65, 0x22, 0x20, 0x0a, 462 | 0x0e, 0x46, 0x69, 0x6e, 0x64, 0x4f, 0x6e, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 463 | 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x22, 464 | 0x69, 0x0a, 0x0f, 0x46, 0x69, 0x6e, 0x64, 0x4f, 0x6e, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 465 | 0x73, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x01, 0x20, 0x01, 466 | 0x28, 0x03, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x72, 467 | 0x72, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 468 | 0x12, 0x28, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 469 | 0x2e, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x2e, 0x46, 0x69, 0x6e, 0x64, 0x4f, 0x6e, 0x65, 470 | 0x44, 0x61, 0x74, 0x61, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x40, 0x0a, 0x14, 0x44, 0x65, 471 | 0x63, 0x72, 0x65, 0x61, 0x73, 0x65, 0x53, 0x74, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 472 | 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 473 | 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x49, 0x64, 0x18, 0x02, 0x20, 474 | 0x01, 0x28, 0x03, 0x52, 0x07, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x49, 0x64, 0x22, 0x45, 0x0a, 0x15, 475 | 0x44, 0x65, 0x63, 0x72, 0x65, 0x61, 0x73, 0x65, 0x53, 0x74, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x73, 476 | 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 477 | 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x14, 0x0a, 478 | 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x72, 479 | 0x72, 0x6f, 0x72, 0x32, 0xee, 0x01, 0x0a, 0x0e, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x53, 480 | 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x4e, 0x0a, 0x0d, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 481 | 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x12, 0x1d, 0x2e, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 482 | 0x74, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x52, 483 | 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1e, 0x2e, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 484 | 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x52, 0x65, 485 | 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3c, 0x0a, 0x07, 0x46, 0x69, 0x6e, 0x64, 0x4f, 0x6e, 486 | 0x65, 0x12, 0x17, 0x2e, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x2e, 0x46, 0x69, 0x6e, 0x64, 487 | 0x4f, 0x6e, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x70, 0x72, 0x6f, 488 | 0x64, 0x75, 0x63, 0x74, 0x2e, 0x46, 0x69, 0x6e, 0x64, 0x4f, 0x6e, 0x65, 0x52, 0x65, 0x73, 0x70, 489 | 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x4e, 0x0a, 0x0d, 0x44, 0x65, 0x63, 0x72, 0x65, 0x61, 0x73, 0x65, 490 | 0x53, 0x74, 0x6f, 0x63, 0x6b, 0x12, 0x1d, 0x2e, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x2e, 491 | 0x44, 0x65, 0x63, 0x72, 0x65, 0x61, 0x73, 0x65, 0x53, 0x74, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x71, 492 | 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1e, 0x2e, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x2e, 0x44, 493 | 0x65, 0x63, 0x72, 0x65, 0x61, 0x73, 0x65, 0x53, 0x74, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 494 | 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x0a, 0x5a, 0x08, 0x2e, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x62, 495 | 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 496 | } 497 | 498 | var ( 499 | file_pkg_pb_product_proto_rawDescOnce sync.Once 500 | file_pkg_pb_product_proto_rawDescData = file_pkg_pb_product_proto_rawDesc 501 | ) 502 | 503 | func file_pkg_pb_product_proto_rawDescGZIP() []byte { 504 | file_pkg_pb_product_proto_rawDescOnce.Do(func() { 505 | file_pkg_pb_product_proto_rawDescData = protoimpl.X.CompressGZIP(file_pkg_pb_product_proto_rawDescData) 506 | }) 507 | return file_pkg_pb_product_proto_rawDescData 508 | } 509 | 510 | var file_pkg_pb_product_proto_msgTypes = make([]protoimpl.MessageInfo, 7) 511 | var file_pkg_pb_product_proto_goTypes = []interface{}{ 512 | (*CreateProductRequest)(nil), // 0: product.CreateProductRequest 513 | (*CreateProductResponse)(nil), // 1: product.CreateProductResponse 514 | (*FindOneData)(nil), // 2: product.FindOneData 515 | (*FindOneRequest)(nil), // 3: product.FindOneRequest 516 | (*FindOneResponse)(nil), // 4: product.FindOneResponse 517 | (*DecreaseStockRequest)(nil), // 5: product.DecreaseStockRequest 518 | (*DecreaseStockResponse)(nil), // 6: product.DecreaseStockResponse 519 | } 520 | var file_pkg_pb_product_proto_depIdxs = []int32{ 521 | 2, // 0: product.FindOneResponse.data:type_name -> product.FindOneData 522 | 0, // 1: product.ProductService.CreateProduct:input_type -> product.CreateProductRequest 523 | 3, // 2: product.ProductService.FindOne:input_type -> product.FindOneRequest 524 | 5, // 3: product.ProductService.DecreaseStock:input_type -> product.DecreaseStockRequest 525 | 1, // 4: product.ProductService.CreateProduct:output_type -> product.CreateProductResponse 526 | 4, // 5: product.ProductService.FindOne:output_type -> product.FindOneResponse 527 | 6, // 6: product.ProductService.DecreaseStock:output_type -> product.DecreaseStockResponse 528 | 4, // [4:7] is the sub-list for method output_type 529 | 1, // [1:4] is the sub-list for method input_type 530 | 1, // [1:1] is the sub-list for extension type_name 531 | 1, // [1:1] is the sub-list for extension extendee 532 | 0, // [0:1] is the sub-list for field type_name 533 | } 534 | 535 | func init() { file_pkg_pb_product_proto_init() } 536 | func file_pkg_pb_product_proto_init() { 537 | if File_pkg_pb_product_proto != nil { 538 | return 539 | } 540 | if !protoimpl.UnsafeEnabled { 541 | file_pkg_pb_product_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { 542 | switch v := v.(*CreateProductRequest); i { 543 | case 0: 544 | return &v.state 545 | case 1: 546 | return &v.sizeCache 547 | case 2: 548 | return &v.unknownFields 549 | default: 550 | return nil 551 | } 552 | } 553 | file_pkg_pb_product_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { 554 | switch v := v.(*CreateProductResponse); i { 555 | case 0: 556 | return &v.state 557 | case 1: 558 | return &v.sizeCache 559 | case 2: 560 | return &v.unknownFields 561 | default: 562 | return nil 563 | } 564 | } 565 | file_pkg_pb_product_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { 566 | switch v := v.(*FindOneData); i { 567 | case 0: 568 | return &v.state 569 | case 1: 570 | return &v.sizeCache 571 | case 2: 572 | return &v.unknownFields 573 | default: 574 | return nil 575 | } 576 | } 577 | file_pkg_pb_product_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { 578 | switch v := v.(*FindOneRequest); i { 579 | case 0: 580 | return &v.state 581 | case 1: 582 | return &v.sizeCache 583 | case 2: 584 | return &v.unknownFields 585 | default: 586 | return nil 587 | } 588 | } 589 | file_pkg_pb_product_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { 590 | switch v := v.(*FindOneResponse); i { 591 | case 0: 592 | return &v.state 593 | case 1: 594 | return &v.sizeCache 595 | case 2: 596 | return &v.unknownFields 597 | default: 598 | return nil 599 | } 600 | } 601 | file_pkg_pb_product_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { 602 | switch v := v.(*DecreaseStockRequest); i { 603 | case 0: 604 | return &v.state 605 | case 1: 606 | return &v.sizeCache 607 | case 2: 608 | return &v.unknownFields 609 | default: 610 | return nil 611 | } 612 | } 613 | file_pkg_pb_product_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { 614 | switch v := v.(*DecreaseStockResponse); i { 615 | case 0: 616 | return &v.state 617 | case 1: 618 | return &v.sizeCache 619 | case 2: 620 | return &v.unknownFields 621 | default: 622 | return nil 623 | } 624 | } 625 | } 626 | type x struct{} 627 | out := protoimpl.TypeBuilder{ 628 | File: protoimpl.DescBuilder{ 629 | GoPackagePath: reflect.TypeOf(x{}).PkgPath(), 630 | RawDescriptor: file_pkg_pb_product_proto_rawDesc, 631 | NumEnums: 0, 632 | NumMessages: 7, 633 | NumExtensions: 0, 634 | NumServices: 1, 635 | }, 636 | GoTypes: file_pkg_pb_product_proto_goTypes, 637 | DependencyIndexes: file_pkg_pb_product_proto_depIdxs, 638 | MessageInfos: file_pkg_pb_product_proto_msgTypes, 639 | }.Build() 640 | File_pkg_pb_product_proto = out.File 641 | file_pkg_pb_product_proto_rawDesc = nil 642 | file_pkg_pb_product_proto_goTypes = nil 643 | file_pkg_pb_product_proto_depIdxs = nil 644 | } 645 | --------------------------------------------------------------------------------