reinit
This commit is contained in:
@@ -1,36 +0,0 @@
|
||||
# Makefile for backend services
|
||||
|
||||
.PHONY: dev build proto test down logs clean
|
||||
|
||||
dev:
|
||||
@echo "Starting development environment..."
|
||||
@docker-compose -f docker-compose.dev.yml up -d --build
|
||||
@echo "Development environment started successfully!"
|
||||
@docker-compose -f docker-compose.dev.yml ps
|
||||
|
||||
build:
|
||||
@echo "Building production environment..."
|
||||
@docker-compose build
|
||||
|
||||
proto:
|
||||
@echo "Skipping proto compilation as per configuration..."
|
||||
|
||||
test:
|
||||
@echo "Running tests..."
|
||||
@docker-compose -f docker-compose.dev.yml run --rm asset-helper-user-svc sh -c "go test ./..."
|
||||
|
||||
down:
|
||||
@echo "Stopping all services..."
|
||||
@docker-compose down
|
||||
@docker-compose -f docker-compose.dev.yml down
|
||||
|
||||
logs:
|
||||
@echo "Showing logs for development environment..."
|
||||
@docker-compose -f docker-compose.dev.yml logs -f
|
||||
|
||||
clean:
|
||||
@echo "Cleaning up..."
|
||||
@docker-compose down -v
|
||||
@docker-compose -f docker-compose.dev.yml down -v
|
||||
@rm -rf services/user-svc/user/* shared/proto/common/*
|
||||
@echo "Cleanup completed!"
|
||||
@@ -1,118 +0,0 @@
|
||||
# Backend Services
|
||||
|
||||
## 项目结构
|
||||
|
||||
```
|
||||
backend/
|
||||
├── nginx/ # Nginx 配置
|
||||
├── gateway/ # WebSocket 网关服务
|
||||
├── services/
|
||||
│ └── user-svc/ # 用户微服务
|
||||
├── shared/ # 公共工具包
|
||||
│ ├── logger/ # 日志工具
|
||||
│ ├── errors/ # 错误处理
|
||||
│ ├── postgres/ # PostgreSQL 数据库
|
||||
│ ├── redis/ # Redis 缓存
|
||||
│ └── proto/ # 公共 proto 定义
|
||||
├── scripts/ # 自动化脚本
|
||||
├── docker-compose.yml # 生产环境配置
|
||||
├── docker-compose.dev.yml # 开发环境配置
|
||||
├── Makefile # 命令封装
|
||||
└── README.md # 使用说明
|
||||
```
|
||||
|
||||
## 环境要求
|
||||
|
||||
- Docker
|
||||
- Docker Compose
|
||||
|
||||
## 快速开始
|
||||
|
||||
### 开发环境
|
||||
|
||||
1. 一键启动开发环境:
|
||||
|
||||
```bash
|
||||
make dev-start
|
||||
```
|
||||
|
||||
这会自动:
|
||||
- 生成 proto 代码
|
||||
- 构建开发环境镜像
|
||||
- 启动所有服务
|
||||
- 显示服务状态
|
||||
|
||||
2. 查看服务状态:
|
||||
|
||||
```bash
|
||||
make dev-status
|
||||
```
|
||||
|
||||
3. 查看服务日志:
|
||||
|
||||
```bash
|
||||
make dev-logs
|
||||
```
|
||||
|
||||
4. 停止开发环境:
|
||||
|
||||
```bash
|
||||
make dev-down
|
||||
```
|
||||
|
||||
### 生产环境
|
||||
|
||||
1. 构建生产环境:
|
||||
|
||||
```bash
|
||||
make build
|
||||
```
|
||||
|
||||
2. 启动生产环境:
|
||||
|
||||
```bash
|
||||
make up
|
||||
```
|
||||
|
||||
3. 停止生产环境:
|
||||
|
||||
```bash
|
||||
make down
|
||||
```
|
||||
|
||||
## 其他命令
|
||||
|
||||
### 生成 proto 代码
|
||||
|
||||
```bash
|
||||
make gen-proto
|
||||
```
|
||||
|
||||
### 运行测试
|
||||
|
||||
```bash
|
||||
make test
|
||||
```
|
||||
|
||||
## 服务端口
|
||||
|
||||
- Nginx: 80
|
||||
- Gateway: 8080
|
||||
- User Service: 50051
|
||||
- PostgreSQL: 5432
|
||||
- Redis: 6379
|
||||
|
||||
## 技术栈
|
||||
|
||||
- Go 1.26.1
|
||||
- gRPC
|
||||
- PostgreSQL
|
||||
- Redis
|
||||
- Nginx
|
||||
- Docker
|
||||
|
||||
## 注意事项
|
||||
|
||||
- 所有服务都在 Docker 容器中运行,无宿主机依赖
|
||||
- 服务之间通过内部网络通信
|
||||
- 数据持久化使用 Docker 卷
|
||||
@@ -1,292 +0,0 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.36.11
|
||||
// protoc v6.31.1
|
||||
// source: shared/proto/common.proto
|
||||
|
||||
package common
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
unsafe "unsafe"
|
||||
)
|
||||
|
||||
const (
|
||||
// Verify that this generated code is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
type Empty struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *Empty) Reset() {
|
||||
*x = Empty{}
|
||||
mi := &file_shared_proto_common_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *Empty) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*Empty) ProtoMessage() {}
|
||||
|
||||
func (x *Empty) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_shared_proto_common_proto_msgTypes[0]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use Empty.ProtoReflect.Descriptor instead.
|
||||
func (*Empty) Descriptor() ([]byte, []int) {
|
||||
return file_shared_proto_common_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
type Status struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"`
|
||||
Message string `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"`
|
||||
Code string `protobuf:"bytes,3,opt,name=code,proto3" json:"code,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *Status) Reset() {
|
||||
*x = Status{}
|
||||
mi := &file_shared_proto_common_proto_msgTypes[1]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *Status) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*Status) ProtoMessage() {}
|
||||
|
||||
func (x *Status) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_shared_proto_common_proto_msgTypes[1]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use Status.ProtoReflect.Descriptor instead.
|
||||
func (*Status) Descriptor() ([]byte, []int) {
|
||||
return file_shared_proto_common_proto_rawDescGZIP(), []int{1}
|
||||
}
|
||||
|
||||
func (x *Status) GetSuccess() bool {
|
||||
if x != nil {
|
||||
return x.Success
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (x *Status) GetMessage() string {
|
||||
if x != nil {
|
||||
return x.Message
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *Status) GetCode() string {
|
||||
if x != nil {
|
||||
return x.Code
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type Pagination struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Page int32 `protobuf:"varint,1,opt,name=page,proto3" json:"page,omitempty"`
|
||||
PageSize int32 `protobuf:"varint,2,opt,name=page_size,json=pageSize,proto3" json:"page_size,omitempty"`
|
||||
Total int32 `protobuf:"varint,3,opt,name=total,proto3" json:"total,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *Pagination) Reset() {
|
||||
*x = Pagination{}
|
||||
mi := &file_shared_proto_common_proto_msgTypes[2]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *Pagination) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*Pagination) ProtoMessage() {}
|
||||
|
||||
func (x *Pagination) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_shared_proto_common_proto_msgTypes[2]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use Pagination.ProtoReflect.Descriptor instead.
|
||||
func (*Pagination) Descriptor() ([]byte, []int) {
|
||||
return file_shared_proto_common_proto_rawDescGZIP(), []int{2}
|
||||
}
|
||||
|
||||
func (x *Pagination) GetPage() int32 {
|
||||
if x != nil {
|
||||
return x.Page
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *Pagination) GetPageSize() int32 {
|
||||
if x != nil {
|
||||
return x.PageSize
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *Pagination) GetTotal() int32 {
|
||||
if x != nil {
|
||||
return x.Total
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
type IdRequest struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *IdRequest) Reset() {
|
||||
*x = IdRequest{}
|
||||
mi := &file_shared_proto_common_proto_msgTypes[3]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *IdRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*IdRequest) ProtoMessage() {}
|
||||
|
||||
func (x *IdRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_shared_proto_common_proto_msgTypes[3]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use IdRequest.ProtoReflect.Descriptor instead.
|
||||
func (*IdRequest) Descriptor() ([]byte, []int) {
|
||||
return file_shared_proto_common_proto_rawDescGZIP(), []int{3}
|
||||
}
|
||||
|
||||
func (x *IdRequest) GetId() string {
|
||||
if x != nil {
|
||||
return x.Id
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
var File_shared_proto_common_proto protoreflect.FileDescriptor
|
||||
|
||||
const file_shared_proto_common_proto_rawDesc = "" +
|
||||
"\n" +
|
||||
"\x19shared/proto/common.proto\x12\x06common\"\a\n" +
|
||||
"\x05Empty\"P\n" +
|
||||
"\x06Status\x12\x18\n" +
|
||||
"\asuccess\x18\x01 \x01(\bR\asuccess\x12\x18\n" +
|
||||
"\amessage\x18\x02 \x01(\tR\amessage\x12\x12\n" +
|
||||
"\x04code\x18\x03 \x01(\tR\x04code\"S\n" +
|
||||
"\n" +
|
||||
"Pagination\x12\x12\n" +
|
||||
"\x04page\x18\x01 \x01(\x05R\x04page\x12\x1b\n" +
|
||||
"\tpage_size\x18\x02 \x01(\x05R\bpageSize\x12\x14\n" +
|
||||
"\x05total\x18\x03 \x01(\x05R\x05total\"\x1b\n" +
|
||||
"\tIdRequest\x12\x0e\n" +
|
||||
"\x02id\x18\x01 \x01(\tR\x02idB\n" +
|
||||
"Z\b./commonb\x06proto3"
|
||||
|
||||
var (
|
||||
file_shared_proto_common_proto_rawDescOnce sync.Once
|
||||
file_shared_proto_common_proto_rawDescData []byte
|
||||
)
|
||||
|
||||
func file_shared_proto_common_proto_rawDescGZIP() []byte {
|
||||
file_shared_proto_common_proto_rawDescOnce.Do(func() {
|
||||
file_shared_proto_common_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_shared_proto_common_proto_rawDesc), len(file_shared_proto_common_proto_rawDesc)))
|
||||
})
|
||||
return file_shared_proto_common_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_shared_proto_common_proto_msgTypes = make([]protoimpl.MessageInfo, 4)
|
||||
var file_shared_proto_common_proto_goTypes = []any{
|
||||
(*Empty)(nil), // 0: common.Empty
|
||||
(*Status)(nil), // 1: common.Status
|
||||
(*Pagination)(nil), // 2: common.Pagination
|
||||
(*IdRequest)(nil), // 3: common.IdRequest
|
||||
}
|
||||
var file_shared_proto_common_proto_depIdxs = []int32{
|
||||
0, // [0:0] is the sub-list for method output_type
|
||||
0, // [0:0] is the sub-list for method input_type
|
||||
0, // [0:0] is the sub-list for extension type_name
|
||||
0, // [0:0] is the sub-list for extension extendee
|
||||
0, // [0:0] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_shared_proto_common_proto_init() }
|
||||
func file_shared_proto_common_proto_init() {
|
||||
if File_shared_proto_common_proto != nil {
|
||||
return
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: unsafe.Slice(unsafe.StringData(file_shared_proto_common_proto_rawDesc), len(file_shared_proto_common_proto_rawDesc)),
|
||||
NumEnums: 0,
|
||||
NumMessages: 4,
|
||||
NumExtensions: 0,
|
||||
NumServices: 0,
|
||||
},
|
||||
GoTypes: file_shared_proto_common_proto_goTypes,
|
||||
DependencyIndexes: file_shared_proto_common_proto_depIdxs,
|
||||
MessageInfos: file_shared_proto_common_proto_msgTypes,
|
||||
}.Build()
|
||||
File_shared_proto_common_proto = out.File
|
||||
file_shared_proto_common_proto_goTypes = nil
|
||||
file_shared_proto_common_proto_depIdxs = nil
|
||||
}
|
||||
@@ -1,86 +0,0 @@
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
asset-helper-nginx:
|
||||
image: nginx:1.25-alpine
|
||||
container_name: asset-helper-nginx-dev
|
||||
ports:
|
||||
- "80:80"
|
||||
volumes:
|
||||
- ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro
|
||||
depends_on:
|
||||
- asset-helper-gateway
|
||||
networks:
|
||||
- asset-helper-network
|
||||
|
||||
asset-helper-gateway:
|
||||
build:
|
||||
context: ./gateway
|
||||
dockerfile: Dockerfile
|
||||
image: asset-helper-gateway
|
||||
container_name: asset-helper-gateway-dev
|
||||
ports:
|
||||
- "8080:8080"
|
||||
environment:
|
||||
- GO_ENV=development
|
||||
- REDIS_ADDR=asset-helper-redis:6379
|
||||
volumes:
|
||||
- ./gateway:/app
|
||||
depends_on:
|
||||
- asset-helper-redis
|
||||
networks:
|
||||
- asset-helper-network
|
||||
|
||||
asset-helper-user-svc:
|
||||
build:
|
||||
context: ./services/user-svc
|
||||
dockerfile: Dockerfile
|
||||
image: asset-helper-user-svc
|
||||
container_name: asset-helper-user-svc-dev
|
||||
ports:
|
||||
- "50051:50051"
|
||||
environment:
|
||||
- GO_ENV=development
|
||||
- POSTGRES_HOST=asset-helper-postgres
|
||||
- POSTGRES_PORT=5432
|
||||
- POSTGRES_USER=admin
|
||||
- POSTGRES_PASSWORD=password
|
||||
- POSTGRES_DB=userdb
|
||||
volumes:
|
||||
- ./services/user-svc:/app
|
||||
depends_on:
|
||||
- asset-helper-postgres
|
||||
networks:
|
||||
- asset-helper-network
|
||||
|
||||
asset-helper-postgres:
|
||||
image: postgres:18.3-alpine3.23
|
||||
container_name: asset-helper-postgres-dev
|
||||
ports:
|
||||
- "5432:5432"
|
||||
environment:
|
||||
- POSTGRES_USER=admin
|
||||
- POSTGRES_PASSWORD=password
|
||||
- POSTGRES_DB=userdb
|
||||
volumes:
|
||||
- asset-helper-postgres-data:/var/lib/postgresql/data
|
||||
networks:
|
||||
- asset-helper-network
|
||||
|
||||
asset-helper-redis:
|
||||
image: redis:8.6.2-alpine
|
||||
container_name: asset-helper-redis-dev
|
||||
ports:
|
||||
- "6379:6379"
|
||||
volumes:
|
||||
- asset-helper-redis-data:/data
|
||||
networks:
|
||||
- asset-helper-network
|
||||
|
||||
volumes:
|
||||
asset-helper-postgres-data:
|
||||
asset-helper-redis-data:
|
||||
|
||||
networks:
|
||||
asset-helper-network:
|
||||
driver: bridge
|
||||
@@ -1,82 +0,0 @@
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
asset-helper-nginx:
|
||||
image: nginx:1.25-alpine
|
||||
container_name: asset-helper-nginx
|
||||
ports:
|
||||
- "80:80"
|
||||
volumes:
|
||||
- ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro
|
||||
depends_on:
|
||||
- asset-helper-gateway
|
||||
networks:
|
||||
- asset-helper-network
|
||||
|
||||
asset-helper-gateway:
|
||||
build:
|
||||
context: ./gateway
|
||||
dockerfile: Dockerfile
|
||||
image: asset-helper-gateway
|
||||
container_name: asset-helper-gateway
|
||||
ports:
|
||||
- "8080:8080"
|
||||
environment:
|
||||
- GO_ENV=production
|
||||
- REDIS_ADDR=asset-helper-redis:6379
|
||||
depends_on:
|
||||
- asset-helper-redis
|
||||
networks:
|
||||
- asset-helper-network
|
||||
|
||||
asset-helper-user-svc:
|
||||
build:
|
||||
context: ./services/user-svc
|
||||
dockerfile: Dockerfile
|
||||
image: asset-helper-user-svc
|
||||
container_name: asset-helper-user-svc
|
||||
ports:
|
||||
- "50051:50051"
|
||||
environment:
|
||||
- GO_ENV=production
|
||||
- POSTGRES_HOST=asset-helper-postgres
|
||||
- POSTGRES_PORT=5432
|
||||
- POSTGRES_USER=admin
|
||||
- POSTGRES_PASSWORD=password
|
||||
- POSTGRES_DB=userdb
|
||||
depends_on:
|
||||
- asset-helper-postgres
|
||||
networks:
|
||||
- asset-helper-network
|
||||
|
||||
asset-helper-postgres:
|
||||
image: postgres:18.3-alpine3.23
|
||||
container_name: asset-helper-postgres
|
||||
ports:
|
||||
- "5432:5432"
|
||||
environment:
|
||||
- POSTGRES_USER=admin
|
||||
- POSTGRES_PASSWORD=password
|
||||
- POSTGRES_DB=userdb
|
||||
volumes:
|
||||
- asset-helper-postgres-data:/var/lib/postgresql/data
|
||||
networks:
|
||||
- asset-helper-network
|
||||
|
||||
asset-helper-redis:
|
||||
image: redis:8.6.2-alpine
|
||||
container_name: asset-helper-redis
|
||||
ports:
|
||||
- "6379:6379"
|
||||
volumes:
|
||||
- asset-helper-redis-data:/data
|
||||
networks:
|
||||
- asset-helper-network
|
||||
|
||||
volumes:
|
||||
asset-helper-postgres-data:
|
||||
asset-helper-redis-data:
|
||||
|
||||
networks:
|
||||
asset-helper-network:
|
||||
driver: bridge
|
||||
@@ -1,21 +0,0 @@
|
||||
FROM golang:1.26.1-alpine3.23 AS builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
ENV GOPROXY=https://goproxy.cn,direct
|
||||
|
||||
COPY go.mod ./
|
||||
COPY main.go ./
|
||||
|
||||
RUN go mod download
|
||||
RUN go build -o gateway main.go
|
||||
|
||||
FROM alpine:3.23
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY --from=builder /app/gateway .
|
||||
|
||||
EXPOSE 8080
|
||||
|
||||
CMD ["./gateway"]
|
||||
@@ -1,35 +0,0 @@
|
||||
module gateway
|
||||
|
||||
go 1.26
|
||||
|
||||
require (
|
||||
github.com/gin-gonic/gin v1.9.1
|
||||
github.com/gorilla/websocket v1.5.1
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/bytedance/sonic v1.9.1 // indirect
|
||||
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect
|
||||
github.com/gabriel-vasile/mimetype v1.4.2 // indirect
|
||||
github.com/gin-contrib/sse v0.1.0 // indirect
|
||||
github.com/go-playground/locales v0.14.1 // indirect
|
||||
github.com/go-playground/universal-translator v0.18.1 // indirect
|
||||
github.com/go-playground/validator/v10 v10.14.0 // indirect
|
||||
github.com/goccy/go-json v0.10.2 // indirect
|
||||
github.com/json-iterator/go v1.1.12 // indirect
|
||||
github.com/klauspost/cpuid/v2 v2.2.4 // indirect
|
||||
github.com/leodido/go-urn v1.2.4 // indirect
|
||||
github.com/mattn/go-isatty v0.0.19 // indirect
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.0.8 // indirect
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
|
||||
github.com/ugorji/go/codec v1.2.11 // indirect
|
||||
golang.org/x/arch v0.3.0 // indirect
|
||||
golang.org/x/crypto v0.9.0 // indirect
|
||||
golang.org/x/net v0.10.0 // indirect
|
||||
golang.org/x/sys v0.8.0 // indirect
|
||||
golang.org/x/text v0.9.0 // indirect
|
||||
google.golang.org/protobuf v1.30.0 // indirect
|
||||
gopkg.in/yaml.v3 v3 // indirect
|
||||
)
|
||||
@@ -1,155 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/gorilla/websocket"
|
||||
)
|
||||
|
||||
var upgrader = websocket.Upgrader{
|
||||
ReadBufferSize: 1024,
|
||||
WriteBufferSize: 1024,
|
||||
CheckOrigin: func(r *http.Request) bool {
|
||||
return true
|
||||
},
|
||||
}
|
||||
|
||||
type Hub struct {
|
||||
clients map[*Client]bool
|
||||
broadcast chan []byte
|
||||
register chan *Client
|
||||
unregister chan *Client
|
||||
}
|
||||
|
||||
type Client struct {
|
||||
hub *Hub
|
||||
conn *websocket.Conn
|
||||
send chan []byte
|
||||
}
|
||||
|
||||
type Message struct {
|
||||
Type string `json:"type"`
|
||||
Content string `json:"content"`
|
||||
Sender string `json:"sender"`
|
||||
}
|
||||
|
||||
func newHub() *Hub {
|
||||
return &Hub{
|
||||
broadcast: make(chan []byte),
|
||||
register: make(chan *Client),
|
||||
unregister: make(chan *Client),
|
||||
clients: make(map[*Client]bool),
|
||||
}
|
||||
}
|
||||
|
||||
func (h *Hub) run() {
|
||||
for {
|
||||
select {
|
||||
case client := <-h.register:
|
||||
h.clients[client] = true
|
||||
case client := <-h.unregister:
|
||||
if _, ok := h.clients[client]; ok {
|
||||
delete(h.clients, client)
|
||||
close(client.send)
|
||||
}
|
||||
case message := <-h.broadcast:
|
||||
for client := range h.clients {
|
||||
select {
|
||||
case client.send <- message:
|
||||
default:
|
||||
close(client.send)
|
||||
delete(h.clients, client)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Client) readPump() {
|
||||
defer func() {
|
||||
c.hub.unregister <- c
|
||||
c.conn.Close()
|
||||
}()
|
||||
|
||||
for {
|
||||
_, message, err := c.conn.ReadMessage()
|
||||
if err != nil {
|
||||
if websocket.IsUnexpectedCloseError(err, websocket.CloseGoingAway, websocket.CloseAbnormalClosure) {
|
||||
log.Printf("error: %v", err)
|
||||
}
|
||||
break
|
||||
}
|
||||
c.hub.broadcast <- message
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Client) writePump() {
|
||||
defer func() {
|
||||
c.conn.Close()
|
||||
}()
|
||||
|
||||
for {
|
||||
message, ok := <-c.send
|
||||
if !ok {
|
||||
c.conn.WriteMessage(websocket.CloseMessage, []byte{})
|
||||
return
|
||||
}
|
||||
|
||||
w, err := c.conn.NextWriter(websocket.TextMessage)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
w.Write(message)
|
||||
|
||||
n := len(c.send)
|
||||
for i := 0; i < n; i++ {
|
||||
w.Write([]byte("\n"))
|
||||
w.Write(<-c.send)
|
||||
}
|
||||
|
||||
if err := w.Close(); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func handleWebSocket(hub *Hub) gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
conn, err := upgrader.Upgrade(c.Writer, c.Request, nil)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
return
|
||||
}
|
||||
|
||||
client := &Client{
|
||||
hub: hub,
|
||||
conn: conn,
|
||||
send: make(chan []byte, 256),
|
||||
}
|
||||
client.hub.register <- client
|
||||
|
||||
go client.writePump()
|
||||
go client.readPump()
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
hub := newHub()
|
||||
go hub.run()
|
||||
|
||||
r := gin.Default()
|
||||
|
||||
r.GET("/ws", handleWebSocket(hub))
|
||||
r.GET("/health", func(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"status": "ok",
|
||||
})
|
||||
})
|
||||
|
||||
log.Println("Gateway server starting on port 8080...")
|
||||
if err := r.Run(":8080"); err != nil {
|
||||
log.Fatalf("Failed to start server: %v", err)
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
|
||||
http {
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
|
||||
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
|
||||
'$status $body_bytes_sent "$http_referer" '
|
||||
'"$http_user_agent" "$http_x_forwarded_for"';
|
||||
|
||||
access_log /var/log/nginx/access.log main;
|
||||
error_log /var/log/nginx/error.log warn;
|
||||
|
||||
sendfile on;
|
||||
tcp_nopush on;
|
||||
tcp_nodelay on;
|
||||
keepalive_timeout 65;
|
||||
|
||||
upstream gateway {
|
||||
server asset-helper-gateway:8080;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
server_name localhost;
|
||||
|
||||
location / {
|
||||
proxy_pass http://gateway;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_cache_bypass $http_upgrade;
|
||||
}
|
||||
|
||||
location /health {
|
||||
stub_status on;
|
||||
access_log off;
|
||||
allow all;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# 一键开发环境启动脚本
|
||||
|
||||
# 定义颜色
|
||||
GREEN="\033[0;32m"
|
||||
YELLOW="\033[1;33m"
|
||||
RED="\033[0;31m"
|
||||
NC="\033[0m" # No Color
|
||||
|
||||
echo -e "${GREEN}Starting development environment setup...${NC}"
|
||||
|
||||
# 检查 Docker 是否安装
|
||||
if ! command -v docker &> /dev/null; then
|
||||
echo -e "${RED}Docker is not installed! Please install Docker first.${NC}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 检查 Docker Compose 是否安装
|
||||
if ! command -v docker-compose &> /dev/null; then
|
||||
echo -e "${RED}Docker Compose is not installed! Please install Docker Compose first.${NC}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 构建开发环境
|
||||
echo -e "${YELLOW}Building development environment...${NC}"
|
||||
if docker-compose -f docker-compose.dev.yml build; then
|
||||
echo -e "${GREEN}Build completed successfully!${NC}"
|
||||
else
|
||||
echo -e "${RED}Build failed!${NC}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 启动开发环境
|
||||
echo -e "${YELLOW}Starting development environment...${NC}"
|
||||
if docker-compose -f docker-compose.dev.yml up -d; then
|
||||
echo -e "${GREEN}Development environment started successfully!${NC}"
|
||||
else
|
||||
echo -e "${RED}Failed to start development environment!${NC}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 显示服务状态
|
||||
echo -e "${YELLOW}Service status:${NC}"
|
||||
docker-compose -f docker-compose.dev.yml ps
|
||||
|
||||
echo -e "${GREEN}Development environment setup completed!${NC}"
|
||||
echo -e "${YELLOW}To view logs, run: make logs${NC}"
|
||||
echo -e "${YELLOW}To stop the environment, run: make down${NC}"
|
||||
@@ -1,16 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# 生成 proto 代码的脚本 - 本地已有代码直接编译版本
|
||||
|
||||
# 定义颜色
|
||||
GREEN="\033[0;32m"
|
||||
YELLOW="\033[1;33m"
|
||||
RED="\033[0;31m"
|
||||
NC="\033[0m" # No Color
|
||||
|
||||
echo -e "${GREEN}Starting proto compilation...${NC}"
|
||||
|
||||
echo -e "${YELLOW}Skipping proto compilation as per configuration...${NC}"
|
||||
echo -e "${YELLOW}Using existing proto code if available...${NC}"
|
||||
|
||||
echo -e "${GREEN}Proto compilation step completed!${NC}"
|
||||
@@ -1,21 +0,0 @@
|
||||
FROM golang:1.26.1-alpine3.23 AS builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
ENV GOPROXY=https://goproxy.cn,direct
|
||||
|
||||
COPY go.mod ./
|
||||
COPY main.go ./
|
||||
|
||||
RUN go mod download
|
||||
RUN go build -o user-svc main.go
|
||||
|
||||
FROM alpine:3.23
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY --from=builder /app/user-svc .
|
||||
|
||||
EXPOSE 50051
|
||||
|
||||
CMD ["./user-svc"]
|
||||
@@ -1,9 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# 生成 gRPC 代码
|
||||
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
|
||||
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
|
||||
|
||||
protoc --go_out=. --go-grpc_out=. user.proto
|
||||
|
||||
echo "gRPC code generated successfully!"
|
||||
@@ -1,40 +0,0 @@
|
||||
module user-svc
|
||||
|
||||
go 1.26
|
||||
|
||||
require (
|
||||
google.golang.org/grpc v1.58.0
|
||||
gorm.io/driver/sqlite v1.5.4
|
||||
gorm.io/gorm v1.25.5
|
||||
google.golang.org/protobuf v1.31.0
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/bytedance/sonic v1.9.1 // indirect
|
||||
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect
|
||||
github.com/gabriel-vasile/mimetype v1.4.2 // indirect
|
||||
github.com/gin-contrib/sse v0.1.0 // indirect
|
||||
github.com/go-playground/locales v0.14.1 // indirect
|
||||
github.com/go-playground/universal-translator v0.18.1 // indirect
|
||||
github.com/go-playground/validator/v10 v10.14.0 // indirect
|
||||
github.com/goccy/go-json v0.10.2 // indirect
|
||||
github.com/jinzhu/inflection v1.0.0 // indirect
|
||||
github.com/jinzhu/now v1.1.5 // indirect
|
||||
github.com/json-iterator/go v1.1.12 // indirect
|
||||
github.com/klauspost/cpuid/v2 v2.2.4 // indirect
|
||||
github.com/leodido/go-urn v1.2.4 // indirect
|
||||
github.com/mattn/go-isatty v0.0.19 // indirect
|
||||
github.com/mattn/go-sqlite3 v1.14.17 // indirect
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.0.8 // indirect
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
|
||||
github.com/ugorji/go/codec v1.2.11 // indirect
|
||||
golang.org/x/arch v0.3.0 // indirect
|
||||
golang.org/x/crypto v0.9.0 // indirect
|
||||
golang.org/x/net v0.10.0 // indirect
|
||||
golang.org/x/sys v0.8.0 // indirect
|
||||
golang.org/x/text v0.9.0 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.12.0 // indirect
|
||||
gopkg.in/yaml.v3 v3 // indirect
|
||||
)
|
||||
@@ -1,156 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"log"
|
||||
"net"
|
||||
"user-svc/user"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
"gorm.io/driver/sqlite"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type User struct {
|
||||
ID string `json:"id" gorm:"primaryKey"`
|
||||
Name string `json:"name"`
|
||||
Email string `json:"email"`
|
||||
Password string `json:"password"`
|
||||
}
|
||||
|
||||
type UserServiceServer struct {
|
||||
user.UnimplementedUserServiceServer
|
||||
db *gorm.DB
|
||||
}
|
||||
|
||||
func (s *UserServiceServer) CreateUser(ctx context.Context, req *user.CreateUserRequest) (*user.CreateUserResponse, error) {
|
||||
newUser := User{
|
||||
ID: fmt.Sprintf("%d", len(s.getAllUsers())+1),
|
||||
Name: req.Name,
|
||||
Email: req.Email,
|
||||
Password: req.Password,
|
||||
}
|
||||
|
||||
result := s.db.Create(&newUser)
|
||||
if result.Error != nil {
|
||||
return nil, result.Error
|
||||
}
|
||||
|
||||
return &user.CreateUserResponse{
|
||||
User: &user.User{
|
||||
Id: newUser.ID,
|
||||
Name: newUser.Name,
|
||||
Email: newUser.Email,
|
||||
Password: newUser.Password,
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *UserServiceServer) GetUser(ctx context.Context, req *user.GetUserRequest) (*user.GetUserResponse, error) {
|
||||
var user User
|
||||
result := s.db.First(&user, "id = ?", req.Id)
|
||||
if result.Error != nil {
|
||||
return nil, result.Error
|
||||
}
|
||||
|
||||
return &user.GetUserResponse{
|
||||
User: &user.User{
|
||||
Id: user.ID,
|
||||
Name: user.Name,
|
||||
Email: user.Email,
|
||||
Password: user.Password,
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *UserServiceServer) ListUsers(ctx context.Context, req *user.ListUsersRequest) (*user.ListUsersResponse, error) {
|
||||
users := s.getAllUsers()
|
||||
var protoUsers []*user.User
|
||||
|
||||
for _, u := range users {
|
||||
protoUsers = append(protoUsers, &user.User{
|
||||
Id: u.ID,
|
||||
Name: u.Name,
|
||||
Email: u.Email,
|
||||
Password: u.Password,
|
||||
})
|
||||
}
|
||||
|
||||
return &user.ListUsersResponse{
|
||||
Users: protoUsers,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *UserServiceServer) UpdateUser(ctx context.Context, req *user.UpdateUserRequest) (*user.UpdateUserResponse, error) {
|
||||
var user User
|
||||
result := s.db.First(&user, "id = ?", req.Id)
|
||||
if result.Error != nil {
|
||||
return nil, result.Error
|
||||
}
|
||||
|
||||
if req.Name != "" {
|
||||
user.Name = req.Name
|
||||
}
|
||||
if req.Email != "" {
|
||||
user.Email = req.Email
|
||||
}
|
||||
if req.Password != "" {
|
||||
user.Password = req.Password
|
||||
}
|
||||
|
||||
s.db.Save(&user)
|
||||
|
||||
return &user.UpdateUserResponse{
|
||||
User: &user.User{
|
||||
Id: user.ID,
|
||||
Name: user.Name,
|
||||
Email: user.Email,
|
||||
Password: user.Password,
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *UserServiceServer) DeleteUser(ctx context.Context, req *user.DeleteUserRequest) (*user.DeleteUserResponse, error) {
|
||||
result := s.db.Delete(&User{}, "id = ?", req.Id)
|
||||
if result.Error != nil {
|
||||
return nil, result.Error
|
||||
}
|
||||
|
||||
return &user.DeleteUserResponse{
|
||||
Success: true,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *UserServiceServer) getAllUsers() []User {
|
||||
var users []User
|
||||
s.db.Find(&users)
|
||||
return users
|
||||
}
|
||||
|
||||
func initDB() *gorm.DB {
|
||||
db, err := gorm.Open(sqlite.Open("users.db"), &gorm.Config{})
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to connect to database: %v", err)
|
||||
}
|
||||
|
||||
db.AutoMigrate(&User{})
|
||||
return db
|
||||
}
|
||||
|
||||
func main() {
|
||||
db := initDB()
|
||||
|
||||
server := grpc.NewServer()
|
||||
user.RegisterUserServiceServer(server, &UserServiceServer{db: db})
|
||||
|
||||
listener, err := net.Listen("tcp", ":50051")
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to listen: %v", err)
|
||||
}
|
||||
|
||||
log.Println("User service starting on port 50051...")
|
||||
if err := server.Serve(listener); err != nil {
|
||||
log.Fatalf("Failed to serve: %v", err)
|
||||
}
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package user;
|
||||
|
||||
option go_package = "./user";
|
||||
|
||||
message User {
|
||||
string id = 1;
|
||||
string name = 2;
|
||||
string email = 3;
|
||||
string password = 4;
|
||||
}
|
||||
|
||||
message CreateUserRequest {
|
||||
string name = 1;
|
||||
string email = 2;
|
||||
string password = 3;
|
||||
}
|
||||
|
||||
message CreateUserResponse {
|
||||
User user = 1;
|
||||
}
|
||||
|
||||
message GetUserRequest {
|
||||
string id = 1;
|
||||
}
|
||||
|
||||
message GetUserResponse {
|
||||
User user = 1;
|
||||
}
|
||||
|
||||
message ListUsersRequest {
|
||||
}
|
||||
|
||||
message ListUsersResponse {
|
||||
repeated User users = 1;
|
||||
}
|
||||
|
||||
message UpdateUserRequest {
|
||||
string id = 1;
|
||||
string name = 2;
|
||||
string email = 3;
|
||||
string password = 4;
|
||||
}
|
||||
|
||||
message UpdateUserResponse {
|
||||
User user = 1;
|
||||
}
|
||||
|
||||
message DeleteUserRequest {
|
||||
string id = 1;
|
||||
}
|
||||
|
||||
message DeleteUserResponse {
|
||||
bool success = 1;
|
||||
}
|
||||
|
||||
service UserService {
|
||||
rpc CreateUser(CreateUserRequest) returns (CreateUserResponse);
|
||||
rpc GetUser(GetUserRequest) returns (GetUserResponse);
|
||||
rpc ListUsers(ListUsersRequest) returns (ListUsersResponse);
|
||||
rpc UpdateUser(UpdateUserRequest) returns (UpdateUserResponse);
|
||||
rpc DeleteUser(DeleteUserRequest) returns (DeleteUserResponse);
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
package errors
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type AppError struct {
|
||||
Code string
|
||||
Message string
|
||||
Err error
|
||||
}
|
||||
|
||||
func (e *AppError) Error() string {
|
||||
if e.Err != nil {
|
||||
return fmt.Sprintf("%s: %s (code: %s)", e.Message, e.Err.Error(), e.Code)
|
||||
}
|
||||
return fmt.Sprintf("%s (code: %s)", e.Message, e.Code)
|
||||
}
|
||||
|
||||
func (e *AppError) Unwrap() error {
|
||||
return e.Err
|
||||
}
|
||||
|
||||
func NewAppError(code, message string, err error) *AppError {
|
||||
return &AppError{
|
||||
Code: code,
|
||||
Message: message,
|
||||
Err: err,
|
||||
}
|
||||
}
|
||||
|
||||
func NewBadRequestError(message string, err error) *AppError {
|
||||
return NewAppError("BAD_REQUEST", message, err)
|
||||
}
|
||||
|
||||
func NewInternalError(message string, err error) *AppError {
|
||||
return NewAppError("INTERNAL_ERROR", message, err)
|
||||
}
|
||||
|
||||
func NewNotFoundError(message string, err error) *AppError {
|
||||
return NewAppError("NOT_FOUND", message, err)
|
||||
}
|
||||
|
||||
func NewUnauthorizedError(message string, err error) *AppError {
|
||||
return NewAppError("UNAUTHORIZED", message, err)
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
module shared
|
||||
|
||||
go 1.26
|
||||
|
||||
require (
|
||||
github.com/go-redis/redis/v8 v8.11.5
|
||||
github.com/rs/zerolog v1.30.0
|
||||
gorm.io/driver/postgres v1.5.4
|
||||
gorm.io/gorm v1.25.5
|
||||
google.golang.org/protobuf v1.31.0
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/bytedance/sonic v1.9.1 // indirect
|
||||
github.com/cespare/xxhash/v2 v2.2.0 // indirect
|
||||
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect
|
||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
|
||||
github.com/gabriel-vasile/mimetype v1.4.2 // indirect
|
||||
github.com/gin-contrib/sse v0.1.0 // indirect
|
||||
github.com/go-playground/locales v0.14.1 // indirect
|
||||
github.com/go-playground/universal-translator v0.18.1 // indirect
|
||||
github.com/go-playground/validator/v10 v10.14.0 // indirect
|
||||
github.com/goccy/go-json v0.10.2 // indirect
|
||||
github.com/jackc/pgpassfile v1.0.0 // indirect
|
||||
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect
|
||||
github.com/jackc/pgx/v5 v5.4.3 // indirect
|
||||
github.com/jinzhu/inflection v1.0.0 // indirect
|
||||
github.com/jinzhu/now v1.1.5 // indirect
|
||||
github.com/json-iterator/go v1.1.12 // indirect
|
||||
github.com/klauspost/cpuid/v2 v2.2.4 // indirect
|
||||
github.com/leodido/go-urn v1.2.4 // indirect
|
||||
github.com/mattn/go-isatty v0.0.19 // indirect
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.0.8 // indirect
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
|
||||
github.com/ugorji/go/codec v1.2.11 // indirect
|
||||
golang.org/x/arch v0.3.0 // indirect
|
||||
golang.org/x/crypto v0.9.0 // indirect
|
||||
golang.org/x/net v0.10.0 // indirect
|
||||
golang.org/x/sys v0.8.0 // indirect
|
||||
golang.org/x/text v0.9.0 // indirect
|
||||
gopkg.in/yaml.v3 v3 // indirect
|
||||
)
|
||||
@@ -1,33 +0,0 @@
|
||||
package logger
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/rs/zerolog"
|
||||
)
|
||||
|
||||
var log zerolog.Logger
|
||||
|
||||
func init() {
|
||||
log = zerolog.New(os.Stdout).With().Timestamp().Logger()
|
||||
}
|
||||
|
||||
func Info() *zerolog.Event {
|
||||
return log.Info()
|
||||
}
|
||||
|
||||
func Error() *zerolog.Event {
|
||||
return log.Error()
|
||||
}
|
||||
|
||||
func Debug() *zerolog.Event {
|
||||
return log.Debug()
|
||||
}
|
||||
|
||||
func Warn() *zerolog.Event {
|
||||
return log.Warn()
|
||||
}
|
||||
|
||||
func Fatal() *zerolog.Event {
|
||||
return log.Fatal()
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
package postgres
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"shared/logger"
|
||||
|
||||
"gorm.io/driver/postgres"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
Host string
|
||||
Port string
|
||||
User string
|
||||
Password string
|
||||
DBName string
|
||||
SSLMode string
|
||||
}
|
||||
|
||||
func NewPostgresDB(cfg Config) (*gorm.DB, error) {
|
||||
dsn := fmt.Sprintf("host=%s port=%s user=%s password=%s dbname=%s sslmode=%s",
|
||||
cfg.Host, cfg.Port, cfg.User, cfg.Password, cfg.DBName, cfg.SSLMode)
|
||||
|
||||
db, err := gorm.Open(postgres.Open(dsn), &gorm.Config{})
|
||||
if err != nil {
|
||||
logger.Error().Err(err).Msg("Failed to connect to PostgreSQL database")
|
||||
return nil, err
|
||||
}
|
||||
|
||||
logger.Info().Msg("Connected to PostgreSQL database successfully")
|
||||
return db, nil
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package common;
|
||||
|
||||
option go_package = "./common";
|
||||
|
||||
message Empty {
|
||||
}
|
||||
|
||||
message Status {
|
||||
bool success = 1;
|
||||
string message = 2;
|
||||
string code = 3;
|
||||
}
|
||||
|
||||
message Pagination {
|
||||
int32 page = 1;
|
||||
int32 page_size = 2;
|
||||
int32 total = 3;
|
||||
}
|
||||
|
||||
message IdRequest {
|
||||
string id = 1;
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
package redis
|
||||
|
||||
import (
|
||||
"context"
|
||||
"shared/logger"
|
||||
|
||||
"github.com/go-redis/redis/v8"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
Addr string
|
||||
Password string
|
||||
DB int
|
||||
}
|
||||
|
||||
func NewRedisClient(cfg Config) *redis.Client {
|
||||
client := redis.NewClient(&redis.Options{
|
||||
Addr: cfg.Addr,
|
||||
Password: cfg.Password,
|
||||
DB: cfg.DB,
|
||||
})
|
||||
|
||||
ctx := context.Background()
|
||||
_, err := client.Ping(ctx).Result()
|
||||
if err != nil {
|
||||
logger.Error().Err(err).Msg("Failed to connect to Redis")
|
||||
return nil
|
||||
}
|
||||
|
||||
logger.Info().Msg("Connected to Redis successfully")
|
||||
return client
|
||||
}
|
||||
@@ -1,682 +0,0 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.36.11
|
||||
// protoc v6.31.1
|
||||
// source: services/user-svc/user.proto
|
||||
|
||||
package user
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
unsafe "unsafe"
|
||||
)
|
||||
|
||||
const (
|
||||
// Verify that this generated code is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
type User struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
|
||||
Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
|
||||
Email string `protobuf:"bytes,3,opt,name=email,proto3" json:"email,omitempty"`
|
||||
Password string `protobuf:"bytes,4,opt,name=password,proto3" json:"password,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *User) Reset() {
|
||||
*x = User{}
|
||||
mi := &file_services_user_svc_user_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *User) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*User) ProtoMessage() {}
|
||||
|
||||
func (x *User) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_services_user_svc_user_proto_msgTypes[0]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use User.ProtoReflect.Descriptor instead.
|
||||
func (*User) Descriptor() ([]byte, []int) {
|
||||
return file_services_user_svc_user_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *User) GetId() string {
|
||||
if x != nil {
|
||||
return x.Id
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *User) GetName() string {
|
||||
if x != nil {
|
||||
return x.Name
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *User) GetEmail() string {
|
||||
if x != nil {
|
||||
return x.Email
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *User) GetPassword() string {
|
||||
if x != nil {
|
||||
return x.Password
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type CreateUserRequest struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
|
||||
Email string `protobuf:"bytes,2,opt,name=email,proto3" json:"email,omitempty"`
|
||||
Password string `protobuf:"bytes,3,opt,name=password,proto3" json:"password,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *CreateUserRequest) Reset() {
|
||||
*x = CreateUserRequest{}
|
||||
mi := &file_services_user_svc_user_proto_msgTypes[1]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *CreateUserRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*CreateUserRequest) ProtoMessage() {}
|
||||
|
||||
func (x *CreateUserRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_services_user_svc_user_proto_msgTypes[1]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use CreateUserRequest.ProtoReflect.Descriptor instead.
|
||||
func (*CreateUserRequest) Descriptor() ([]byte, []int) {
|
||||
return file_services_user_svc_user_proto_rawDescGZIP(), []int{1}
|
||||
}
|
||||
|
||||
func (x *CreateUserRequest) GetName() string {
|
||||
if x != nil {
|
||||
return x.Name
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *CreateUserRequest) GetEmail() string {
|
||||
if x != nil {
|
||||
return x.Email
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *CreateUserRequest) GetPassword() string {
|
||||
if x != nil {
|
||||
return x.Password
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type CreateUserResponse struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
User *User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *CreateUserResponse) Reset() {
|
||||
*x = CreateUserResponse{}
|
||||
mi := &file_services_user_svc_user_proto_msgTypes[2]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *CreateUserResponse) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*CreateUserResponse) ProtoMessage() {}
|
||||
|
||||
func (x *CreateUserResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_services_user_svc_user_proto_msgTypes[2]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use CreateUserResponse.ProtoReflect.Descriptor instead.
|
||||
func (*CreateUserResponse) Descriptor() ([]byte, []int) {
|
||||
return file_services_user_svc_user_proto_rawDescGZIP(), []int{2}
|
||||
}
|
||||
|
||||
func (x *CreateUserResponse) GetUser() *User {
|
||||
if x != nil {
|
||||
return x.User
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type GetUserRequest struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *GetUserRequest) Reset() {
|
||||
*x = GetUserRequest{}
|
||||
mi := &file_services_user_svc_user_proto_msgTypes[3]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *GetUserRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*GetUserRequest) ProtoMessage() {}
|
||||
|
||||
func (x *GetUserRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_services_user_svc_user_proto_msgTypes[3]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use GetUserRequest.ProtoReflect.Descriptor instead.
|
||||
func (*GetUserRequest) Descriptor() ([]byte, []int) {
|
||||
return file_services_user_svc_user_proto_rawDescGZIP(), []int{3}
|
||||
}
|
||||
|
||||
func (x *GetUserRequest) GetId() string {
|
||||
if x != nil {
|
||||
return x.Id
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type GetUserResponse struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
User *User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *GetUserResponse) Reset() {
|
||||
*x = GetUserResponse{}
|
||||
mi := &file_services_user_svc_user_proto_msgTypes[4]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *GetUserResponse) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*GetUserResponse) ProtoMessage() {}
|
||||
|
||||
func (x *GetUserResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_services_user_svc_user_proto_msgTypes[4]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use GetUserResponse.ProtoReflect.Descriptor instead.
|
||||
func (*GetUserResponse) Descriptor() ([]byte, []int) {
|
||||
return file_services_user_svc_user_proto_rawDescGZIP(), []int{4}
|
||||
}
|
||||
|
||||
func (x *GetUserResponse) GetUser() *User {
|
||||
if x != nil {
|
||||
return x.User
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type ListUsersRequest struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *ListUsersRequest) Reset() {
|
||||
*x = ListUsersRequest{}
|
||||
mi := &file_services_user_svc_user_proto_msgTypes[5]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *ListUsersRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*ListUsersRequest) ProtoMessage() {}
|
||||
|
||||
func (x *ListUsersRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_services_user_svc_user_proto_msgTypes[5]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use ListUsersRequest.ProtoReflect.Descriptor instead.
|
||||
func (*ListUsersRequest) Descriptor() ([]byte, []int) {
|
||||
return file_services_user_svc_user_proto_rawDescGZIP(), []int{5}
|
||||
}
|
||||
|
||||
type ListUsersResponse struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Users []*User `protobuf:"bytes,1,rep,name=users,proto3" json:"users,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *ListUsersResponse) Reset() {
|
||||
*x = ListUsersResponse{}
|
||||
mi := &file_services_user_svc_user_proto_msgTypes[6]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *ListUsersResponse) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*ListUsersResponse) ProtoMessage() {}
|
||||
|
||||
func (x *ListUsersResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_services_user_svc_user_proto_msgTypes[6]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use ListUsersResponse.ProtoReflect.Descriptor instead.
|
||||
func (*ListUsersResponse) Descriptor() ([]byte, []int) {
|
||||
return file_services_user_svc_user_proto_rawDescGZIP(), []int{6}
|
||||
}
|
||||
|
||||
func (x *ListUsersResponse) GetUsers() []*User {
|
||||
if x != nil {
|
||||
return x.Users
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type UpdateUserRequest struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
|
||||
Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
|
||||
Email string `protobuf:"bytes,3,opt,name=email,proto3" json:"email,omitempty"`
|
||||
Password string `protobuf:"bytes,4,opt,name=password,proto3" json:"password,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *UpdateUserRequest) Reset() {
|
||||
*x = UpdateUserRequest{}
|
||||
mi := &file_services_user_svc_user_proto_msgTypes[7]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *UpdateUserRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*UpdateUserRequest) ProtoMessage() {}
|
||||
|
||||
func (x *UpdateUserRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_services_user_svc_user_proto_msgTypes[7]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use UpdateUserRequest.ProtoReflect.Descriptor instead.
|
||||
func (*UpdateUserRequest) Descriptor() ([]byte, []int) {
|
||||
return file_services_user_svc_user_proto_rawDescGZIP(), []int{7}
|
||||
}
|
||||
|
||||
func (x *UpdateUserRequest) GetId() string {
|
||||
if x != nil {
|
||||
return x.Id
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *UpdateUserRequest) GetName() string {
|
||||
if x != nil {
|
||||
return x.Name
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *UpdateUserRequest) GetEmail() string {
|
||||
if x != nil {
|
||||
return x.Email
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *UpdateUserRequest) GetPassword() string {
|
||||
if x != nil {
|
||||
return x.Password
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type UpdateUserResponse struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
User *User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *UpdateUserResponse) Reset() {
|
||||
*x = UpdateUserResponse{}
|
||||
mi := &file_services_user_svc_user_proto_msgTypes[8]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *UpdateUserResponse) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*UpdateUserResponse) ProtoMessage() {}
|
||||
|
||||
func (x *UpdateUserResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_services_user_svc_user_proto_msgTypes[8]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use UpdateUserResponse.ProtoReflect.Descriptor instead.
|
||||
func (*UpdateUserResponse) Descriptor() ([]byte, []int) {
|
||||
return file_services_user_svc_user_proto_rawDescGZIP(), []int{8}
|
||||
}
|
||||
|
||||
func (x *UpdateUserResponse) GetUser() *User {
|
||||
if x != nil {
|
||||
return x.User
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type DeleteUserRequest struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *DeleteUserRequest) Reset() {
|
||||
*x = DeleteUserRequest{}
|
||||
mi := &file_services_user_svc_user_proto_msgTypes[9]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *DeleteUserRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*DeleteUserRequest) ProtoMessage() {}
|
||||
|
||||
func (x *DeleteUserRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_services_user_svc_user_proto_msgTypes[9]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use DeleteUserRequest.ProtoReflect.Descriptor instead.
|
||||
func (*DeleteUserRequest) Descriptor() ([]byte, []int) {
|
||||
return file_services_user_svc_user_proto_rawDescGZIP(), []int{9}
|
||||
}
|
||||
|
||||
func (x *DeleteUserRequest) GetId() string {
|
||||
if x != nil {
|
||||
return x.Id
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type DeleteUserResponse struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *DeleteUserResponse) Reset() {
|
||||
*x = DeleteUserResponse{}
|
||||
mi := &file_services_user_svc_user_proto_msgTypes[10]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *DeleteUserResponse) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*DeleteUserResponse) ProtoMessage() {}
|
||||
|
||||
func (x *DeleteUserResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_services_user_svc_user_proto_msgTypes[10]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use DeleteUserResponse.ProtoReflect.Descriptor instead.
|
||||
func (*DeleteUserResponse) Descriptor() ([]byte, []int) {
|
||||
return file_services_user_svc_user_proto_rawDescGZIP(), []int{10}
|
||||
}
|
||||
|
||||
func (x *DeleteUserResponse) GetSuccess() bool {
|
||||
if x != nil {
|
||||
return x.Success
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
var File_services_user_svc_user_proto protoreflect.FileDescriptor
|
||||
|
||||
const file_services_user_svc_user_proto_rawDesc = "" +
|
||||
"\n" +
|
||||
"\x1cservices/user-svc/user.proto\x12\x04user\"\\\n" +
|
||||
"\x04User\x12\x0e\n" +
|
||||
"\x02id\x18\x01 \x01(\tR\x02id\x12\x12\n" +
|
||||
"\x04name\x18\x02 \x01(\tR\x04name\x12\x14\n" +
|
||||
"\x05email\x18\x03 \x01(\tR\x05email\x12\x1a\n" +
|
||||
"\bpassword\x18\x04 \x01(\tR\bpassword\"Y\n" +
|
||||
"\x11CreateUserRequest\x12\x12\n" +
|
||||
"\x04name\x18\x01 \x01(\tR\x04name\x12\x14\n" +
|
||||
"\x05email\x18\x02 \x01(\tR\x05email\x12\x1a\n" +
|
||||
"\bpassword\x18\x03 \x01(\tR\bpassword\"4\n" +
|
||||
"\x12CreateUserResponse\x12\x1e\n" +
|
||||
"\x04user\x18\x01 \x01(\v2\n" +
|
||||
".user.UserR\x04user\" \n" +
|
||||
"\x0eGetUserRequest\x12\x0e\n" +
|
||||
"\x02id\x18\x01 \x01(\tR\x02id\"1\n" +
|
||||
"\x0fGetUserResponse\x12\x1e\n" +
|
||||
"\x04user\x18\x01 \x01(\v2\n" +
|
||||
".user.UserR\x04user\"\x12\n" +
|
||||
"\x10ListUsersRequest\"5\n" +
|
||||
"\x11ListUsersResponse\x12 \n" +
|
||||
"\x05users\x18\x01 \x03(\v2\n" +
|
||||
".user.UserR\x05users\"i\n" +
|
||||
"\x11UpdateUserRequest\x12\x0e\n" +
|
||||
"\x02id\x18\x01 \x01(\tR\x02id\x12\x12\n" +
|
||||
"\x04name\x18\x02 \x01(\tR\x04name\x12\x14\n" +
|
||||
"\x05email\x18\x03 \x01(\tR\x05email\x12\x1a\n" +
|
||||
"\bpassword\x18\x04 \x01(\tR\bpassword\"4\n" +
|
||||
"\x12UpdateUserResponse\x12\x1e\n" +
|
||||
"\x04user\x18\x01 \x01(\v2\n" +
|
||||
".user.UserR\x04user\"#\n" +
|
||||
"\x11DeleteUserRequest\x12\x0e\n" +
|
||||
"\x02id\x18\x01 \x01(\tR\x02id\".\n" +
|
||||
"\x12DeleteUserResponse\x12\x18\n" +
|
||||
"\asuccess\x18\x01 \x01(\bR\asuccess2\xc6\x02\n" +
|
||||
"\vUserService\x12?\n" +
|
||||
"\n" +
|
||||
"CreateUser\x12\x17.user.CreateUserRequest\x1a\x18.user.CreateUserResponse\x126\n" +
|
||||
"\aGetUser\x12\x14.user.GetUserRequest\x1a\x15.user.GetUserResponse\x12<\n" +
|
||||
"\tListUsers\x12\x16.user.ListUsersRequest\x1a\x17.user.ListUsersResponse\x12?\n" +
|
||||
"\n" +
|
||||
"UpdateUser\x12\x17.user.UpdateUserRequest\x1a\x18.user.UpdateUserResponse\x12?\n" +
|
||||
"\n" +
|
||||
"DeleteUser\x12\x17.user.DeleteUserRequest\x1a\x18.user.DeleteUserResponseB\bZ\x06./userb\x06proto3"
|
||||
|
||||
var (
|
||||
file_services_user_svc_user_proto_rawDescOnce sync.Once
|
||||
file_services_user_svc_user_proto_rawDescData []byte
|
||||
)
|
||||
|
||||
func file_services_user_svc_user_proto_rawDescGZIP() []byte {
|
||||
file_services_user_svc_user_proto_rawDescOnce.Do(func() {
|
||||
file_services_user_svc_user_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_services_user_svc_user_proto_rawDesc), len(file_services_user_svc_user_proto_rawDesc)))
|
||||
})
|
||||
return file_services_user_svc_user_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_services_user_svc_user_proto_msgTypes = make([]protoimpl.MessageInfo, 11)
|
||||
var file_services_user_svc_user_proto_goTypes = []any{
|
||||
(*User)(nil), // 0: user.User
|
||||
(*CreateUserRequest)(nil), // 1: user.CreateUserRequest
|
||||
(*CreateUserResponse)(nil), // 2: user.CreateUserResponse
|
||||
(*GetUserRequest)(nil), // 3: user.GetUserRequest
|
||||
(*GetUserResponse)(nil), // 4: user.GetUserResponse
|
||||
(*ListUsersRequest)(nil), // 5: user.ListUsersRequest
|
||||
(*ListUsersResponse)(nil), // 6: user.ListUsersResponse
|
||||
(*UpdateUserRequest)(nil), // 7: user.UpdateUserRequest
|
||||
(*UpdateUserResponse)(nil), // 8: user.UpdateUserResponse
|
||||
(*DeleteUserRequest)(nil), // 9: user.DeleteUserRequest
|
||||
(*DeleteUserResponse)(nil), // 10: user.DeleteUserResponse
|
||||
}
|
||||
var file_services_user_svc_user_proto_depIdxs = []int32{
|
||||
0, // 0: user.CreateUserResponse.user:type_name -> user.User
|
||||
0, // 1: user.GetUserResponse.user:type_name -> user.User
|
||||
0, // 2: user.ListUsersResponse.users:type_name -> user.User
|
||||
0, // 3: user.UpdateUserResponse.user:type_name -> user.User
|
||||
1, // 4: user.UserService.CreateUser:input_type -> user.CreateUserRequest
|
||||
3, // 5: user.UserService.GetUser:input_type -> user.GetUserRequest
|
||||
5, // 6: user.UserService.ListUsers:input_type -> user.ListUsersRequest
|
||||
7, // 7: user.UserService.UpdateUser:input_type -> user.UpdateUserRequest
|
||||
9, // 8: user.UserService.DeleteUser:input_type -> user.DeleteUserRequest
|
||||
2, // 9: user.UserService.CreateUser:output_type -> user.CreateUserResponse
|
||||
4, // 10: user.UserService.GetUser:output_type -> user.GetUserResponse
|
||||
6, // 11: user.UserService.ListUsers:output_type -> user.ListUsersResponse
|
||||
8, // 12: user.UserService.UpdateUser:output_type -> user.UpdateUserResponse
|
||||
10, // 13: user.UserService.DeleteUser:output_type -> user.DeleteUserResponse
|
||||
9, // [9:14] is the sub-list for method output_type
|
||||
4, // [4:9] is the sub-list for method input_type
|
||||
4, // [4:4] is the sub-list for extension type_name
|
||||
4, // [4:4] is the sub-list for extension extendee
|
||||
0, // [0:4] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_services_user_svc_user_proto_init() }
|
||||
func file_services_user_svc_user_proto_init() {
|
||||
if File_services_user_svc_user_proto != nil {
|
||||
return
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: unsafe.Slice(unsafe.StringData(file_services_user_svc_user_proto_rawDesc), len(file_services_user_svc_user_proto_rawDesc)),
|
||||
NumEnums: 0,
|
||||
NumMessages: 11,
|
||||
NumExtensions: 0,
|
||||
NumServices: 1,
|
||||
},
|
||||
GoTypes: file_services_user_svc_user_proto_goTypes,
|
||||
DependencyIndexes: file_services_user_svc_user_proto_depIdxs,
|
||||
MessageInfos: file_services_user_svc_user_proto_msgTypes,
|
||||
}.Build()
|
||||
File_services_user_svc_user_proto = out.File
|
||||
file_services_user_svc_user_proto_goTypes = nil
|
||||
file_services_user_svc_user_proto_depIdxs = nil
|
||||
}
|
||||
@@ -1,273 +0,0 @@
|
||||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-grpc v1.6.1
|
||||
// - protoc v6.31.1
|
||||
// source: services/user-svc/user.proto
|
||||
|
||||
package user
|
||||
|
||||
import (
|
||||
context "context"
|
||||
grpc "google.golang.org/grpc"
|
||||
codes "google.golang.org/grpc/codes"
|
||||
status "google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the grpc package it is being compiled against.
|
||||
// Requires gRPC-Go v1.64.0 or later.
|
||||
const _ = grpc.SupportPackageIsVersion9
|
||||
|
||||
const (
|
||||
UserService_CreateUser_FullMethodName = "/user.UserService/CreateUser"
|
||||
UserService_GetUser_FullMethodName = "/user.UserService/GetUser"
|
||||
UserService_ListUsers_FullMethodName = "/user.UserService/ListUsers"
|
||||
UserService_UpdateUser_FullMethodName = "/user.UserService/UpdateUser"
|
||||
UserService_DeleteUser_FullMethodName = "/user.UserService/DeleteUser"
|
||||
)
|
||||
|
||||
// UserServiceClient is the client API for UserService service.
|
||||
//
|
||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
||||
type UserServiceClient interface {
|
||||
CreateUser(ctx context.Context, in *CreateUserRequest, opts ...grpc.CallOption) (*CreateUserResponse, error)
|
||||
GetUser(ctx context.Context, in *GetUserRequest, opts ...grpc.CallOption) (*GetUserResponse, error)
|
||||
ListUsers(ctx context.Context, in *ListUsersRequest, opts ...grpc.CallOption) (*ListUsersResponse, error)
|
||||
UpdateUser(ctx context.Context, in *UpdateUserRequest, opts ...grpc.CallOption) (*UpdateUserResponse, error)
|
||||
DeleteUser(ctx context.Context, in *DeleteUserRequest, opts ...grpc.CallOption) (*DeleteUserResponse, error)
|
||||
}
|
||||
|
||||
type userServiceClient struct {
|
||||
cc grpc.ClientConnInterface
|
||||
}
|
||||
|
||||
func NewUserServiceClient(cc grpc.ClientConnInterface) UserServiceClient {
|
||||
return &userServiceClient{cc}
|
||||
}
|
||||
|
||||
func (c *userServiceClient) CreateUser(ctx context.Context, in *CreateUserRequest, opts ...grpc.CallOption) (*CreateUserResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(CreateUserResponse)
|
||||
err := c.cc.Invoke(ctx, UserService_CreateUser_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *userServiceClient) GetUser(ctx context.Context, in *GetUserRequest, opts ...grpc.CallOption) (*GetUserResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(GetUserResponse)
|
||||
err := c.cc.Invoke(ctx, UserService_GetUser_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *userServiceClient) ListUsers(ctx context.Context, in *ListUsersRequest, opts ...grpc.CallOption) (*ListUsersResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(ListUsersResponse)
|
||||
err := c.cc.Invoke(ctx, UserService_ListUsers_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *userServiceClient) UpdateUser(ctx context.Context, in *UpdateUserRequest, opts ...grpc.CallOption) (*UpdateUserResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(UpdateUserResponse)
|
||||
err := c.cc.Invoke(ctx, UserService_UpdateUser_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *userServiceClient) DeleteUser(ctx context.Context, in *DeleteUserRequest, opts ...grpc.CallOption) (*DeleteUserResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(DeleteUserResponse)
|
||||
err := c.cc.Invoke(ctx, UserService_DeleteUser_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// UserServiceServer is the server API for UserService service.
|
||||
// All implementations must embed UnimplementedUserServiceServer
|
||||
// for forward compatibility.
|
||||
type UserServiceServer interface {
|
||||
CreateUser(context.Context, *CreateUserRequest) (*CreateUserResponse, error)
|
||||
GetUser(context.Context, *GetUserRequest) (*GetUserResponse, error)
|
||||
ListUsers(context.Context, *ListUsersRequest) (*ListUsersResponse, error)
|
||||
UpdateUser(context.Context, *UpdateUserRequest) (*UpdateUserResponse, error)
|
||||
DeleteUser(context.Context, *DeleteUserRequest) (*DeleteUserResponse, error)
|
||||
mustEmbedUnimplementedUserServiceServer()
|
||||
}
|
||||
|
||||
// UnimplementedUserServiceServer must be embedded to have
|
||||
// forward compatible implementations.
|
||||
//
|
||||
// NOTE: this should be embedded by value instead of pointer to avoid a nil
|
||||
// pointer dereference when methods are called.
|
||||
type UnimplementedUserServiceServer struct{}
|
||||
|
||||
func (UnimplementedUserServiceServer) CreateUser(context.Context, *CreateUserRequest) (*CreateUserResponse, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method CreateUser not implemented")
|
||||
}
|
||||
func (UnimplementedUserServiceServer) GetUser(context.Context, *GetUserRequest) (*GetUserResponse, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method GetUser not implemented")
|
||||
}
|
||||
func (UnimplementedUserServiceServer) ListUsers(context.Context, *ListUsersRequest) (*ListUsersResponse, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method ListUsers not implemented")
|
||||
}
|
||||
func (UnimplementedUserServiceServer) UpdateUser(context.Context, *UpdateUserRequest) (*UpdateUserResponse, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method UpdateUser not implemented")
|
||||
}
|
||||
func (UnimplementedUserServiceServer) DeleteUser(context.Context, *DeleteUserRequest) (*DeleteUserResponse, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method DeleteUser not implemented")
|
||||
}
|
||||
func (UnimplementedUserServiceServer) mustEmbedUnimplementedUserServiceServer() {}
|
||||
func (UnimplementedUserServiceServer) testEmbeddedByValue() {}
|
||||
|
||||
// UnsafeUserServiceServer may be embedded to opt out of forward compatibility for this service.
|
||||
// Use of this interface is not recommended, as added methods to UserServiceServer will
|
||||
// result in compilation errors.
|
||||
type UnsafeUserServiceServer interface {
|
||||
mustEmbedUnimplementedUserServiceServer()
|
||||
}
|
||||
|
||||
func RegisterUserServiceServer(s grpc.ServiceRegistrar, srv UserServiceServer) {
|
||||
// If the following call panics, it indicates UnimplementedUserServiceServer was
|
||||
// embedded by pointer and is nil. This will cause panics if an
|
||||
// unimplemented method is ever invoked, so we test this at initialization
|
||||
// time to prevent it from happening at runtime later due to I/O.
|
||||
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
|
||||
t.testEmbeddedByValue()
|
||||
}
|
||||
s.RegisterService(&UserService_ServiceDesc, srv)
|
||||
}
|
||||
|
||||
func _UserService_CreateUser_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(CreateUserRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(UserServiceServer).CreateUser(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: UserService_CreateUser_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(UserServiceServer).CreateUser(ctx, req.(*CreateUserRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _UserService_GetUser_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(GetUserRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(UserServiceServer).GetUser(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: UserService_GetUser_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(UserServiceServer).GetUser(ctx, req.(*GetUserRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _UserService_ListUsers_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(ListUsersRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(UserServiceServer).ListUsers(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: UserService_ListUsers_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(UserServiceServer).ListUsers(ctx, req.(*ListUsersRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _UserService_UpdateUser_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(UpdateUserRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(UserServiceServer).UpdateUser(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: UserService_UpdateUser_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(UserServiceServer).UpdateUser(ctx, req.(*UpdateUserRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _UserService_DeleteUser_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(DeleteUserRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(UserServiceServer).DeleteUser(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: UserService_DeleteUser_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(UserServiceServer).DeleteUser(ctx, req.(*DeleteUserRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
// UserService_ServiceDesc is the grpc.ServiceDesc for UserService service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
var UserService_ServiceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "user.UserService",
|
||||
HandlerType: (*UserServiceServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "CreateUser",
|
||||
Handler: _UserService_CreateUser_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "GetUser",
|
||||
Handler: _UserService_GetUser_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "ListUsers",
|
||||
Handler: _UserService_ListUsers_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "UpdateUser",
|
||||
Handler: _UserService_UpdateUser_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "DeleteUser",
|
||||
Handler: _UserService_DeleteUser_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "services/user-svc/user.proto",
|
||||
}
|
||||
Reference in New Issue
Block a user