Compare commits

...

52 Commits

Author SHA1 Message Date
tx7do
2d04529a89 feat: refactor go.mod. 2024-11-14 16:53:47 +08:00
tx7do
16cccfe6ab feat: refactor go.mod. 2024-11-14 16:49:40 +08:00
tx7do
9e9d634935 feat: refactor go.mod. 2024-11-14 16:07:28 +08:00
tx7do
f65e647380 feat: refactor go.mod. 2024-11-14 16:03:35 +08:00
tx7do
be232fe811 feat: refactor go.mod. 2024-11-14 15:51:47 +08:00
tx7do
52fc752502 feat: refactor go.mod. 2024-11-14 15:48:38 +08:00
tx7do
120029bb01 feat: refactor go.mod. 2024-11-14 15:47:21 +08:00
tx7do
f3d17b9d34 feat: refactor go.mod. 2024-11-14 15:25:58 +08:00
tx7do
62ee65a36b feat: refactor go.mod. 2024-11-14 15:00:57 +08:00
tx7do
a28f55cb99 feat: refactor go.mod. 2024-11-14 14:56:51 +08:00
tx7do
9a4861eff2 feat: refactor go.mod. 2024-11-14 14:11:32 +08:00
tx7do
dd2b0f5156 feat: refactor go.mod. 2024-11-14 13:40:48 +08:00
tx7do
c506430ed7 feat: refactor go.mod. 2024-11-14 13:29:20 +08:00
tx7do
719fa01c8d feat: refactor go.mod. 2024-11-14 13:04:30 +08:00
tx7do
3ef28da068 feat: refactor go.mod. 2024-11-14 11:45:17 +08:00
tx7do
0e4d1aa6cb feat: add database. 2024-11-14 11:35:26 +08:00
tx7do
bef6bbc269 feat: refactor go.mod. 2024-11-14 10:32:27 +08:00
tx7do
8b79665a27 feat: refactor go.mod. 2024-11-14 09:08:30 +08:00
tx7do
da4a21ce62 feat: refactor go.mod. 2024-11-14 09:03:48 +08:00
tx7do
883b23dbbb feat: refactor go.mod. 2024-11-14 08:41:54 +08:00
tx7do
40ec693f17 feat: rpc. 2024-11-13 23:48:48 +08:00
tx7do
968f1b72b0 feat: upgrade go.mod. 2024-11-13 13:41:34 +08:00
tx7do
43da1db483 feat: upgrade go.mod. 2024-11-13 13:00:36 +08:00
tx7do
16f4462220 feat: upgrade go.mod. 2024-11-13 12:40:59 +08:00
tx7do
9e051505a1 feat: support tls config. 2024-11-13 11:27:13 +08:00
tx7do
e755b6cfc8 feat: upgrade go.mod. 2024-10-16 21:04:04 +08:00
tx7do
91b483ac9a feat: conf. 2024-06-08 14:21:00 +08:00
tx7do
01424e4387 feat: refactor. 2024-06-08 14:09:29 +08:00
tx7do
5e85934e35 feat: refactor. 2024-05-14 16:37:22 +08:00
tx7do
edbcad5973 feat: refactor. 2024-05-14 16:25:53 +08:00
tx7do
6711cb7613 feat: refactor. 2024-05-14 16:25:37 +08:00
tx7do
d7b7e9e8fd feat: refactor. 2024-05-06 13:15:31 +08:00
tx7do
ad13aafe69 feat: refactor. 2024-05-06 13:04:22 +08:00
tx7do
f1fa4176af feat: refactor. 2024-05-06 12:55:44 +08:00
tx7do
8044bb92b3 feat: refactor. 2024-05-06 12:51:50 +08:00
tx7do
3eb9f014bc feat: refactor. 2024-05-06 12:32:26 +08:00
tx7do
7eb628e676 feat: refactor. 2024-05-06 12:27:45 +08:00
tx7do
7b10a94188 feat: refactor. 2024-05-06 12:09:37 +08:00
tx7do
cf902efeca feat: refactor. 2024-05-06 12:05:57 +08:00
tx7do
e043284a58 feat: refactor. 2024-05-06 10:57:42 +08:00
tx7do
f4658eb5d9 feat: refactor. 2024-05-06 10:38:46 +08:00
tx7do
72daf43151 feat: refactor. 2024-05-06 10:26:59 +08:00
tx7do
7ce746e181 feat: refactor. 2024-05-06 10:07:22 +08:00
tx7do
9df72bbad8 feat: refactor. 2024-05-06 09:52:29 +08:00
tx7do
7471dbf968 feat: refactor. 2024-05-06 08:34:16 +08:00
tx7do
601a7e5545 feat: refactor. 2024-05-06 08:23:05 +08:00
tx7do
8e16b4309c feat: refactor. 2024-05-06 08:02:26 +08:00
tx7do
cfb5aefaf9 feat: edit. 2024-05-06 06:21:05 +08:00
tx7do
22382d11e0 feat: edit. 2024-04-18 13:47:24 +08:00
tx7do
f428916cd1 feat: edit. 2023-11-18 13:30:18 +08:00
tx7do
3fc082fef5 feat: edit. 2023-11-17 22:48:39 +08:00
tx7do
094a996690 feat: upgrade go-redis version. 2023-11-13 19:52:57 +08:00
141 changed files with 15022 additions and 4406 deletions

26
.gitignore vendored
View File

@@ -1,6 +1,4 @@
# If you prefer the allow list template instead of the deny list, see community template:
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
#
# Reference https://github.com/github/gitignore/blob/master/Go.gitignore
# Binaries for programs and plugins
*.exe
*.exe~
@@ -15,7 +13,23 @@
*.out
# Dependency directories (remove the comment below to include it)
# vendor/
vendor/
# Go workspace file
go.work
# Compiled Object files, Static and Dynamic libs (Shared Objects)
*.o
*.a
# OS General
Thumbs.db
.DS_Store
# project
*.cert
*.key
*.log
bin/
# Develop tools
.vscode/
.idea/
*.swp

View File

@@ -13,6 +13,7 @@ SRCS_MK := $(foreach dir, app, $(wildcard $(dir)/*/*/Makefile))
# generate protobuf api go code
api:
cd api && \
buf generate
# show help

View File

@@ -6,7 +6,7 @@ managed:
optimize_for: SPEED
go_package_prefix:
default: github.com/tx7do/kratos-bootstrap/gen/api/go
default: github.com/tx7do/kratos-bootstrap/api/gen/go
except:
- 'buf.build/googleapis/googleapis'
- 'buf.build/envoyproxy/protoc-gen-validate'
@@ -18,5 +18,5 @@ plugins:
# generate go struct code
#- plugin: buf.build/protocolbuffers/go
- name: go
out: gen/api/go
out: gen/go
opt: paths=source_relative

View File

@@ -1,28 +1,2 @@
# Generated by buf. DO NOT EDIT.
version: v1
deps:
- remote: buf.build
owner: envoyproxy
repository: protoc-gen-validate
commit: eac44469a7af47e7839a7f1f3d7ac004
digest: shake256:0feabcde01b6b11e3c75a5e3f807968d5995626546f39c37e5d4205892b3a59cced0ed83b35a2eb9e6dddd3309660ad46b737c9dcd224b425de0a6654ce04417
- remote: buf.build
owner: gnostic
repository: gnostic
commit: 087bc8072ce44e339f213209e4d57bf0
digest: shake256:4689c26f0460fea84c4c277c1b9c7e7d657388c5b4116d1065f907a92100ffbea87de05bbd138a0166411361e1f6ce063b4c0c6002358d39710f3c4a8de788d5
- remote: buf.build
owner: gogo
repository: protobuf
commit: 5461a3dfa9d941da82028ab185dc2a0e
digest: shake256:37c7c75224982038cb1abf45b481ef06716c1f806ffaa162018d0df092bd11a2a9b62c2d0dc0a2ae43beff86b6014fc0eb8c594ffd84d52ade4b08fca901eadc
- remote: buf.build
owner: googleapis
repository: googleapis
commit: 28151c0d0a1641bf938a7672c500e01d
digest: shake256:49215edf8ef57f7863004539deff8834cfb2195113f0b890dd1f67815d9353e28e668019165b9d872395871eeafcbab3ccfdb2b5f11734d3cca95be9e8d139de
- remote: buf.build
owner: kratos
repository: apis
commit: c2de25f14fa445a79a054214f31d17a8
digest: shake256:91c024935d46f7966667c29e4fc933435959f93c3f0e675e1227c99db09905d44f8ec275b770da7659df5a6b18f4710da157b6d8ad760a4a95f60365b231e637

View File

@@ -1,4 +1,4 @@
version: v1
directories:
- api
- protos

View File

@@ -1,26 +0,0 @@
syntax = "proto3";
package conf;
option go_package = "github.com/tx7do/kratos-bootstrap/gen/api/go/conf/v1;conf";
import "google/protobuf/duration.proto";
import "conf/v1/kratos_conf_middleware.proto";
// 客户端
message Client {
// REST
message REST {
google.protobuf.Duration timeout = 1; // 超时时间
Middleware middleware = 2;
}
// gPRC
message GRPC {
google.protobuf.Duration timeout = 1; // 超时时间
Middleware middleware = 2;
}
REST rest = 1; // REST服务
GRPC grpc = 2; // gRPC服务
}

View File

@@ -1,53 +0,0 @@
syntax = "proto3";
package conf;
option go_package = "github.com/tx7do/kratos-bootstrap/gen/api/go/conf/v1;conf";
import "google/protobuf/duration.proto";
// 配置服务
message RemoteConfig {
message Nacos {
string address = 1; // 服务端地址
uint64 port = 2; // 服务端端口
string key = 3; //
}
message Etcd {
repeated string endpoints = 1;
google.protobuf.Duration timeout = 2;
string key = 3; //
}
message Consul {
string scheme = 1; // 网络样式
string address = 2; // 服务端地址
string key = 3; //
}
message Apollo {
string endpoint = 1;
string app_id = 2;
string cluster = 3;
string namespace = 4;
string secret = 5;
}
message Kubernetes {
string namespace = 1;
}
message Polaris {
}
string type = 1;
Etcd etcd = 2;
Consul consul = 3;
Nacos nacos = 4;
Apollo apollo = 6;
Kubernetes kubernetes = 7;
Polaris polaris = 8;
}

View File

@@ -1,76 +0,0 @@
syntax = "proto3";
package conf;
option go_package = "github.com/tx7do/kratos-bootstrap/gen/api/go/conf/v1;conf";
import "google/protobuf/duration.proto";
// 数据
message Data {
// 数据库
message Database {
string driver = 1; // 驱动名mysql、postgresql、mongodb、sqlite……
string source = 2; // 数据源DSN字符串
bool migrate = 3; // 数据迁移开关
bool debug = 4; // 调试开关
int32 max_idle_connections = 5; // 连接池最大空闲连接数
int32 max_open_connections = 6; // 连接池最大打开连接数
google.protobuf.Duration connection_max_lifetime = 7; // 连接可重用的最大时间长度
}
// redis
message Redis {
string network = 1; // 网络
string addr = 2; // 服务端地址
string password = 3; // 密码
int32 db = 4; // 数据库索引
google.protobuf.Duration dial_timeout = 5; // 连接超时时间
google.protobuf.Duration read_timeout = 6; // 读取超时时间
google.protobuf.Duration write_timeout = 7; // 写入超时时间
}
// MongoDB
message MongoDB {
string address = 1;
}
// ClickHouse
message ClickHouse {
string address = 1;
}
// InfluxDB
message InfluxDB {
string address = 1;
string token = 2;
string orgnization = 3;
string bucket = 4;
}
// Kafka
message Kafka {
repeated string addrs = 1; // 对端网络地址
string codec = 2; // 编解码器
}
message Doris {
string address = 1;
}
message ElasticSearch {
string address = 1;
}
Database database = 1; // 数据库DSN
Redis redis = 10; // Redis
MongoDB mongodb = 11; // MongoDB数据库
ElasticSearch elastic_search = 12; // ElasticSearch数据库
ClickHouse clickhouse = 20; // ClickHouse数据库
InfluxDB influxdb = 21; // InfluxDB数据库
Doris doris = 22; // Doris数据库
Kafka kafka = 30; // Kafka服务
}

View File

@@ -1,20 +0,0 @@
syntax = "proto3";
package conf;
option go_package = "github.com/tx7do/kratos-bootstrap/gen/api/go/conf/v1;conf";
message OSS {
// MinIO
message MinIO {
string endpoint = 1; // 对端端口
string access_key = 2; // 访问密钥
string secret_key = 3; // 密钥
string token = 4; // 令牌
bool use_ssl = 5; // 使用SSL
string upload_host = 6; // 上传链接的主机名
string download_host = 7; // 下载链接的主机名
}
MinIO minio = 1;
}

View File

@@ -183,8 +183,8 @@ var file_conf_v1_kratos_conf_bootstrap_proto_rawDesc = []byte{
0x61, 0x74, 0x6f, 0x73, 0x43, 0x6f, 0x6e, 0x66, 0x42, 0x6f, 0x6f, 0x74, 0x73, 0x74, 0x72, 0x61,
0x70, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x34, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62,
0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x74, 0x78, 0x37, 0x64, 0x6f, 0x2f, 0x6b, 0x72, 0x61, 0x74, 0x6f,
0x73, 0x2d, 0x62, 0x6f, 0x6f, 0x74, 0x73, 0x74, 0x72, 0x61, 0x70, 0x2f, 0x67, 0x65, 0x6e, 0x2f,
0x61, 0x70, 0x69, 0x2f, 0x67, 0x6f, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x2f, 0x76, 0x31, 0xa2, 0x02,
0x73, 0x2d, 0x62, 0x6f, 0x6f, 0x74, 0x73, 0x74, 0x72, 0x61, 0x70, 0x2f, 0x61, 0x70, 0x69, 0x2f,
0x67, 0x65, 0x6e, 0x2f, 0x67, 0x6f, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x2f, 0x76, 0x31, 0xa2, 0x02,
0x03, 0x43, 0x58, 0x58, 0xaa, 0x02, 0x04, 0x43, 0x6f, 0x6e, 0x66, 0xca, 0x02, 0x04, 0x43, 0x6f,
0x6e, 0x66, 0xe2, 0x02, 0x10, 0x43, 0x6f, 0x6e, 0x66, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74,
0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x04, 0x43, 0x6f, 0x6e, 0x66, 0x62, 0x06, 0x70, 0x72,

View File

@@ -27,8 +27,8 @@ type Client struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Rest *Client_REST `protobuf:"bytes,1,opt,name=rest,proto3" json:"rest,omitempty"` // REST服务
Grpc *Client_GRPC `protobuf:"bytes,2,opt,name=grpc,proto3" json:"grpc,omitempty"` // gRPC服务
Rest *Client_REST `protobuf:"bytes,1,opt,name=rest,proto3,oneof" json:"rest,omitempty"` // REST服务
Grpc *Client_GRPC `protobuf:"bytes,2,opt,name=grpc,proto3,oneof" json:"grpc,omitempty"` // gRPC服务
}
func (x *Client) Reset() {
@@ -83,8 +83,9 @@ type Client_REST struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Timeout *durationpb.Duration `protobuf:"bytes,1,opt,name=timeout,proto3" json:"timeout,omitempty"` // 超时时间
Middleware *Middleware `protobuf:"bytes,2,opt,name=middleware,proto3" json:"middleware,omitempty"`
Timeout *durationpb.Duration `protobuf:"bytes,1,opt,name=timeout,proto3" json:"timeout,omitempty"` // 超时时间
Middleware *Middleware `protobuf:"bytes,2,opt,name=middleware,proto3" json:"middleware,omitempty"` // 中间件
Tls *TLS `protobuf:"bytes,3,opt,name=tls,proto3" json:"tls,omitempty"` // TLS配置
}
func (x *Client_REST) Reset() {
@@ -133,14 +134,22 @@ func (x *Client_REST) GetMiddleware() *Middleware {
return nil
}
func (x *Client_REST) GetTls() *TLS {
if x != nil {
return x.Tls
}
return nil
}
// gPRC
type Client_GRPC struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Timeout *durationpb.Duration `protobuf:"bytes,1,opt,name=timeout,proto3" json:"timeout,omitempty"` // 超时时间
Middleware *Middleware `protobuf:"bytes,2,opt,name=middleware,proto3" json:"middleware,omitempty"`
Timeout *durationpb.Duration `protobuf:"bytes,1,opt,name=timeout,proto3" json:"timeout,omitempty"` // 超时时间
Middleware *Middleware `protobuf:"bytes,2,opt,name=middleware,proto3" json:"middleware,omitempty"` // 中间件
Tls *TLS `protobuf:"bytes,3,opt,name=tls,proto3" json:"tls,omitempty"` // TLS配置
}
func (x *Client_GRPC) Reset() {
@@ -189,6 +198,13 @@ func (x *Client_GRPC) GetMiddleware() *Middleware {
return nil
}
func (x *Client_GRPC) GetTls() *TLS {
if x != nil {
return x.Tls
}
return nil
}
var File_conf_v1_kratos_conf_client_proto protoreflect.FileDescriptor
var file_conf_v1_kratos_conf_client_proto_rawDesc = []byte{
@@ -198,36 +214,43 @@ var file_conf_v1_kratos_conf_client_proto_rawDesc = []byte{
0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x64, 0x75, 0x72, 0x61, 0x74, 0x69,
0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x24, 0x63, 0x6f, 0x6e, 0x66, 0x2f, 0x76,
0x31, 0x2f, 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x5f, 0x6d, 0x69,
0x64, 0x64, 0x6c, 0x65, 0x77, 0x61, 0x72, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xb4,
0x02, 0x0a, 0x06, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x12, 0x25, 0x0a, 0x04, 0x72, 0x65, 0x73,
0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x2e, 0x43,
0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x52, 0x45, 0x53, 0x54, 0x52, 0x04, 0x72, 0x65, 0x73, 0x74,
0x12, 0x25, 0x0a, 0x04, 0x67, 0x72, 0x70, 0x63, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11,
0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x2e, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x47, 0x52, 0x50,
0x43, 0x52, 0x04, 0x67, 0x72, 0x70, 0x63, 0x1a, 0x6d, 0x0a, 0x04, 0x52, 0x45, 0x53, 0x54, 0x12,
0x33, 0x0a, 0x07, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b,
0x32, 0x19, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62,
0x75, 0x66, 0x2e, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x07, 0x74, 0x69, 0x6d,
0x65, 0x6f, 0x75, 0x74, 0x12, 0x30, 0x0a, 0x0a, 0x6d, 0x69, 0x64, 0x64, 0x6c, 0x65, 0x77, 0x61,
0x72, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x2e,
0x4d, 0x69, 0x64, 0x64, 0x6c, 0x65, 0x77, 0x61, 0x72, 0x65, 0x52, 0x0a, 0x6d, 0x69, 0x64, 0x64,
0x6c, 0x65, 0x77, 0x61, 0x72, 0x65, 0x1a, 0x6d, 0x0a, 0x04, 0x47, 0x52, 0x50, 0x43, 0x12, 0x33,
0x0a, 0x07, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32,
0x19, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75,
0x66, 0x2e, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x07, 0x74, 0x69, 0x6d, 0x65,
0x6f, 0x75, 0x74, 0x12, 0x30, 0x0a, 0x0a, 0x6d, 0x69, 0x64, 0x64, 0x6c, 0x65, 0x77, 0x61, 0x72,
0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x2e, 0x4d,
0x69, 0x64, 0x64, 0x6c, 0x65, 0x77, 0x61, 0x72, 0x65, 0x52, 0x0a, 0x6d, 0x69, 0x64, 0x64, 0x6c,
0x65, 0x77, 0x61, 0x72, 0x65, 0x42, 0x87, 0x01, 0x0a, 0x08, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f,
0x6e, 0x66, 0x42, 0x15, 0x4b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x43, 0x6f, 0x6e, 0x66, 0x43, 0x6c,
0x69, 0x65, 0x6e, 0x74, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x34, 0x67, 0x69, 0x74,
0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x74, 0x78, 0x37, 0x64, 0x6f, 0x2f, 0x6b, 0x72,
0x61, 0x74, 0x6f, 0x73, 0x2d, 0x62, 0x6f, 0x6f, 0x74, 0x73, 0x74, 0x72, 0x61, 0x70, 0x2f, 0x67,
0x65, 0x6e, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x67, 0x6f, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x2f, 0x76,
0x31, 0xa2, 0x02, 0x03, 0x43, 0x58, 0x58, 0xaa, 0x02, 0x04, 0x43, 0x6f, 0x6e, 0x66, 0xca, 0x02,
0x04, 0x43, 0x6f, 0x6e, 0x66, 0xe2, 0x02, 0x10, 0x43, 0x6f, 0x6e, 0x66, 0x5c, 0x47, 0x50, 0x42,
0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x04, 0x43, 0x6f, 0x6e, 0x66, 0x62,
0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x64, 0x64, 0x6c, 0x65, 0x77, 0x61, 0x72, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1d,
0x63, 0x6f, 0x6e, 0x66, 0x2f, 0x76, 0x31, 0x2f, 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x5f, 0x63,
0x6f, 0x6e, 0x66, 0x5f, 0x74, 0x6c, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x8c, 0x03,
0x0a, 0x06, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x12, 0x2a, 0x0a, 0x04, 0x72, 0x65, 0x73, 0x74,
0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x2e, 0x43, 0x6c,
0x69, 0x65, 0x6e, 0x74, 0x2e, 0x52, 0x45, 0x53, 0x54, 0x48, 0x00, 0x52, 0x04, 0x72, 0x65, 0x73,
0x74, 0x88, 0x01, 0x01, 0x12, 0x2a, 0x0a, 0x04, 0x67, 0x72, 0x70, 0x63, 0x18, 0x02, 0x20, 0x01,
0x28, 0x0b, 0x32, 0x11, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x2e, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74,
0x2e, 0x47, 0x52, 0x50, 0x43, 0x48, 0x01, 0x52, 0x04, 0x67, 0x72, 0x70, 0x63, 0x88, 0x01, 0x01,
0x1a, 0x8a, 0x01, 0x0a, 0x04, 0x52, 0x45, 0x53, 0x54, 0x12, 0x33, 0x0a, 0x07, 0x74, 0x69, 0x6d,
0x65, 0x6f, 0x75, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x67, 0x6f, 0x6f,
0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, 0x75, 0x72,
0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x07, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x12, 0x30,
0x0a, 0x0a, 0x6d, 0x69, 0x64, 0x64, 0x6c, 0x65, 0x77, 0x61, 0x72, 0x65, 0x18, 0x02, 0x20, 0x01,
0x28, 0x0b, 0x32, 0x10, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x2e, 0x4d, 0x69, 0x64, 0x64, 0x6c, 0x65,
0x77, 0x61, 0x72, 0x65, 0x52, 0x0a, 0x6d, 0x69, 0x64, 0x64, 0x6c, 0x65, 0x77, 0x61, 0x72, 0x65,
0x12, 0x1b, 0x0a, 0x03, 0x74, 0x6c, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x09, 0x2e,
0x63, 0x6f, 0x6e, 0x66, 0x2e, 0x54, 0x4c, 0x53, 0x52, 0x03, 0x74, 0x6c, 0x73, 0x1a, 0x8a, 0x01,
0x0a, 0x04, 0x47, 0x52, 0x50, 0x43, 0x12, 0x33, 0x0a, 0x07, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75,
0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65,
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69,
0x6f, 0x6e, 0x52, 0x07, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x12, 0x30, 0x0a, 0x0a, 0x6d,
0x69, 0x64, 0x64, 0x6c, 0x65, 0x77, 0x61, 0x72, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32,
0x10, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x2e, 0x4d, 0x69, 0x64, 0x64, 0x6c, 0x65, 0x77, 0x61, 0x72,
0x65, 0x52, 0x0a, 0x6d, 0x69, 0x64, 0x64, 0x6c, 0x65, 0x77, 0x61, 0x72, 0x65, 0x12, 0x1b, 0x0a,
0x03, 0x74, 0x6c, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x09, 0x2e, 0x63, 0x6f, 0x6e,
0x66, 0x2e, 0x54, 0x4c, 0x53, 0x52, 0x03, 0x74, 0x6c, 0x73, 0x42, 0x07, 0x0a, 0x05, 0x5f, 0x72,
0x65, 0x73, 0x74, 0x42, 0x07, 0x0a, 0x05, 0x5f, 0x67, 0x72, 0x70, 0x63, 0x42, 0x87, 0x01, 0x0a,
0x08, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x42, 0x15, 0x4b, 0x72, 0x61, 0x74, 0x6f,
0x73, 0x43, 0x6f, 0x6e, 0x66, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x50, 0x72, 0x6f, 0x74, 0x6f,
0x50, 0x01, 0x5a, 0x34, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x74,
0x78, 0x37, 0x64, 0x6f, 0x2f, 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2d, 0x62, 0x6f, 0x6f, 0x74,
0x73, 0x74, 0x72, 0x61, 0x70, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x67, 0x6f,
0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x2f, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x58, 0x58, 0xaa, 0x02,
0x04, 0x43, 0x6f, 0x6e, 0x66, 0xca, 0x02, 0x04, 0x43, 0x6f, 0x6e, 0x66, 0xe2, 0x02, 0x10, 0x43,
0x6f, 0x6e, 0x66, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea,
0x02, 0x04, 0x43, 0x6f, 0x6e, 0x66, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
@@ -249,19 +272,22 @@ var file_conf_v1_kratos_conf_client_proto_goTypes = []interface{}{
(*Client_GRPC)(nil), // 2: conf.Client.GRPC
(*durationpb.Duration)(nil), // 3: google.protobuf.Duration
(*Middleware)(nil), // 4: conf.Middleware
(*TLS)(nil), // 5: conf.TLS
}
var file_conf_v1_kratos_conf_client_proto_depIdxs = []int32{
1, // 0: conf.Client.rest:type_name -> conf.Client.REST
2, // 1: conf.Client.grpc:type_name -> conf.Client.GRPC
3, // 2: conf.Client.REST.timeout:type_name -> google.protobuf.Duration
4, // 3: conf.Client.REST.middleware:type_name -> conf.Middleware
3, // 4: conf.Client.GRPC.timeout:type_name -> google.protobuf.Duration
4, // 5: conf.Client.GRPC.middleware:type_name -> conf.Middleware
6, // [6:6] is the sub-list for method output_type
6, // [6:6] is the sub-list for method input_type
6, // [6:6] is the sub-list for extension type_name
6, // [6:6] is the sub-list for extension extendee
0, // [0:6] is the sub-list for field type_name
5, // 4: conf.Client.REST.tls:type_name -> conf.TLS
3, // 5: conf.Client.GRPC.timeout:type_name -> google.protobuf.Duration
4, // 6: conf.Client.GRPC.middleware:type_name -> conf.Middleware
5, // 7: conf.Client.GRPC.tls:type_name -> conf.TLS
8, // [8:8] is the sub-list for method output_type
8, // [8:8] is the sub-list for method input_type
8, // [8:8] is the sub-list for extension type_name
8, // [8:8] is the sub-list for extension extendee
0, // [0:8] is the sub-list for field type_name
}
func init() { file_conf_v1_kratos_conf_client_proto_init() }
@@ -270,6 +296,7 @@ func file_conf_v1_kratos_conf_client_proto_init() {
return
}
file_conf_v1_kratos_conf_middleware_proto_init()
file_conf_v1_kratos_conf_tls_proto_init()
if !protoimpl.UnsafeEnabled {
file_conf_v1_kratos_conf_client_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Client); i {
@@ -308,6 +335,7 @@ func file_conf_v1_kratos_conf_client_proto_init() {
}
}
}
file_conf_v1_kratos_conf_client_proto_msgTypes[0].OneofWrappers = []interface{}{}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{

View File

@@ -27,13 +27,13 @@ type RemoteConfig struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Type string `protobuf:"bytes,1,opt,name=type,proto3" json:"type,omitempty"`
Etcd *RemoteConfig_Etcd `protobuf:"bytes,2,opt,name=etcd,proto3" json:"etcd,omitempty"`
Consul *RemoteConfig_Consul `protobuf:"bytes,3,opt,name=consul,proto3" json:"consul,omitempty"`
Nacos *RemoteConfig_Nacos `protobuf:"bytes,4,opt,name=nacos,proto3" json:"nacos,omitempty"`
Apollo *RemoteConfig_Apollo `protobuf:"bytes,6,opt,name=apollo,proto3" json:"apollo,omitempty"`
Kubernetes *RemoteConfig_Kubernetes `protobuf:"bytes,7,opt,name=kubernetes,proto3" json:"kubernetes,omitempty"`
Polaris *RemoteConfig_Polaris `protobuf:"bytes,8,opt,name=polaris,proto3" json:"polaris,omitempty"`
Type string `protobuf:"bytes,1,opt,name=type,proto3" json:"type,omitempty"` // 配置类型
Etcd *RemoteConfig_Etcd `protobuf:"bytes,2,opt,name=etcd,proto3,oneof" json:"etcd,omitempty"`
Consul *RemoteConfig_Consul `protobuf:"bytes,3,opt,name=consul,proto3,oneof" json:"consul,omitempty"`
Nacos *RemoteConfig_Nacos `protobuf:"bytes,4,opt,name=nacos,proto3,oneof" json:"nacos,omitempty"`
Apollo *RemoteConfig_Apollo `protobuf:"bytes,6,opt,name=apollo,proto3,oneof" json:"apollo,omitempty"`
Kubernetes *RemoteConfig_Kubernetes `protobuf:"bytes,7,opt,name=kubernetes,proto3,oneof" json:"kubernetes,omitempty"`
Polaris *RemoteConfig_Polaris `protobuf:"bytes,8,opt,name=polaris,proto3,oneof" json:"polaris,omitempty"`
}
func (x *RemoteConfig) Reset() {
@@ -124,7 +124,7 @@ type RemoteConfig_Nacos struct {
Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` // 服务端地址
Port uint64 `protobuf:"varint,2,opt,name=port,proto3" json:"port,omitempty"` // 服务端端口
Key string `protobuf:"bytes,3,opt,name=key,proto3" json:"key,omitempty"` //
Key string `protobuf:"bytes,3,opt,name=key,proto3" json:"key,omitempty"` // 配置键
}
func (x *RemoteConfig_Nacos) Reset() {
@@ -185,9 +185,9 @@ type RemoteConfig_Etcd struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Endpoints []string `protobuf:"bytes,1,rep,name=endpoints,proto3" json:"endpoints,omitempty"`
Timeout *durationpb.Duration `protobuf:"bytes,2,opt,name=timeout,proto3" json:"timeout,omitempty"`
Key string `protobuf:"bytes,3,opt,name=key,proto3" json:"key,omitempty"` //
Endpoints []string `protobuf:"bytes,1,rep,name=endpoints,proto3" json:"endpoints,omitempty"` // 服务端地址
Timeout *durationpb.Duration `protobuf:"bytes,2,opt,name=timeout,proto3" json:"timeout,omitempty"` // 超时时间
Key string `protobuf:"bytes,3,opt,name=key,proto3" json:"key,omitempty"` // 配置键
}
func (x *RemoteConfig_Etcd) Reset() {
@@ -250,7 +250,7 @@ type RemoteConfig_Consul struct {
Scheme string `protobuf:"bytes,1,opt,name=scheme,proto3" json:"scheme,omitempty"` // 网络样式
Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"` // 服务端地址
Key string `protobuf:"bytes,3,opt,name=key,proto3" json:"key,omitempty"` //
Key string `protobuf:"bytes,3,opt,name=key,proto3" json:"key,omitempty"` // 配置键
}
func (x *RemoteConfig_Consul) Reset() {
@@ -311,11 +311,11 @@ type RemoteConfig_Apollo struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Endpoint string `protobuf:"bytes,1,opt,name=endpoint,proto3" json:"endpoint,omitempty"`
AppId string `protobuf:"bytes,2,opt,name=app_id,json=appId,proto3" json:"app_id,omitempty"`
Cluster string `protobuf:"bytes,3,opt,name=cluster,proto3" json:"cluster,omitempty"`
Namespace string `protobuf:"bytes,4,opt,name=namespace,proto3" json:"namespace,omitempty"`
Secret string `protobuf:"bytes,5,opt,name=secret,proto3" json:"secret,omitempty"`
Endpoint string `protobuf:"bytes,1,opt,name=endpoint,proto3" json:"endpoint,omitempty"` // 服务端地址
AppId string `protobuf:"bytes,2,opt,name=app_id,json=appId,proto3" json:"app_id,omitempty"` // 应用ID
Cluster string `protobuf:"bytes,3,opt,name=cluster,proto3" json:"cluster,omitempty"` // 集群
Namespace string `protobuf:"bytes,4,opt,name=namespace,proto3" json:"namespace,omitempty"` // 命名空间
Secret string `protobuf:"bytes,5,opt,name=secret,proto3" json:"secret,omitempty"` // 密钥
}
func (x *RemoteConfig_Apollo) Reset() {
@@ -390,7 +390,7 @@ type RemoteConfig_Kubernetes struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Namespace string `protobuf:"bytes,1,opt,name=namespace,proto3" json:"namespace,omitempty"`
Namespace string `protobuf:"bytes,1,opt,name=namespace,proto3" json:"namespace,omitempty"` // 命名空间
}
func (x *RemoteConfig_Kubernetes) Reset() {
@@ -477,66 +477,73 @@ var file_conf_v1_kratos_conf_config_proto_rawDesc = []byte{
0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x12, 0x04, 0x63, 0x6f, 0x6e, 0x66, 0x1a, 0x1e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65,
0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x64, 0x75, 0x72, 0x61, 0x74, 0x69,
0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xa3, 0x06, 0x0a, 0x0c, 0x52, 0x65, 0x6d,
0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x85, 0x07, 0x0a, 0x0c, 0x52, 0x65, 0x6d,
0x6f, 0x74, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70,
0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x2b, 0x0a,
0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x30, 0x0a,
0x04, 0x65, 0x74, 0x63, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x63, 0x6f,
0x6e, 0x66, 0x2e, 0x52, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e,
0x45, 0x74, 0x63, 0x64, 0x52, 0x04, 0x65, 0x74, 0x63, 0x64, 0x12, 0x31, 0x0a, 0x06, 0x63, 0x6f,
0x6e, 0x73, 0x75, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x63, 0x6f, 0x6e,
0x66, 0x2e, 0x52, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x43,
0x6f, 0x6e, 0x73, 0x75, 0x6c, 0x52, 0x06, 0x63, 0x6f, 0x6e, 0x73, 0x75, 0x6c, 0x12, 0x2e, 0x0a,
0x05, 0x6e, 0x61, 0x63, 0x6f, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x63,
0x45, 0x74, 0x63, 0x64, 0x48, 0x00, 0x52, 0x04, 0x65, 0x74, 0x63, 0x64, 0x88, 0x01, 0x01, 0x12,
0x36, 0x0a, 0x06, 0x63, 0x6f, 0x6e, 0x73, 0x75, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32,
0x19, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x2e, 0x52, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x43, 0x6f, 0x6e,
0x66, 0x69, 0x67, 0x2e, 0x43, 0x6f, 0x6e, 0x73, 0x75, 0x6c, 0x48, 0x01, 0x52, 0x06, 0x63, 0x6f,
0x6e, 0x73, 0x75, 0x6c, 0x88, 0x01, 0x01, 0x12, 0x33, 0x0a, 0x05, 0x6e, 0x61, 0x63, 0x6f, 0x73,
0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x2e, 0x52, 0x65,
0x6d, 0x6f, 0x74, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x4e, 0x61, 0x63, 0x6f, 0x73,
0x48, 0x02, 0x52, 0x05, 0x6e, 0x61, 0x63, 0x6f, 0x73, 0x88, 0x01, 0x01, 0x12, 0x36, 0x0a, 0x06,
0x61, 0x70, 0x6f, 0x6c, 0x6c, 0x6f, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x63,
0x6f, 0x6e, 0x66, 0x2e, 0x52, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67,
0x2e, 0x4e, 0x61, 0x63, 0x6f, 0x73, 0x52, 0x05, 0x6e, 0x61, 0x63, 0x6f, 0x73, 0x12, 0x31, 0x0a,
0x06, 0x61, 0x70, 0x6f, 0x6c, 0x6c, 0x6f, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e,
0x63, 0x6f, 0x6e, 0x66, 0x2e, 0x52, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69,
0x67, 0x2e, 0x41, 0x70, 0x6f, 0x6c, 0x6c, 0x6f, 0x52, 0x06, 0x61, 0x70, 0x6f, 0x6c, 0x6c, 0x6f,
0x12, 0x3d, 0x0a, 0x0a, 0x6b, 0x75, 0x62, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x65, 0x73, 0x18, 0x07,
0x20, 0x01, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x2e, 0x52, 0x65, 0x6d, 0x6f,
0x74, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x4b, 0x75, 0x62, 0x65, 0x72, 0x6e, 0x65,
0x74, 0x65, 0x73, 0x52, 0x0a, 0x6b, 0x75, 0x62, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x65, 0x73, 0x12,
0x34, 0x0a, 0x07, 0x70, 0x6f, 0x6c, 0x61, 0x72, 0x69, 0x73, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b,
0x32, 0x1a, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x2e, 0x52, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x43, 0x6f,
0x6e, 0x66, 0x69, 0x67, 0x2e, 0x50, 0x6f, 0x6c, 0x61, 0x72, 0x69, 0x73, 0x52, 0x07, 0x70, 0x6f,
0x6c, 0x61, 0x72, 0x69, 0x73, 0x1a, 0x47, 0x0a, 0x05, 0x4e, 0x61, 0x63, 0x6f, 0x73, 0x12, 0x18,
0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x6f, 0x72, 0x74,
0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x04, 0x70, 0x6f, 0x72, 0x74, 0x12, 0x10, 0x0a, 0x03,
0x6b, 0x65, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x1a, 0x6b,
0x0a, 0x04, 0x45, 0x74, 0x63, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69,
0x6e, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x09, 0x65, 0x6e, 0x64, 0x70, 0x6f,
0x69, 0x6e, 0x74, 0x73, 0x12, 0x33, 0x0a, 0x07, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x18,
0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e,
0x52, 0x07, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79,
0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x1a, 0x4c, 0x0a, 0x06, 0x43,
0x6f, 0x6e, 0x73, 0x75, 0x6c, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x18,
0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x12, 0x18, 0x0a,
0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07,
0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x03,
0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x1a, 0x8b, 0x01, 0x0a, 0x06, 0x41, 0x70,
0x6f, 0x6c, 0x6c, 0x6f, 0x12, 0x1a, 0x0a, 0x08, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74,
0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74,
0x12, 0x15, 0x0a, 0x06, 0x61, 0x70, 0x70, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09,
0x52, 0x05, 0x61, 0x70, 0x70, 0x49, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6c, 0x75, 0x73, 0x74,
0x65, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65,
0x72, 0x12, 0x1c, 0x0a, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x18, 0x04,
0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x12,
0x16, 0x0a, 0x06, 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52,
0x06, 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x1a, 0x2a, 0x0a, 0x0a, 0x4b, 0x75, 0x62, 0x65, 0x72,
0x6e, 0x65, 0x74, 0x65, 0x73, 0x12, 0x1c, 0x0a, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61,
0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70,
0x61, 0x63, 0x65, 0x1a, 0x09, 0x0a, 0x07, 0x50, 0x6f, 0x6c, 0x61, 0x72, 0x69, 0x73, 0x42, 0x87,
0x01, 0x0a, 0x08, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x42, 0x15, 0x4b, 0x72, 0x61,
0x74, 0x6f, 0x73, 0x43, 0x6f, 0x6e, 0x66, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x50, 0x72, 0x6f,
0x74, 0x6f, 0x50, 0x01, 0x5a, 0x34, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d,
0x2f, 0x74, 0x78, 0x37, 0x64, 0x6f, 0x2f, 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2d, 0x62, 0x6f,
0x6f, 0x74, 0x73, 0x74, 0x72, 0x61, 0x70, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x61, 0x70, 0x69, 0x2f,
0x67, 0x6f, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x2f, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x58, 0x58,
0xaa, 0x02, 0x04, 0x43, 0x6f, 0x6e, 0x66, 0xca, 0x02, 0x04, 0x43, 0x6f, 0x6e, 0x66, 0xe2, 0x02,
0x10, 0x43, 0x6f, 0x6e, 0x66, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74,
0x61, 0xea, 0x02, 0x04, 0x43, 0x6f, 0x6e, 0x66, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x2e, 0x41, 0x70, 0x6f, 0x6c, 0x6c, 0x6f, 0x48, 0x03, 0x52, 0x06, 0x61, 0x70, 0x6f, 0x6c, 0x6c,
0x6f, 0x88, 0x01, 0x01, 0x12, 0x42, 0x0a, 0x0a, 0x6b, 0x75, 0x62, 0x65, 0x72, 0x6e, 0x65, 0x74,
0x65, 0x73, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x2e,
0x52, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x4b, 0x75, 0x62,
0x65, 0x72, 0x6e, 0x65, 0x74, 0x65, 0x73, 0x48, 0x04, 0x52, 0x0a, 0x6b, 0x75, 0x62, 0x65, 0x72,
0x6e, 0x65, 0x74, 0x65, 0x73, 0x88, 0x01, 0x01, 0x12, 0x39, 0x0a, 0x07, 0x70, 0x6f, 0x6c, 0x61,
0x72, 0x69, 0x73, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x63, 0x6f, 0x6e, 0x66,
0x2e, 0x52, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x50, 0x6f,
0x6c, 0x61, 0x72, 0x69, 0x73, 0x48, 0x05, 0x52, 0x07, 0x70, 0x6f, 0x6c, 0x61, 0x72, 0x69, 0x73,
0x88, 0x01, 0x01, 0x1a, 0x47, 0x0a, 0x05, 0x4e, 0x61, 0x63, 0x6f, 0x73, 0x12, 0x18, 0x0a, 0x07,
0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61,
0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x02,
0x20, 0x01, 0x28, 0x04, 0x52, 0x04, 0x70, 0x6f, 0x72, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65,
0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x1a, 0x6b, 0x0a, 0x04,
0x45, 0x74, 0x63, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74,
0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x09, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e,
0x74, 0x73, 0x12, 0x33, 0x0a, 0x07, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x18, 0x02, 0x20,
0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x07,
0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x03,
0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x1a, 0x4c, 0x0a, 0x06, 0x43, 0x6f, 0x6e,
0x73, 0x75, 0x6c, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x18, 0x01, 0x20,
0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x61,
0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x64,
0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x03, 0x20, 0x01,
0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x1a, 0x8b, 0x01, 0x0a, 0x06, 0x41, 0x70, 0x6f, 0x6c,
0x6c, 0x6f, 0x12, 0x1a, 0x0a, 0x08, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x18, 0x01,
0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x12, 0x15,
0x0a, 0x06, 0x61, 0x70, 0x70, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05,
0x61, 0x70, 0x70, 0x49, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72,
0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x12,
0x1c, 0x0a, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x18, 0x04, 0x20, 0x01,
0x28, 0x09, 0x52, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x16, 0x0a,
0x06, 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73,
0x65, 0x63, 0x72, 0x65, 0x74, 0x1a, 0x2a, 0x0a, 0x0a, 0x4b, 0x75, 0x62, 0x65, 0x72, 0x6e, 0x65,
0x74, 0x65, 0x73, 0x12, 0x1c, 0x0a, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65,
0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63,
0x65, 0x1a, 0x09, 0x0a, 0x07, 0x50, 0x6f, 0x6c, 0x61, 0x72, 0x69, 0x73, 0x42, 0x07, 0x0a, 0x05,
0x5f, 0x65, 0x74, 0x63, 0x64, 0x42, 0x09, 0x0a, 0x07, 0x5f, 0x63, 0x6f, 0x6e, 0x73, 0x75, 0x6c,
0x42, 0x08, 0x0a, 0x06, 0x5f, 0x6e, 0x61, 0x63, 0x6f, 0x73, 0x42, 0x09, 0x0a, 0x07, 0x5f, 0x61,
0x70, 0x6f, 0x6c, 0x6c, 0x6f, 0x42, 0x0d, 0x0a, 0x0b, 0x5f, 0x6b, 0x75, 0x62, 0x65, 0x72, 0x6e,
0x65, 0x74, 0x65, 0x73, 0x42, 0x0a, 0x0a, 0x08, 0x5f, 0x70, 0x6f, 0x6c, 0x61, 0x72, 0x69, 0x73,
0x42, 0x87, 0x01, 0x0a, 0x08, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x42, 0x15, 0x4b,
0x72, 0x61, 0x74, 0x6f, 0x73, 0x43, 0x6f, 0x6e, 0x66, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x50,
0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x34, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63,
0x6f, 0x6d, 0x2f, 0x74, 0x78, 0x37, 0x64, 0x6f, 0x2f, 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2d,
0x62, 0x6f, 0x6f, 0x74, 0x73, 0x74, 0x72, 0x61, 0x70, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x67, 0x65,
0x6e, 0x2f, 0x67, 0x6f, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x2f, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x43,
0x58, 0x58, 0xaa, 0x02, 0x04, 0x43, 0x6f, 0x6e, 0x66, 0xca, 0x02, 0x04, 0x43, 0x6f, 0x6e, 0x66,
0xe2, 0x02, 0x10, 0x43, 0x6f, 0x6e, 0x66, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64,
0x61, 0x74, 0x61, 0xea, 0x02, 0x04, 0x43, 0x6f, 0x6e, 0x66, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x33,
}
var (
@@ -668,6 +675,7 @@ func file_conf_v1_kratos_conf_config_proto_init() {
}
}
}
file_conf_v1_kratos_conf_config_proto_msgTypes[0].OneofWrappers = []interface{}{}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{

File diff suppressed because it is too large Load Diff

View File

@@ -27,11 +27,11 @@ type Logger struct {
unknownFields protoimpl.UnknownFields
Type string `protobuf:"bytes,1,opt,name=type,proto3" json:"type,omitempty"`
Zap *Logger_Zap `protobuf:"bytes,2,opt,name=zap,proto3" json:"zap,omitempty"`
Logrus *Logger_Logrus `protobuf:"bytes,3,opt,name=logrus,proto3" json:"logrus,omitempty"`
Fluent *Logger_Fluent `protobuf:"bytes,4,opt,name=fluent,proto3" json:"fluent,omitempty"`
Aliyun *Logger_Aliyun `protobuf:"bytes,5,opt,name=aliyun,proto3" json:"aliyun,omitempty"`
Tencent *Logger_Tencent `protobuf:"bytes,6,opt,name=tencent,proto3" json:"tencent,omitempty"`
Zap *Logger_Zap `protobuf:"bytes,2,opt,name=zap,proto3,oneof" json:"zap,omitempty"`
Logrus *Logger_Logrus `protobuf:"bytes,3,opt,name=logrus,proto3,oneof" json:"logrus,omitempty"`
Fluent *Logger_Fluent `protobuf:"bytes,4,opt,name=fluent,proto3,oneof" json:"fluent,omitempty"`
Aliyun *Logger_Aliyun `protobuf:"bytes,5,opt,name=aliyun,proto3,oneof" json:"aliyun,omitempty"`
Tencent *Logger_Tencent `protobuf:"bytes,6,opt,name=tencent,proto3,oneof" json:"tencent,omitempty"`
}
func (x *Logger) Reset() {
@@ -465,72 +465,77 @@ var File_conf_v1_kratos_conf_logger_proto protoreflect.FileDescriptor
var file_conf_v1_kratos_conf_logger_proto_rawDesc = []byte{
0x0a, 0x20, 0x63, 0x6f, 0x6e, 0x66, 0x2f, 0x76, 0x31, 0x2f, 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73,
0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x5f, 0x6c, 0x6f, 0x67, 0x67, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x12, 0x04, 0x63, 0x6f, 0x6e, 0x66, 0x22, 0xf6, 0x06, 0x0a, 0x06, 0x4c, 0x6f, 0x67,
0x74, 0x6f, 0x12, 0x04, 0x63, 0x6f, 0x6e, 0x66, 0x22, 0xc4, 0x07, 0x0a, 0x06, 0x4c, 0x6f, 0x67,
0x67, 0x65, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28,
0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x22, 0x0a, 0x03, 0x7a, 0x61, 0x70, 0x18, 0x02,
0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x27, 0x0a, 0x03, 0x7a, 0x61, 0x70, 0x18, 0x02,
0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x2e, 0x4c, 0x6f, 0x67, 0x67,
0x65, 0x72, 0x2e, 0x5a, 0x61, 0x70, 0x52, 0x03, 0x7a, 0x61, 0x70, 0x12, 0x2b, 0x0a, 0x06, 0x6c,
0x6f, 0x67, 0x72, 0x75, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x63, 0x6f,
0x6e, 0x66, 0x2e, 0x4c, 0x6f, 0x67, 0x67, 0x65, 0x72, 0x2e, 0x4c, 0x6f, 0x67, 0x72, 0x75, 0x73,
0x52, 0x06, 0x6c, 0x6f, 0x67, 0x72, 0x75, 0x73, 0x12, 0x2b, 0x0a, 0x06, 0x66, 0x6c, 0x75, 0x65,
0x6e, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x2e,
0x4c, 0x6f, 0x67, 0x67, 0x65, 0x72, 0x2e, 0x46, 0x6c, 0x75, 0x65, 0x6e, 0x74, 0x52, 0x06, 0x66,
0x6c, 0x75, 0x65, 0x6e, 0x74, 0x12, 0x2b, 0x0a, 0x06, 0x61, 0x6c, 0x69, 0x79, 0x75, 0x6e, 0x18,
0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x2e, 0x4c, 0x6f, 0x67,
0x67, 0x65, 0x72, 0x2e, 0x41, 0x6c, 0x69, 0x79, 0x75, 0x6e, 0x52, 0x06, 0x61, 0x6c, 0x69, 0x79,
0x75, 0x6e, 0x12, 0x2e, 0x0a, 0x07, 0x74, 0x65, 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x18, 0x06, 0x20,
0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x2e, 0x4c, 0x6f, 0x67, 0x67, 0x65,
0x72, 0x2e, 0x54, 0x65, 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x52, 0x07, 0x74, 0x65, 0x6e, 0x63, 0x65,
0x6e, 0x74, 0x1a, 0x8c, 0x01, 0x0a, 0x03, 0x5a, 0x61, 0x70, 0x12, 0x1a, 0x0a, 0x08, 0x66, 0x69,
0x6c, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x66, 0x69,
0x6c, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x18,
0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x12, 0x19, 0x0a, 0x08,
0x6d, 0x61, 0x78, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07,
0x6d, 0x61, 0x78, 0x53, 0x69, 0x7a, 0x65, 0x12, 0x17, 0x0a, 0x07, 0x6d, 0x61, 0x78, 0x5f, 0x61,
0x67, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x6d, 0x61, 0x78, 0x41, 0x67, 0x65,
0x12, 0x1f, 0x0a, 0x0b, 0x6d, 0x61, 0x78, 0x5f, 0x62, 0x61, 0x63, 0x6b, 0x75, 0x70, 0x73, 0x18,
0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x6d, 0x61, 0x78, 0x42, 0x61, 0x63, 0x6b, 0x75, 0x70,
0x73, 0x1a, 0xbb, 0x01, 0x0a, 0x06, 0x4c, 0x6f, 0x67, 0x72, 0x75, 0x73, 0x12, 0x14, 0x0a, 0x05,
0x6c, 0x65, 0x76, 0x65, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6c, 0x65, 0x76,
0x65, 0x6c, 0x12, 0x1c, 0x0a, 0x09, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x74, 0x65, 0x72, 0x18,
0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x74, 0x65, 0x72,
0x12, 0x29, 0x0a, 0x10, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x5f, 0x66, 0x6f,
0x72, 0x6d, 0x61, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x74, 0x69, 0x6d, 0x65,
0x73, 0x74, 0x61, 0x6d, 0x70, 0x46, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x12, 0x25, 0x0a, 0x0e, 0x64,
0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x73, 0x18, 0x04, 0x20,
0x01, 0x28, 0x08, 0x52, 0x0d, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x43, 0x6f, 0x6c, 0x6f,
0x72, 0x73, 0x12, 0x2b, 0x0a, 0x11, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x74, 0x69,
0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x10, 0x64,
0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x1a,
0x24, 0x0a, 0x06, 0x46, 0x6c, 0x75, 0x65, 0x6e, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x65, 0x6e, 0x64,
0x65, 0x72, 0x2e, 0x5a, 0x61, 0x70, 0x48, 0x00, 0x52, 0x03, 0x7a, 0x61, 0x70, 0x88, 0x01, 0x01,
0x12, 0x30, 0x0a, 0x06, 0x6c, 0x6f, 0x67, 0x72, 0x75, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b,
0x32, 0x13, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x2e, 0x4c, 0x6f, 0x67, 0x67, 0x65, 0x72, 0x2e, 0x4c,
0x6f, 0x67, 0x72, 0x75, 0x73, 0x48, 0x01, 0x52, 0x06, 0x6c, 0x6f, 0x67, 0x72, 0x75, 0x73, 0x88,
0x01, 0x01, 0x12, 0x30, 0x0a, 0x06, 0x66, 0x6c, 0x75, 0x65, 0x6e, 0x74, 0x18, 0x04, 0x20, 0x01,
0x28, 0x0b, 0x32, 0x13, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x2e, 0x4c, 0x6f, 0x67, 0x67, 0x65, 0x72,
0x2e, 0x46, 0x6c, 0x75, 0x65, 0x6e, 0x74, 0x48, 0x02, 0x52, 0x06, 0x66, 0x6c, 0x75, 0x65, 0x6e,
0x74, 0x88, 0x01, 0x01, 0x12, 0x30, 0x0a, 0x06, 0x61, 0x6c, 0x69, 0x79, 0x75, 0x6e, 0x18, 0x05,
0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x2e, 0x4c, 0x6f, 0x67, 0x67,
0x65, 0x72, 0x2e, 0x41, 0x6c, 0x69, 0x79, 0x75, 0x6e, 0x48, 0x03, 0x52, 0x06, 0x61, 0x6c, 0x69,
0x79, 0x75, 0x6e, 0x88, 0x01, 0x01, 0x12, 0x33, 0x0a, 0x07, 0x74, 0x65, 0x6e, 0x63, 0x65, 0x6e,
0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x2e, 0x4c,
0x6f, 0x67, 0x67, 0x65, 0x72, 0x2e, 0x54, 0x65, 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x48, 0x04, 0x52,
0x07, 0x74, 0x65, 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x88, 0x01, 0x01, 0x1a, 0x8c, 0x01, 0x0a, 0x03,
0x5a, 0x61, 0x70, 0x12, 0x1a, 0x0a, 0x08, 0x66, 0x69, 0x6c, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x18,
0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x66, 0x69, 0x6c, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x12,
0x14, 0x0a, 0x05, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05,
0x6c, 0x65, 0x76, 0x65, 0x6c, 0x12, 0x19, 0x0a, 0x08, 0x6d, 0x61, 0x78, 0x5f, 0x73, 0x69, 0x7a,
0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x6d, 0x61, 0x78, 0x53, 0x69, 0x7a, 0x65,
0x12, 0x17, 0x0a, 0x07, 0x6d, 0x61, 0x78, 0x5f, 0x61, 0x67, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28,
0x05, 0x52, 0x06, 0x6d, 0x61, 0x78, 0x41, 0x67, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x6d, 0x61, 0x78,
0x5f, 0x62, 0x61, 0x63, 0x6b, 0x75, 0x70, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a,
0x6d, 0x61, 0x78, 0x42, 0x61, 0x63, 0x6b, 0x75, 0x70, 0x73, 0x1a, 0xbb, 0x01, 0x0a, 0x06, 0x4c,
0x6f, 0x67, 0x72, 0x75, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x18, 0x01,
0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x12, 0x1c, 0x0a, 0x09, 0x66,
0x6f, 0x72, 0x6d, 0x61, 0x74, 0x74, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09,
0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x74, 0x65, 0x72, 0x12, 0x29, 0x0a, 0x10, 0x74, 0x69, 0x6d,
0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x5f, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x18, 0x03, 0x20,
0x01, 0x28, 0x09, 0x52, 0x0f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x46, 0x6f,
0x72, 0x6d, 0x61, 0x74, 0x12, 0x25, 0x0a, 0x0e, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x5f,
0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0d, 0x64, 0x69,
0x73, 0x61, 0x62, 0x6c, 0x65, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x73, 0x12, 0x2b, 0x0a, 0x11, 0x64,
0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70,
0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x10, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x54,
0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x1a, 0x24, 0x0a, 0x06, 0x46, 0x6c, 0x75, 0x65,
0x6e, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x18, 0x01,
0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x1a, 0x82,
0x01, 0x0a, 0x06, 0x41, 0x6c, 0x69, 0x79, 0x75, 0x6e, 0x12, 0x1a, 0x0a, 0x08, 0x65, 0x6e, 0x64,
0x70, 0x6f, 0x69, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x65, 0x6e, 0x64,
0x70, 0x6f, 0x69, 0x6e, 0x74, 0x1a, 0x82, 0x01, 0x0a, 0x06, 0x41, 0x6c, 0x69, 0x79, 0x75, 0x6e,
0x12, 0x1a, 0x0a, 0x08, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01,
0x28, 0x09, 0x52, 0x08, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x12, 0x18, 0x0a, 0x07,
0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x70,
0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73,
0x70, 0x6f, 0x69, 0x6e, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74,
0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x70, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x12,
0x1d, 0x0a, 0x0a, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x03, 0x20,
0x01, 0x28, 0x09, 0x52, 0x09, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x4b, 0x65, 0x79, 0x12, 0x23,
0x0a, 0x0d, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x5f, 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x18,
0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x53, 0x65, 0x63,
0x72, 0x65, 0x74, 0x1a, 0x84, 0x01, 0x0a, 0x07, 0x54, 0x65, 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x12,
0x1a, 0x0a, 0x08, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28,
0x09, 0x52, 0x08, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x12, 0x19, 0x0a, 0x08, 0x74,
0x6f, 0x70, 0x69, 0x63, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x74,
0x6f, 0x70, 0x69, 0x63, 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73,
0x5f, 0x6b, 0x65, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x61, 0x63, 0x63, 0x65,
0x73, 0x73, 0x4b, 0x65, 0x79, 0x12, 0x23, 0x0a, 0x0d, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x5f,
0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x61, 0x63,
0x63, 0x65, 0x73, 0x73, 0x53, 0x65, 0x63, 0x72, 0x65, 0x74, 0x1a, 0x84, 0x01, 0x0a, 0x07, 0x54,
0x65, 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69,
0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69,
0x6e, 0x74, 0x12, 0x19, 0x0a, 0x08, 0x74, 0x6f, 0x70, 0x69, 0x63, 0x5f, 0x69, 0x64, 0x18, 0x02,
0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x74, 0x6f, 0x70, 0x69, 0x63, 0x49, 0x64, 0x12, 0x1d, 0x0a,
0x0a, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28,
0x09, 0x52, 0x09, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x4b, 0x65, 0x79, 0x12, 0x23, 0x0a, 0x0d,
0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x5f, 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x18, 0x04, 0x20,
0x01, 0x28, 0x09, 0x52, 0x0c, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x53, 0x65, 0x63, 0x72, 0x65,
0x74, 0x42, 0x87, 0x01, 0x0a, 0x08, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x42, 0x15,
0x4b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x43, 0x6f, 0x6e, 0x66, 0x4c, 0x6f, 0x67, 0x67, 0x65, 0x72,
0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x34, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e,
0x63, 0x6f, 0x6d, 0x2f, 0x74, 0x78, 0x37, 0x64, 0x6f, 0x2f, 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73,
0x2d, 0x62, 0x6f, 0x6f, 0x74, 0x73, 0x74, 0x72, 0x61, 0x70, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x61,
0x70, 0x69, 0x2f, 0x67, 0x6f, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x2f, 0x76, 0x31, 0xa2, 0x02, 0x03,
0x43, 0x58, 0x58, 0xaa, 0x02, 0x04, 0x43, 0x6f, 0x6e, 0x66, 0xca, 0x02, 0x04, 0x43, 0x6f, 0x6e,
0x66, 0xe2, 0x02, 0x10, 0x43, 0x6f, 0x6e, 0x66, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61,
0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x04, 0x43, 0x6f, 0x6e, 0x66, 0x62, 0x06, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x33,
0x63, 0x65, 0x73, 0x73, 0x53, 0x65, 0x63, 0x72, 0x65, 0x74, 0x42, 0x06, 0x0a, 0x04, 0x5f, 0x7a,
0x61, 0x70, 0x42, 0x09, 0x0a, 0x07, 0x5f, 0x6c, 0x6f, 0x67, 0x72, 0x75, 0x73, 0x42, 0x09, 0x0a,
0x07, 0x5f, 0x66, 0x6c, 0x75, 0x65, 0x6e, 0x74, 0x42, 0x09, 0x0a, 0x07, 0x5f, 0x61, 0x6c, 0x69,
0x79, 0x75, 0x6e, 0x42, 0x0a, 0x0a, 0x08, 0x5f, 0x74, 0x65, 0x6e, 0x63, 0x65, 0x6e, 0x74, 0x42,
0x87, 0x01, 0x0a, 0x08, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x42, 0x15, 0x4b, 0x72,
0x61, 0x74, 0x6f, 0x73, 0x43, 0x6f, 0x6e, 0x66, 0x4c, 0x6f, 0x67, 0x67, 0x65, 0x72, 0x50, 0x72,
0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x34, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f,
0x6d, 0x2f, 0x74, 0x78, 0x37, 0x64, 0x6f, 0x2f, 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2d, 0x62,
0x6f, 0x6f, 0x74, 0x73, 0x74, 0x72, 0x61, 0x70, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x67, 0x65, 0x6e,
0x2f, 0x67, 0x6f, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x2f, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x58,
0x58, 0xaa, 0x02, 0x04, 0x43, 0x6f, 0x6e, 0x66, 0xca, 0x02, 0x04, 0x43, 0x6f, 0x6e, 0x66, 0xe2,
0x02, 0x10, 0x43, 0x6f, 0x6e, 0x66, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61,
0x74, 0x61, 0xea, 0x02, 0x04, 0x43, 0x6f, 0x6e, 0x66, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x33,
}
var (
@@ -646,6 +651,7 @@ func file_conf_v1_kratos_conf_logger_proto_init() {
}
}
}
file_conf_v1_kratos_conf_logger_proto_msgTypes[0].OneofWrappers = []interface{}{}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{

View File

@@ -348,8 +348,8 @@ var file_conf_v1_kratos_conf_middleware_proto_rawDesc = []byte{
0x72, 0x61, 0x74, 0x6f, 0x73, 0x43, 0x6f, 0x6e, 0x66, 0x4d, 0x69, 0x64, 0x64, 0x6c, 0x65, 0x77,
0x61, 0x72, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x34, 0x67, 0x69, 0x74, 0x68,
0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x74, 0x78, 0x37, 0x64, 0x6f, 0x2f, 0x6b, 0x72, 0x61,
0x74, 0x6f, 0x73, 0x2d, 0x62, 0x6f, 0x6f, 0x74, 0x73, 0x74, 0x72, 0x61, 0x70, 0x2f, 0x67, 0x65,
0x6e, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x67, 0x6f, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x2f, 0x76, 0x31,
0x74, 0x6f, 0x73, 0x2d, 0x62, 0x6f, 0x6f, 0x74, 0x73, 0x74, 0x72, 0x61, 0x70, 0x2f, 0x61, 0x70,
0x69, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x67, 0x6f, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x2f, 0x76, 0x31,
0xa2, 0x02, 0x03, 0x43, 0x58, 0x58, 0xaa, 0x02, 0x04, 0x43, 0x6f, 0x6e, 0x66, 0xca, 0x02, 0x04,
0x43, 0x6f, 0x6e, 0x66, 0xe2, 0x02, 0x10, 0x43, 0x6f, 0x6e, 0x66, 0x5c, 0x47, 0x50, 0x42, 0x4d,
0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x04, 0x43, 0x6f, 0x6e, 0x66, 0x62, 0x06,

View File

@@ -162,8 +162,8 @@ var file_conf_v1_kratos_conf_notify_proto_rawDesc = []byte{
0x66, 0x42, 0x15, 0x4b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x43, 0x6f, 0x6e, 0x66, 0x4e, 0x6f, 0x74,
0x69, 0x66, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x34, 0x67, 0x69, 0x74, 0x68,
0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x74, 0x78, 0x37, 0x64, 0x6f, 0x2f, 0x6b, 0x72, 0x61,
0x74, 0x6f, 0x73, 0x2d, 0x62, 0x6f, 0x6f, 0x74, 0x73, 0x74, 0x72, 0x61, 0x70, 0x2f, 0x67, 0x65,
0x6e, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x67, 0x6f, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x2f, 0x76, 0x31,
0x74, 0x6f, 0x73, 0x2d, 0x62, 0x6f, 0x6f, 0x74, 0x73, 0x74, 0x72, 0x61, 0x70, 0x2f, 0x61, 0x70,
0x69, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x67, 0x6f, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x2f, 0x76, 0x31,
0xa2, 0x02, 0x03, 0x43, 0x58, 0x58, 0xaa, 0x02, 0x04, 0x43, 0x6f, 0x6e, 0x66, 0xca, 0x02, 0x04,
0x43, 0x6f, 0x6e, 0x66, 0xe2, 0x02, 0x10, 0x43, 0x6f, 0x6e, 0x66, 0x5c, 0x47, 0x50, 0x42, 0x4d,
0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x04, 0x43, 0x6f, 0x6e, 0x66, 0x62, 0x06,

View File

@@ -73,13 +73,14 @@ type OSS_MinIO struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Endpoint string `protobuf:"bytes,1,opt,name=endpoint,proto3" json:"endpoint,omitempty"` // 对端端口
AccessKey string `protobuf:"bytes,2,opt,name=access_key,json=accessKey,proto3" json:"access_key,omitempty"` // 访问密钥
SecretKey string `protobuf:"bytes,3,opt,name=secret_key,json=secretKey,proto3" json:"secret_key,omitempty"` // 密钥
Token string `protobuf:"bytes,4,opt,name=token,proto3" json:"token,omitempty"` // 令牌
UseSsl bool `protobuf:"varint,5,opt,name=use_ssl,json=useSsl,proto3" json:"use_ssl,omitempty"` // 使用SSL
UploadHost string `protobuf:"bytes,6,opt,name=upload_host,json=uploadHost,proto3" json:"upload_host,omitempty"` // 上传链接的主机名
DownloadHost string `protobuf:"bytes,7,opt,name=download_host,json=downloadHost,proto3" json:"download_host,omitempty"` // 下载链接的主机名
Endpoint string `protobuf:"bytes,1,opt,name=endpoint,proto3" json:"endpoint,omitempty"` // 对端端口
AccessKey string `protobuf:"bytes,2,opt,name=access_key,json=accessKey,proto3" json:"access_key,omitempty"` // 访问密钥
SecretKey string `protobuf:"bytes,3,opt,name=secret_key,json=secretKey,proto3" json:"secret_key,omitempty"` // 密钥
Token string `protobuf:"bytes,4,opt,name=token,proto3" json:"token,omitempty"` // 令牌
UseSsl bool `protobuf:"varint,10,opt,name=use_ssl,json=useSsl,proto3" json:"use_ssl,omitempty"` // 使用SSL
Tls *TLS `protobuf:"bytes,11,opt,name=tls,proto3" json:"tls,omitempty"` // TLS配置
UploadHost string `protobuf:"bytes,20,opt,name=upload_host,json=uploadHost,proto3" json:"upload_host,omitempty"` // 上传链接的主机名
DownloadHost string `protobuf:"bytes,21,opt,name=download_host,json=downloadHost,proto3" json:"download_host,omitempty"` // 下载链接的主机名
}
func (x *OSS_MinIO) Reset() {
@@ -149,6 +150,13 @@ func (x *OSS_MinIO) GetUseSsl() bool {
return false
}
func (x *OSS_MinIO) GetTls() *TLS {
if x != nil {
return x.Tls
}
return nil
}
func (x *OSS_MinIO) GetUploadHost() string {
if x != nil {
return x.UploadHost
@@ -168,32 +176,36 @@ var File_conf_v1_kratos_conf_oss_proto protoreflect.FileDescriptor
var file_conf_v1_kratos_conf_oss_proto_rawDesc = []byte{
0x0a, 0x1d, 0x63, 0x6f, 0x6e, 0x66, 0x2f, 0x76, 0x31, 0x2f, 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73,
0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x5f, 0x6f, 0x73, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12,
0x04, 0x63, 0x6f, 0x6e, 0x66, 0x22, 0x85, 0x02, 0x0a, 0x03, 0x4f, 0x53, 0x53, 0x12, 0x25, 0x0a,
0x05, 0x6d, 0x69, 0x6e, 0x69, 0x6f, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x63,
0x6f, 0x6e, 0x66, 0x2e, 0x4f, 0x53, 0x53, 0x2e, 0x4d, 0x69, 0x6e, 0x49, 0x4f, 0x52, 0x05, 0x6d,
0x69, 0x6e, 0x69, 0x6f, 0x1a, 0xd6, 0x01, 0x0a, 0x05, 0x4d, 0x69, 0x6e, 0x49, 0x4f, 0x12, 0x1a,
0x0a, 0x08, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09,
0x52, 0x08, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x61, 0x63,
0x63, 0x65, 0x73, 0x73, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09,
0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x4b, 0x65, 0x79, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x65, 0x63,
0x72, 0x65, 0x74, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73,
0x65, 0x63, 0x72, 0x65, 0x74, 0x4b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x6f, 0x6b, 0x65,
0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x17,
0x0a, 0x07, 0x75, 0x73, 0x65, 0x5f, 0x73, 0x73, 0x6c, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52,
0x06, 0x75, 0x73, 0x65, 0x53, 0x73, 0x6c, 0x12, 0x1f, 0x0a, 0x0b, 0x75, 0x70, 0x6c, 0x6f, 0x61,
0x64, 0x5f, 0x68, 0x6f, 0x73, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x75, 0x70,
0x6c, 0x6f, 0x61, 0x64, 0x48, 0x6f, 0x73, 0x74, 0x12, 0x23, 0x0a, 0x0d, 0x64, 0x6f, 0x77, 0x6e,
0x6c, 0x6f, 0x61, 0x64, 0x5f, 0x68, 0x6f, 0x73, 0x74, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52,
0x0c, 0x64, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x48, 0x6f, 0x73, 0x74, 0x42, 0x84, 0x01,
0x0a, 0x08, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x42, 0x12, 0x4b, 0x72, 0x61, 0x74,
0x6f, 0x73, 0x43, 0x6f, 0x6e, 0x66, 0x4f, 0x73, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01,
0x5a, 0x34, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x74, 0x78, 0x37,
0x64, 0x6f, 0x2f, 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2d, 0x62, 0x6f, 0x6f, 0x74, 0x73, 0x74,
0x72, 0x61, 0x70, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x67, 0x6f, 0x2f, 0x63,
0x6f, 0x6e, 0x66, 0x2f, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x58, 0x58, 0xaa, 0x02, 0x04, 0x43,
0x6f, 0x6e, 0x66, 0xca, 0x02, 0x04, 0x43, 0x6f, 0x6e, 0x66, 0xe2, 0x02, 0x10, 0x43, 0x6f, 0x6e,
0x66, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x04,
0x43, 0x6f, 0x6e, 0x66, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x04, 0x63, 0x6f, 0x6e, 0x66, 0x1a, 0x1d, 0x63, 0x6f, 0x6e, 0x66, 0x2f, 0x76, 0x31, 0x2f, 0x6b,
0x72, 0x61, 0x74, 0x6f, 0x73, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x5f, 0x74, 0x6c, 0x73, 0x2e, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x22, 0xa2, 0x02, 0x0a, 0x03, 0x4f, 0x53, 0x53, 0x12, 0x25, 0x0a, 0x05,
0x6d, 0x69, 0x6e, 0x69, 0x6f, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x63, 0x6f,
0x6e, 0x66, 0x2e, 0x4f, 0x53, 0x53, 0x2e, 0x4d, 0x69, 0x6e, 0x49, 0x4f, 0x52, 0x05, 0x6d, 0x69,
0x6e, 0x69, 0x6f, 0x1a, 0xf3, 0x01, 0x0a, 0x05, 0x4d, 0x69, 0x6e, 0x49, 0x4f, 0x12, 0x1a, 0x0a,
0x08, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
0x08, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x61, 0x63, 0x63,
0x65, 0x73, 0x73, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x61,
0x63, 0x63, 0x65, 0x73, 0x73, 0x4b, 0x65, 0x79, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x65, 0x63, 0x72,
0x65, 0x74, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x65,
0x63, 0x72, 0x65, 0x74, 0x4b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e,
0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x17, 0x0a,
0x07, 0x75, 0x73, 0x65, 0x5f, 0x73, 0x73, 0x6c, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06,
0x75, 0x73, 0x65, 0x53, 0x73, 0x6c, 0x12, 0x1b, 0x0a, 0x03, 0x74, 0x6c, 0x73, 0x18, 0x0b, 0x20,
0x01, 0x28, 0x0b, 0x32, 0x09, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x2e, 0x54, 0x4c, 0x53, 0x52, 0x03,
0x74, 0x6c, 0x73, 0x12, 0x1f, 0x0a, 0x0b, 0x75, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x5f, 0x68, 0x6f,
0x73, 0x74, 0x18, 0x14, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x75, 0x70, 0x6c, 0x6f, 0x61, 0x64,
0x48, 0x6f, 0x73, 0x74, 0x12, 0x23, 0x0a, 0x0d, 0x64, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64,
0x5f, 0x68, 0x6f, 0x73, 0x74, 0x18, 0x15, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x64, 0x6f, 0x77,
0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x48, 0x6f, 0x73, 0x74, 0x42, 0x84, 0x01, 0x0a, 0x08, 0x63, 0x6f,
0x6d, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x42, 0x12, 0x4b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x43, 0x6f,
0x6e, 0x66, 0x4f, 0x73, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x34, 0x67, 0x69,
0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x74, 0x78, 0x37, 0x64, 0x6f, 0x2f, 0x6b,
0x72, 0x61, 0x74, 0x6f, 0x73, 0x2d, 0x62, 0x6f, 0x6f, 0x74, 0x73, 0x74, 0x72, 0x61, 0x70, 0x2f,
0x61, 0x70, 0x69, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x67, 0x6f, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x2f,
0x76, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x58, 0x58, 0xaa, 0x02, 0x04, 0x43, 0x6f, 0x6e, 0x66, 0xca,
0x02, 0x04, 0x43, 0x6f, 0x6e, 0x66, 0xe2, 0x02, 0x10, 0x43, 0x6f, 0x6e, 0x66, 0x5c, 0x47, 0x50,
0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x04, 0x43, 0x6f, 0x6e, 0x66,
0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
@@ -212,14 +224,16 @@ var file_conf_v1_kratos_conf_oss_proto_msgTypes = make([]protoimpl.MessageInfo,
var file_conf_v1_kratos_conf_oss_proto_goTypes = []interface{}{
(*OSS)(nil), // 0: conf.OSS
(*OSS_MinIO)(nil), // 1: conf.OSS.MinIO
(*TLS)(nil), // 2: conf.TLS
}
var file_conf_v1_kratos_conf_oss_proto_depIdxs = []int32{
1, // 0: conf.OSS.minio:type_name -> conf.OSS.MinIO
1, // [1:1] is the sub-list for method output_type
1, // [1:1] is the sub-list for method input_type
1, // [1:1] is the sub-list for extension type_name
1, // [1:1] is the sub-list for extension extendee
0, // [0:1] is the sub-list for field type_name
2, // 1: conf.OSS.MinIO.tls:type_name -> conf.TLS
2, // [2:2] is the sub-list for method output_type
2, // [2:2] is the sub-list for method input_type
2, // [2:2] is the sub-list for extension type_name
2, // [2:2] is the sub-list for extension extendee
0, // [0:2] is the sub-list for field type_name
}
func init() { file_conf_v1_kratos_conf_oss_proto_init() }
@@ -227,6 +241,7 @@ func file_conf_v1_kratos_conf_oss_proto_init() {
if File_conf_v1_kratos_conf_oss_proto != nil {
return
}
file_conf_v1_kratos_conf_tls_proto_init()
if !protoimpl.UnsafeEnabled {
file_conf_v1_kratos_conf_oss_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*OSS); i {

View File

@@ -785,7 +785,7 @@ var file_conf_v1_kratos_conf_registry_proto_rawDesc = []byte{
0x6e, 0x66, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50,
0x01, 0x5a, 0x34, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x74, 0x78,
0x37, 0x64, 0x6f, 0x2f, 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2d, 0x62, 0x6f, 0x6f, 0x74, 0x73,
0x74, 0x72, 0x61, 0x70, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x67, 0x6f, 0x2f,
0x74, 0x72, 0x61, 0x70, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x67, 0x6f, 0x2f,
0x63, 0x6f, 0x6e, 0x66, 0x2f, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x58, 0x58, 0xaa, 0x02, 0x04,
0x43, 0x6f, 0x6e, 0x66, 0xca, 0x02, 0x04, 0x43, 0x6f, 0x6e, 0x66, 0xe2, 0x02, 0x10, 0x43, 0x6f,
0x6e, 0x66, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02,

View File

@@ -0,0 +1,349 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.31.0
// protoc (unknown)
// source: conf/v1/kratos_conf_tls.proto
package v1
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
)
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 TLS struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
File *TLS_File `protobuf:"bytes,1,opt,name=file,proto3,oneof" json:"file,omitempty"`
Config *TLS_Config `protobuf:"bytes,2,opt,name=config,proto3,oneof" json:"config,omitempty"`
InsecureSkipVerify bool `protobuf:"varint,3,opt,name=insecure_skip_verify,json=insecureSkipVerify,proto3" json:"insecure_skip_verify,omitempty"`
}
func (x *TLS) Reset() {
*x = TLS{}
if protoimpl.UnsafeEnabled {
mi := &file_conf_v1_kratos_conf_tls_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *TLS) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*TLS) ProtoMessage() {}
func (x *TLS) ProtoReflect() protoreflect.Message {
mi := &file_conf_v1_kratos_conf_tls_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use TLS.ProtoReflect.Descriptor instead.
func (*TLS) Descriptor() ([]byte, []int) {
return file_conf_v1_kratos_conf_tls_proto_rawDescGZIP(), []int{0}
}
func (x *TLS) GetFile() *TLS_File {
if x != nil {
return x.File
}
return nil
}
func (x *TLS) GetConfig() *TLS_Config {
if x != nil {
return x.Config
}
return nil
}
func (x *TLS) GetInsecureSkipVerify() bool {
if x != nil {
return x.InsecureSkipVerify
}
return false
}
type TLS_File struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
CertPath *string `protobuf:"bytes,1,opt,name=cert_path,json=certPath,proto3,oneof" json:"cert_path,omitempty"`
KeyPath *string `protobuf:"bytes,2,opt,name=key_path,json=keyPath,proto3,oneof" json:"key_path,omitempty"`
CaPath *string `protobuf:"bytes,3,opt,name=ca_path,json=caPath,proto3,oneof" json:"ca_path,omitempty"`
}
func (x *TLS_File) Reset() {
*x = TLS_File{}
if protoimpl.UnsafeEnabled {
mi := &file_conf_v1_kratos_conf_tls_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *TLS_File) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*TLS_File) ProtoMessage() {}
func (x *TLS_File) ProtoReflect() protoreflect.Message {
mi := &file_conf_v1_kratos_conf_tls_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use TLS_File.ProtoReflect.Descriptor instead.
func (*TLS_File) Descriptor() ([]byte, []int) {
return file_conf_v1_kratos_conf_tls_proto_rawDescGZIP(), []int{0, 0}
}
func (x *TLS_File) GetCertPath() string {
if x != nil && x.CertPath != nil {
return *x.CertPath
}
return ""
}
func (x *TLS_File) GetKeyPath() string {
if x != nil && x.KeyPath != nil {
return *x.KeyPath
}
return ""
}
func (x *TLS_File) GetCaPath() string {
if x != nil && x.CaPath != nil {
return *x.CaPath
}
return ""
}
type TLS_Config struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
CertPem []byte `protobuf:"bytes,1,opt,name=cert_pem,json=certPem,proto3,oneof" json:"cert_pem,omitempty"`
KeyPem []byte `protobuf:"bytes,2,opt,name=key_pem,json=keyPem,proto3,oneof" json:"key_pem,omitempty"`
CaPem []byte `protobuf:"bytes,3,opt,name=ca_pem,json=caPem,proto3,oneof" json:"ca_pem,omitempty"`
}
func (x *TLS_Config) Reset() {
*x = TLS_Config{}
if protoimpl.UnsafeEnabled {
mi := &file_conf_v1_kratos_conf_tls_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *TLS_Config) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*TLS_Config) ProtoMessage() {}
func (x *TLS_Config) ProtoReflect() protoreflect.Message {
mi := &file_conf_v1_kratos_conf_tls_proto_msgTypes[2]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use TLS_Config.ProtoReflect.Descriptor instead.
func (*TLS_Config) Descriptor() ([]byte, []int) {
return file_conf_v1_kratos_conf_tls_proto_rawDescGZIP(), []int{0, 1}
}
func (x *TLS_Config) GetCertPem() []byte {
if x != nil {
return x.CertPem
}
return nil
}
func (x *TLS_Config) GetKeyPem() []byte {
if x != nil {
return x.KeyPem
}
return nil
}
func (x *TLS_Config) GetCaPem() []byte {
if x != nil {
return x.CaPem
}
return nil
}
var File_conf_v1_kratos_conf_tls_proto protoreflect.FileDescriptor
var file_conf_v1_kratos_conf_tls_proto_rawDesc = []byte{
0x0a, 0x1d, 0x63, 0x6f, 0x6e, 0x66, 0x2f, 0x76, 0x31, 0x2f, 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73,
0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x5f, 0x74, 0x6c, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12,
0x04, 0x63, 0x6f, 0x6e, 0x66, 0x22, 0xbc, 0x03, 0x0a, 0x03, 0x54, 0x4c, 0x53, 0x12, 0x27, 0x0a,
0x04, 0x66, 0x69, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x63, 0x6f,
0x6e, 0x66, 0x2e, 0x54, 0x4c, 0x53, 0x2e, 0x46, 0x69, 0x6c, 0x65, 0x48, 0x00, 0x52, 0x04, 0x66,
0x69, 0x6c, 0x65, 0x88, 0x01, 0x01, 0x12, 0x2d, 0x0a, 0x06, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67,
0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x2e, 0x54, 0x4c,
0x53, 0x2e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x48, 0x01, 0x52, 0x06, 0x63, 0x6f, 0x6e, 0x66,
0x69, 0x67, 0x88, 0x01, 0x01, 0x12, 0x30, 0x0a, 0x14, 0x69, 0x6e, 0x73, 0x65, 0x63, 0x75, 0x72,
0x65, 0x5f, 0x73, 0x6b, 0x69, 0x70, 0x5f, 0x76, 0x65, 0x72, 0x69, 0x66, 0x79, 0x18, 0x03, 0x20,
0x01, 0x28, 0x08, 0x52, 0x12, 0x69, 0x6e, 0x73, 0x65, 0x63, 0x75, 0x72, 0x65, 0x53, 0x6b, 0x69,
0x70, 0x56, 0x65, 0x72, 0x69, 0x66, 0x79, 0x1a, 0x8d, 0x01, 0x0a, 0x04, 0x46, 0x69, 0x6c, 0x65,
0x12, 0x20, 0x0a, 0x09, 0x63, 0x65, 0x72, 0x74, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x18, 0x01, 0x20,
0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x08, 0x63, 0x65, 0x72, 0x74, 0x50, 0x61, 0x74, 0x68, 0x88,
0x01, 0x01, 0x12, 0x1e, 0x0a, 0x08, 0x6b, 0x65, 0x79, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x18, 0x02,
0x20, 0x01, 0x28, 0x09, 0x48, 0x01, 0x52, 0x07, 0x6b, 0x65, 0x79, 0x50, 0x61, 0x74, 0x68, 0x88,
0x01, 0x01, 0x12, 0x1c, 0x0a, 0x07, 0x63, 0x61, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x18, 0x03, 0x20,
0x01, 0x28, 0x09, 0x48, 0x02, 0x52, 0x06, 0x63, 0x61, 0x50, 0x61, 0x74, 0x68, 0x88, 0x01, 0x01,
0x42, 0x0c, 0x0a, 0x0a, 0x5f, 0x63, 0x65, 0x72, 0x74, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x42, 0x0b,
0x0a, 0x09, 0x5f, 0x6b, 0x65, 0x79, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x42, 0x0a, 0x0a, 0x08, 0x5f,
0x63, 0x61, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x1a, 0x86, 0x01, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66,
0x69, 0x67, 0x12, 0x1e, 0x0a, 0x08, 0x63, 0x65, 0x72, 0x74, 0x5f, 0x70, 0x65, 0x6d, 0x18, 0x01,
0x20, 0x01, 0x28, 0x0c, 0x48, 0x00, 0x52, 0x07, 0x63, 0x65, 0x72, 0x74, 0x50, 0x65, 0x6d, 0x88,
0x01, 0x01, 0x12, 0x1c, 0x0a, 0x07, 0x6b, 0x65, 0x79, 0x5f, 0x70, 0x65, 0x6d, 0x18, 0x02, 0x20,
0x01, 0x28, 0x0c, 0x48, 0x01, 0x52, 0x06, 0x6b, 0x65, 0x79, 0x50, 0x65, 0x6d, 0x88, 0x01, 0x01,
0x12, 0x1a, 0x0a, 0x06, 0x63, 0x61, 0x5f, 0x70, 0x65, 0x6d, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c,
0x48, 0x02, 0x52, 0x05, 0x63, 0x61, 0x50, 0x65, 0x6d, 0x88, 0x01, 0x01, 0x42, 0x0b, 0x0a, 0x09,
0x5f, 0x63, 0x65, 0x72, 0x74, 0x5f, 0x70, 0x65, 0x6d, 0x42, 0x0a, 0x0a, 0x08, 0x5f, 0x6b, 0x65,
0x79, 0x5f, 0x70, 0x65, 0x6d, 0x42, 0x09, 0x0a, 0x07, 0x5f, 0x63, 0x61, 0x5f, 0x70, 0x65, 0x6d,
0x42, 0x07, 0x0a, 0x05, 0x5f, 0x66, 0x69, 0x6c, 0x65, 0x42, 0x09, 0x0a, 0x07, 0x5f, 0x63, 0x6f,
0x6e, 0x66, 0x69, 0x67, 0x42, 0x84, 0x01, 0x0a, 0x08, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x6e,
0x66, 0x42, 0x12, 0x4b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x43, 0x6f, 0x6e, 0x66, 0x54, 0x6c, 0x73,
0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x34, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e,
0x63, 0x6f, 0x6d, 0x2f, 0x74, 0x78, 0x37, 0x64, 0x6f, 0x2f, 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73,
0x2d, 0x62, 0x6f, 0x6f, 0x74, 0x73, 0x74, 0x72, 0x61, 0x70, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x67,
0x65, 0x6e, 0x2f, 0x67, 0x6f, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x2f, 0x76, 0x31, 0xa2, 0x02, 0x03,
0x43, 0x58, 0x58, 0xaa, 0x02, 0x04, 0x43, 0x6f, 0x6e, 0x66, 0xca, 0x02, 0x04, 0x43, 0x6f, 0x6e,
0x66, 0xe2, 0x02, 0x10, 0x43, 0x6f, 0x6e, 0x66, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61,
0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x04, 0x43, 0x6f, 0x6e, 0x66, 0x62, 0x06, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x33,
}
var (
file_conf_v1_kratos_conf_tls_proto_rawDescOnce sync.Once
file_conf_v1_kratos_conf_tls_proto_rawDescData = file_conf_v1_kratos_conf_tls_proto_rawDesc
)
func file_conf_v1_kratos_conf_tls_proto_rawDescGZIP() []byte {
file_conf_v1_kratos_conf_tls_proto_rawDescOnce.Do(func() {
file_conf_v1_kratos_conf_tls_proto_rawDescData = protoimpl.X.CompressGZIP(file_conf_v1_kratos_conf_tls_proto_rawDescData)
})
return file_conf_v1_kratos_conf_tls_proto_rawDescData
}
var file_conf_v1_kratos_conf_tls_proto_msgTypes = make([]protoimpl.MessageInfo, 3)
var file_conf_v1_kratos_conf_tls_proto_goTypes = []interface{}{
(*TLS)(nil), // 0: conf.TLS
(*TLS_File)(nil), // 1: conf.TLS.File
(*TLS_Config)(nil), // 2: conf.TLS.Config
}
var file_conf_v1_kratos_conf_tls_proto_depIdxs = []int32{
1, // 0: conf.TLS.file:type_name -> conf.TLS.File
2, // 1: conf.TLS.config:type_name -> conf.TLS.Config
2, // [2:2] is the sub-list for method output_type
2, // [2:2] is the sub-list for method input_type
2, // [2:2] is the sub-list for extension type_name
2, // [2:2] is the sub-list for extension extendee
0, // [0:2] is the sub-list for field type_name
}
func init() { file_conf_v1_kratos_conf_tls_proto_init() }
func file_conf_v1_kratos_conf_tls_proto_init() {
if File_conf_v1_kratos_conf_tls_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_conf_v1_kratos_conf_tls_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*TLS); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_conf_v1_kratos_conf_tls_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*TLS_File); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_conf_v1_kratos_conf_tls_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*TLS_Config); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
file_conf_v1_kratos_conf_tls_proto_msgTypes[0].OneofWrappers = []interface{}{}
file_conf_v1_kratos_conf_tls_proto_msgTypes[1].OneofWrappers = []interface{}{}
file_conf_v1_kratos_conf_tls_proto_msgTypes[2].OneofWrappers = []interface{}{}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_conf_v1_kratos_conf_tls_proto_rawDesc,
NumEnums: 0,
NumMessages: 3,
NumExtensions: 0,
NumServices: 0,
},
GoTypes: file_conf_v1_kratos_conf_tls_proto_goTypes,
DependencyIndexes: file_conf_v1_kratos_conf_tls_proto_depIdxs,
MessageInfos: file_conf_v1_kratos_conf_tls_proto_msgTypes,
}.Build()
File_conf_v1_kratos_conf_tls_proto = out.File
file_conf_v1_kratos_conf_tls_proto_rawDesc = nil
file_conf_v1_kratos_conf_tls_proto_goTypes = nil
file_conf_v1_kratos_conf_tls_proto_depIdxs = nil
}

View File

@@ -118,8 +118,8 @@ var file_conf_v1_kratos_conf_tracer_proto_rawDesc = []byte{
0x4b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x43, 0x6f, 0x6e, 0x66, 0x54, 0x72, 0x61, 0x63, 0x65, 0x72,
0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x34, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e,
0x63, 0x6f, 0x6d, 0x2f, 0x74, 0x78, 0x37, 0x64, 0x6f, 0x2f, 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73,
0x2d, 0x62, 0x6f, 0x6f, 0x74, 0x73, 0x74, 0x72, 0x61, 0x70, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x61,
0x70, 0x69, 0x2f, 0x67, 0x6f, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x2f, 0x76, 0x31, 0xa2, 0x02, 0x03,
0x2d, 0x62, 0x6f, 0x6f, 0x74, 0x73, 0x74, 0x72, 0x61, 0x70, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x67,
0x65, 0x6e, 0x2f, 0x67, 0x6f, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x2f, 0x76, 0x31, 0xa2, 0x02, 0x03,
0x43, 0x58, 0x58, 0xaa, 0x02, 0x04, 0x43, 0x6f, 0x6e, 0x66, 0xca, 0x02, 0x04, 0x43, 0x6f, 0x6e,
0x66, 0xe2, 0x02, 0x10, 0x43, 0x6f, 0x6e, 0x66, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61,
0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x04, 0x43, 0x6f, 0x6e, 0x66, 0x62, 0x06, 0x70, 0x72, 0x6f,

View File

@@ -249,7 +249,7 @@ var file_pagination_v1_pagination_proto_rawDesc = []byte{
0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x3a, 0x67,
0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x74, 0x78, 0x37, 0x64, 0x6f, 0x2f,
0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2d, 0x62, 0x6f, 0x6f, 0x74, 0x73, 0x74, 0x72, 0x61, 0x70,
0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x67, 0x6f, 0x2f, 0x70, 0x61, 0x67, 0x69,
0x2f, 0x61, 0x70, 0x69, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x67, 0x6f, 0x2f, 0x70, 0x61, 0x67, 0x69,
0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x50, 0x58, 0x58, 0xaa,
0x02, 0x0a, 0x50, 0x61, 0x67, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0xca, 0x02, 0x0a, 0x50,
0x61, 0x67, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0xe2, 0x02, 0x16, 0x50, 0x61, 0x67, 0x69,

18
api/go.mod Normal file
View File

@@ -0,0 +1,18 @@
module github.com/tx7do/kratos-bootstrap/api
go 1.22.0
toolchain go1.22.1
require (
github.com/google/gnostic v0.7.0
google.golang.org/protobuf v1.35.1
)
require (
github.com/google/gnostic-models v0.6.9-0.20230804172637-c7be7c783f49 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/rogpeppe/go-internal v1.10.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

1523
api/go.sum Normal file

File diff suppressed because it is too large Load Diff

28
api/protos/buf.lock Normal file
View File

@@ -0,0 +1,28 @@
# Generated by buf. DO NOT EDIT.
version: v1
deps:
- remote: buf.build
owner: envoyproxy
repository: protoc-gen-validate
commit: eac44469a7af47e7839a7f1f3d7ac004
digest: shake256:0feabcde01b6b11e3c75a5e3f807968d5995626546f39c37e5d4205892b3a59cced0ed83b35a2eb9e6dddd3309660ad46b737c9dcd224b425de0a6654ce04417
- remote: buf.build
owner: gnostic
repository: gnostic
commit: 087bc8072ce44e339f213209e4d57bf0
digest: shake256:4689c26f0460fea84c4c277c1b9c7e7d657388c5b4116d1065f907a92100ffbea87de05bbd138a0166411361e1f6ce063b4c0c6002358d39710f3c4a8de788d5
- remote: buf.build
owner: gogo
repository: protobuf
commit: 5461a3dfa9d941da82028ab185dc2a0e
digest: shake256:37c7c75224982038cb1abf45b481ef06716c1f806ffaa162018d0df092bd11a2a9b62c2d0dc0a2ae43beff86b6014fc0eb8c594ffd84d52ade4b08fca901eadc
- remote: buf.build
owner: googleapis
repository: googleapis
commit: 28151c0d0a1641bf938a7672c500e01d
digest: shake256:49215edf8ef57f7863004539deff8834cfb2195113f0b890dd1f67815d9353e28e668019165b9d872395871eeafcbab3ccfdb2b5f11734d3cca95be9e8d139de
- remote: buf.build
owner: kratos
repository: apis
commit: c2de25f14fa445a79a054214f31d17a8
digest: shake256:91c024935d46f7966667c29e4fc933435959f93c3f0e675e1227c99db09905d44f8ec275b770da7659df5a6b18f4710da157b6d8ad760a4a95f60365b231e637

View File

@@ -2,7 +2,7 @@ syntax = "proto3";
package conf;
option go_package = "github.com/tx7do/kratos-bootstrap/gen/api/go/conf/v1;conf";
option go_package = "github.com/tx7do/kratos-bootstrap/api/gen/go/conf/v1;conf";
import "conf/v1/kratos_conf_tracer.proto";
import "conf/v1/kratos_conf_data.proto";

View File

@@ -0,0 +1,30 @@
syntax = "proto3";
package conf;
option go_package = "github.com/tx7do/kratos-bootstrap/api/gen/go/conf/v1;conf";
import "google/protobuf/duration.proto";
import "conf/v1/kratos_conf_middleware.proto";
import "conf/v1/kratos_conf_tls.proto";
// 客户端
message Client {
// REST
message REST {
google.protobuf.Duration timeout = 1; // 超时时间
Middleware middleware = 2; // 中间件
TLS tls = 3; // TLS配置
}
// gPRC
message GRPC {
google.protobuf.Duration timeout = 1; // 超时时间
Middleware middleware = 2; // 中间件
TLS tls = 3; // TLS配置
}
optional REST rest = 1; // REST服务
optional GRPC grpc = 2; // gRPC服务
}

View File

@@ -0,0 +1,53 @@
syntax = "proto3";
package conf;
option go_package = "github.com/tx7do/kratos-bootstrap/api/gen/go/conf/v1;conf";
import "google/protobuf/duration.proto";
// 配置服务
message RemoteConfig {
message Nacos {
string address = 1; // 服务端地址
uint64 port = 2; // 服务端端口
string key = 3; // 配置键
}
message Etcd {
repeated string endpoints = 1; // 服务端地址
google.protobuf.Duration timeout = 2; // 超时时间
string key = 3; // 配置键
}
message Consul {
string scheme = 1; // 网络样式
string address = 2; // 服务端地址
string key = 3; // 配置键
}
message Apollo {
string endpoint = 1; // 服务端地址
string app_id = 2; // 应用ID
string cluster = 3; // 集群
string namespace = 4; // 命名空间
string secret = 5; // 密钥
}
message Kubernetes {
string namespace = 1; // 命名空间
}
message Polaris {
}
string type = 1; // 配置类型
optional Etcd etcd = 2;
optional Consul consul = 3;
optional Nacos nacos = 4;
optional Apollo apollo = 6;
optional Kubernetes kubernetes = 7;
optional Polaris polaris = 8;
}

View File

@@ -0,0 +1,201 @@
syntax = "proto3";
package conf;
option go_package = "github.com/tx7do/kratos-bootstrap/api/gen/go/conf/v1;conf";
import "google/protobuf/duration.proto";
import "conf/v1/kratos_conf_tls.proto";
// 数据
message Data {
// 数据库
message Database {
string driver = 1; // 驱动名mysql、postgresql、mongodb、sqlite……
string source = 2; // 数据源DSN字符串
bool migrate = 10; // 数据迁移开关
bool debug = 11; // 调试开关
bool enable_trace = 12; // 链路追踪开关
bool enable_metrics = 13; // 性能分析开关
optional int32 max_idle_connections = 20; // 连接池最大空闲连接数
optional int32 max_open_connections = 21; // 连接池最大打开连接数
optional google.protobuf.Duration connection_max_lifetime = 22; // 连接可重用的最大时间长度
optional string prometheus_push_addr = 30;
optional string prometheus_db_name = 31;
optional uint32 prometheus_http_port = 32;
}
// redis
message Redis {
string network = 1; // 网络
string addr = 2; // 服务端地址
string password = 3; // 密码
int32 db = 4; // 数据库索引
google.protobuf.Duration dial_timeout = 5; // 连接超时时间
google.protobuf.Duration read_timeout = 6; // 读取超时时间
google.protobuf.Duration write_timeout = 7; // 写入超时时间
bool enable_tracing = 8; // 打开链路追踪
bool enable_metrics = 9; // 打开性能度量
}
// MongoDB
message MongoDB {
string address = 1;
string username = 2;
string password = 3;
}
// ClickHouse
message ClickHouse {
string address = 1;
string database = 2;
string username = 3;
string password = 4;
bool debug = 5;
string compression_method = 6;
google.protobuf.Duration dial_timeout = 7;
int32 max_execution_time = 8;
int32 max_open_conns = 9;
int32 max_idle_conns = 10;
google.protobuf.Duration conn_max_life_time = 11;
int32 block_buffer_size = 12;
int32 max_compression_buffer = 13;
string conn_open_strategy = 14;
int32 max_idle_connections = 15; // 连接池最大空闲连接数
int32 max_open_connections = 16; // 连接池最大打开连接数
google.protobuf.Duration connection_max_lifetime = 17; // 连接可重用的最大时间长度
string protocol = 18;
TLS tls = 19; // TLS配置
}
// InfluxDB
message InfluxDB {
string address = 1;
string token = 2;
string organization = 3;
string bucket = 4;
}
message Doris {
string address = 1;
}
message ElasticSearch {
repeated string addresses = 1;
string username = 2;
string password = 3;
bool enable_sniffer = 4;
bool enable_gzip = 5;
google.protobuf.Duration health_check_interval = 6;
}
message Cassandra {
string address = 1;
string username = 2;
string password = 3;
string keyspace = 5;
google.protobuf.Duration connect_timeout = 6;
google.protobuf.Duration timeout = 7;
uint32 consistency = 8;
bool disable_initial_host_lookup = 9;
bool ignore_peer_addr = 10;
TLS tls = 11; // TLS配置
}
message Snowflake {
}
// Kafka
message Kafka {
repeated string endpoints = 1; // 对端网络地址
string codec = 2; // 编解码器
bool async = 3; // 异步发送
bool allow_auto_topic_creation = 4; // 允许发送的时候自动创建主题
int32 batch_size = 5; // 批量发送量
int64 batch_bytes = 6;// 批量发送字节数
google.protobuf.Duration batch_timeout = 7; // 批量发送超时时间
google.protobuf.Duration read_timeout = 8; // 读取超时时间
google.protobuf.Duration write_timeout = 9; // 发送超时时间
}
// RabbitMQ
message RabbitMQ {
repeated string endpoints = 1; // 对端网络地址
}
// MQTT
message Mqtt {
string endpoint = 1; // 对端网络地址
string codec = 2; // 编解码器: json,xml,yaml...
}
message ActiveMQ {
string endpoint = 1; // 对端网络地址
string codec = 2; // 编解码器: json,xml,yaml...
}
message NATS {
string endpoint = 1; // 对端网络地址
string codec = 2; // 编解码器: json,xml,yaml...
}
message NSQ {
string endpoint = 1; // 对端网络地址
string codec = 2; // 编解码器: json,xml,yaml...
}
message Pulsar {
string endpoint = 1; // 对端网络地址
string codec = 2; // 编解码器: json,xml,yaml...
}
message RocketMQ {
string version = 1; // 驱动版本aliyun、v2、v5
string codec = 2; // 编解码器: json,xml,yaml...
bool enable_trace = 3;
repeated string name_servers = 4;
string name_server_domain = 5;
string access_key = 6;
string secret_key = 7;
string security_token = 8;
string namespace = 9;
string instance_name = 10;
string group_name = 11;
}
optional Database database = 1; // 数据库DSN
optional Redis redis = 10; // Redis
optional MongoDB mongodb = 11; // MongoDB数据库
optional ElasticSearch elastic_search = 12; // ElasticSearch数据库
optional Cassandra cassandra = 13; // Cassandra数据库
optional ClickHouse clickhouse = 20; // ClickHouse数据库
optional InfluxDB influxdb = 21; // InfluxDB数据库
optional Doris doris = 22; // Doris数据库
// Message Queue
optional Kafka kafka = 30; // Kafka服务
optional RabbitMQ rabbitmq = 31; // RabbitMQ服务
optional Mqtt mqtt = 32; // MQTT服务
optional ActiveMQ activemq = 33; // ActiveMQ
optional NATS nats = 34; // NATS
optional NSQ nsq = 35; // NATS
optional Pulsar pulsar = 36; // Pulsar
optional RocketMQ rocketmq = 38; // RocketMQ
}

View File

@@ -2,7 +2,7 @@ syntax = "proto3";
package conf;
option go_package = "github.com/tx7do/kratos-bootstrap/gen/api/go/conf/v1;conf";
option go_package = "github.com/tx7do/kratos-bootstrap/api/gen/go/conf/v1;conf";
//
message Logger {
@@ -47,9 +47,9 @@ message Logger {
string type = 1;
Zap zap = 2;
Logrus logrus = 3;
Fluent fluent = 4;
Aliyun aliyun = 5;
Tencent tencent = 6;
optional Zap zap = 2;
optional Logrus logrus = 3;
optional Fluent fluent = 4;
optional Aliyun aliyun = 5;
optional Tencent tencent = 6;
}

View File

@@ -2,7 +2,7 @@ syntax = "proto3";
package conf;
option go_package = "github.com/tx7do/kratos-bootstrap/gen/api/go/conf/v1;conf";
option go_package = "github.com/tx7do/kratos-bootstrap/api/gen/go/conf/v1;conf";
import "google/protobuf/duration.proto";

View File

@@ -2,7 +2,7 @@ syntax = "proto3";
package conf;
option go_package = "github.com/tx7do/kratos-bootstrap/gen/api/go/conf/v1;conf";
option go_package = "github.com/tx7do/kratos-bootstrap/api/gen/go/conf/v1;conf";
//
message Notification {

View File

@@ -0,0 +1,25 @@
syntax = "proto3";
package conf;
option go_package = "github.com/tx7do/kratos-bootstrap/api/gen/go/conf/v1;conf";
import "conf/v1/kratos_conf_tls.proto";
message OSS {
// MinIO
message MinIO {
string endpoint = 1; // 对端端口
string access_key = 2; // 访问密钥
string secret_key = 3; // 密钥
string token = 4; // 令牌
bool use_ssl = 10; // 使用SSL
TLS tls = 11; // TLS配置
string upload_host = 20; // 上传链接的主机名
string download_host = 21; // 下载链接的主机名
}
MinIO minio = 1;
}

View File

@@ -2,7 +2,7 @@ syntax = "proto3";
package conf;
option go_package = "github.com/tx7do/kratos-bootstrap/gen/api/go/conf/v1;conf";
option go_package = "github.com/tx7do/kratos-bootstrap/api/gen/go/conf/v1;conf";
import "google/protobuf/duration.proto";
@@ -30,13 +30,18 @@ message Registry {
message Nacos {
string address = 1; //
uint64 port = 2; //
string namespace_id = 3; //
string log_level = 4; //
string cache_dir = 5; //
string log_dir = 6; //
int32 update_thread_num = 7; // 线
google.protobuf.Duration timeout = 8; // http请求超时时间:
google.protobuf.Duration beat_interval = 9; // :
bool not_load_cache_at_start = 10; // true: false:
bool update_cache_when_empty = 11; // true: ,false:
}

View File

@@ -2,10 +2,12 @@ syntax = "proto3";
package conf;
option go_package = "github.com/tx7do/kratos-bootstrap/gen/api/go/conf/v1;conf";
option go_package = "github.com/tx7do/kratos-bootstrap/api/gen/go/conf/v1;conf";
import "google/protobuf/duration.proto";
import "conf/v1/kratos_conf_middleware.proto";
import "conf/v1/kratos_conf_tls.proto";
//
message Server {
@@ -20,18 +22,25 @@ message Server {
string network = 1; //
string addr = 2; //
google.protobuf.Duration timeout = 3; //
CORS cors = 4; //
Middleware middleware = 5; //
bool enable_swagger = 6; // SwaggerUI
bool enable_pprof = 7; // pprof
CORS cors = 10; //
Middleware middleware = 11; //
TLS tls = 12; // TLS配置
bool enable_swagger = 20; // SwaggerUI
bool enable_pprof = 21; // pprof
}
// gPRC
message GRPC {
string network = 1; //
string addr = 2; //
google.protobuf.Duration timeout = 3; //
Middleware middleware = 4;
TLS tls = 5; // TLS配置
}
// Websocket
@@ -41,51 +50,64 @@ message Server {
string path = 3; //
string codec = 4; // : json,xml,yaml...
google.protobuf.Duration timeout = 5; //
TLS tls = 6; // TLS配置
}
// MQTT
message Mqtt {
string addr = 1; //
string endpoint = 1; //
string codec = 2; // : json,xml,yaml...
TLS tls = 3; // TLS配置
}
// Kafka
message Kafka {
repeated string addrs = 1; //
repeated string endpoints = 1; //
string codec = 2; // : json,xml,yaml...
TLS tls = 3; // TLS配置
}
// RabbitMQ
message RabbitMQ {
repeated string addrs = 1; //
repeated string endpoints = 1; //
string codec = 2; // : json,xml,yaml...
TLS tls = 3; // TLS配置
}
message ActiveMQ {
string endpoint = 1; //
string codec = 2; // : json,xml,yaml...
TLS tls = 3; // TLS配置
}
message NATS {
string endpoint = 1; //
string codec = 2; // : json,xml,yaml...
TLS tls = 3; // TLS配置
}
message NSQ {
string endpoint = 1; //
string codec = 2; // : json,xml,yaml...
TLS tls = 3; // TLS配置
}
message Pulsar {
string endpoint = 1; //
string codec = 2; // : json,xml,yaml...
TLS tls = 3; // TLS配置
}
message Redis {
string endpoint = 1; //
string codec = 2; // : json,xml,yaml...
TLS tls = 3; // TLS配置
}
message RocketMQ {
string version = 1; // aliyunv2v5
string codec = 2; // : json,xml,yaml...
bool enable_trace = 3;
repeated string name_servers = 4;
@@ -98,6 +120,8 @@ message Server {
string namespace = 9;
string instance_name = 10;
string group_name = 11;
TLS tls = 12; // TLS配置
}
// Asynq
@@ -105,12 +129,15 @@ message Server {
string endpoint = 1; //
string password = 2; // redis登录密码
int32 db = 3; //
string location = 4; //
TLS tls = 5; // TLS配置
}
// Machinery
message Machinery {
repeated string brokers = 1; // broker的地址使RedisAMQP或AWS SQS
repeated string backends = 2; // backend配置Redismemcached或mongodb等
TLS tls = 3; // TLS配置
}
// SSE
@@ -119,14 +146,15 @@ message Server {
string addr = 2; //
string path = 3; //
string codec = 4; //
TLS tls = 5; // TLS配置
google.protobuf.Duration timeout = 5; //
google.protobuf.Duration event_ttl = 6; //
google.protobuf.Duration timeout = 10; //
google.protobuf.Duration event_ttl = 11; //
bool auto_stream = 7; //
bool auto_reply = 8; //
bool split_data = 9; //
bool encode_base64 = 10; // BASE64编码
bool auto_stream = 20; //
bool auto_reply = 21; //
bool split_data = 22; //
bool encode_base64 = 23; // BASE64编码
}
// SocketIO
@@ -135,6 +163,7 @@ message Server {
string addr = 2; //
string path = 3; //
string codec = 4; //
TLS tls = 5; // TLS配置
}
// SignalR
@@ -142,9 +171,11 @@ message Server {
string network = 1; //
string addr = 2; //
string codec = 3; //
TLS tls = 4; // TLS配置
google.protobuf.Duration keep_alive_interval = 10; //
google.protobuf.Duration chan_receive_timeout = 11; //
google.protobuf.Duration keep_alive_interval = 4; //
google.protobuf.Duration chan_receive_timeout = 5; //
bool debug = 6; //
uint32 stream_buffer_capacity = 7; //
}
@@ -157,6 +188,7 @@ message Server {
string codec = 4; //
google.protobuf.Duration timeout = 5; //
bool strict_slash = 6;
TLS tls = 7; // TLS配置
}
// Thrift
@@ -167,36 +199,37 @@ message Server {
bool buffered = 4;
bool framed = 5;
bool buffer_size = 6;
TLS tls = 7; // TLS配置
}
// RPC
REST rest = 1; // REST服务
GRPC grpc = 2; // gRPC服务
GraphQL graphql = 3; // GraphQL服务
Thrift thrift = 4; // Thrift服务
optional REST rest = 1; // REST服务
optional GRPC grpc = 2; // gRPC服务
optional GraphQL graphql = 3; // GraphQL服务
optional Thrift thrift = 4; // Thrift服务
// Message Queue
Mqtt mqtt = 10; // MQTT服务
Kafka kafka = 11; // Kafka服务
RabbitMQ rabbitmq = 12; // RabbitMQ服务
ActiveMQ activemq = 13; // ActiveMQ
NATS nats = 14; // NATS
NSQ nsq = 15; // NATS
Pulsar pulsar = 16; // Pulsar
Redis redis = 17; // Redis
RocketMQ rocketmq = 18; // RocketMQ
optional Mqtt mqtt = 10; // MQTT服务
optional Kafka kafka = 11; // Kafka服务
optional RabbitMQ rabbitmq = 12; // RabbitMQ服务
optional ActiveMQ activemq = 13; // ActiveMQ
optional NATS nats = 14; // NATS
optional NSQ nsq = 15; // NATS
optional Pulsar pulsar = 16; // Pulsar
optional Redis redis = 17; // Redis
optional RocketMQ rocketmq = 18; // RocketMQ
// RealTime
// RealTime
Websocket websocket = 20; // Websocket服务
SSE sse = 21; // SSE服务
SocketIO socketio = 22; // SocketIO服务
SignalR signalr = 23; // SignalR服务
optional Websocket websocket = 20; // Websocket服务
optional SSE sse = 21; // SSE服务
optional SocketIO socketio = 22; // SocketIO服务
optional SignalR signalr = 23; // SignalR服务
// Task Queue
Asynq asynq = 30; // Asynq服务
Machinery machinery = 31; // Machinery服务
optional Asynq asynq = 30; // Asynq服务
optional Machinery machinery = 31; // Machinery服务
}

View File

@@ -0,0 +1,23 @@
syntax = "proto3";
package conf;
option go_package = "github.com/tx7do/kratos-bootstrap/api/gen/go/conf/v1;conf";
message TLS {
message File {
optional string cert_path = 1;
optional string key_path = 2;
optional string ca_path = 3;
}
message Config {
optional bytes cert_pem = 1;
optional bytes key_pem = 2;
optional bytes ca_pem = 3;
}
optional File file = 1;
optional Config config = 2;
bool insecure_skip_verify = 3;
}

View File

@@ -2,7 +2,7 @@ syntax = "proto3";
package conf;
option go_package = "github.com/tx7do/kratos-bootstrap/gen/api/go/conf/v1;conf";
option go_package = "github.com/tx7do/kratos-bootstrap/api/gen/go/conf/v1;conf";
//
message Tracer {

View File

@@ -1,36 +0,0 @@
package bootstrap
import (
"fmt"
"github.com/go-kratos/kratos/v2/log"
"github.com/go-kratos/kratos/v2/registry"
conf "github.com/tx7do/kratos-bootstrap/gen/api/go/conf/v1"
)
// Bootstrap 应用引导启动
func Bootstrap(serviceInfo *ServiceInfo) (*conf.Bootstrap, log.Logger, registry.Registrar) {
// inject command flags
Flags := NewCommandFlags()
Flags.Init()
var err error
// load configs
if err = LoadBootstrapConfig(Flags.Conf); err != nil {
panic(fmt.Sprintf("load config failed: %v", err))
}
// init logger
ll := NewLoggerProvider(commonConfig.Logger, serviceInfo)
// init registrar
reg := NewRegistry(commonConfig.Registry)
// init tracer
if err = NewTracerProvider(commonConfig.Trace, serviceInfo); err != nil {
panic(fmt.Sprintf("init tracer failed: %v", err))
}
return commonConfig, ll, reg
}

95
bootstrap/bootstrap.go Normal file
View File

@@ -0,0 +1,95 @@
package bootstrap
import (
"fmt"
"github.com/go-kratos/kratos/v2"
"github.com/go-kratos/kratos/v2/log"
kratosRegistry "github.com/go-kratos/kratos/v2/registry"
"github.com/go-kratos/kratos/v2/transport"
"github.com/tx7do/kratos-bootstrap/config"
"github.com/tx7do/kratos-bootstrap/logger"
"github.com/tx7do/kratos-bootstrap/registry"
"github.com/tx7do/kratos-bootstrap/tracer"
conf "github.com/tx7do/kratos-bootstrap/api/gen/go/conf/v1"
"github.com/tx7do/kratos-bootstrap/utils"
)
var (
Service = utils.NewServiceInfo(
"",
"1.0.0",
"",
)
)
// NewApp 创建应用程序
func NewApp(ll log.Logger, rr kratosRegistry.Registrar, srv ...transport.Server) *kratos.App {
return kratos.New(
kratos.ID(Service.GetInstanceId()),
kratos.Name(Service.Name),
kratos.Version(Service.Version),
kratos.Metadata(Service.Metadata),
kratos.Logger(ll),
kratos.Server(
srv...,
),
kratos.Registrar(rr),
)
}
// DoBootstrap 执行引导
func DoBootstrap(serviceInfo *utils.ServiceInfo) (*conf.Bootstrap, log.Logger, kratosRegistry.Registrar) {
// inject command flags
Flags := config.NewCommandFlags()
Flags.Init()
var err error
// load configs
if err = config.LoadBootstrapConfig(Flags.Conf); err != nil {
panic(fmt.Sprintf("load config failed: %v", err))
}
// init logger
ll := logger.NewLoggerProvider(config.GetBootstrapConfig().Logger, serviceInfo)
// init registrar
reg := registry.NewRegistry(config.GetBootstrapConfig().Registry)
// init tracer
if err = tracer.NewTracerProvider(config.GetBootstrapConfig().Trace, serviceInfo); err != nil {
panic(fmt.Sprintf("init tracer failed: %v", err))
}
return config.GetBootstrapConfig(), ll, reg
}
type InitApp func(logger log.Logger, registrar kratosRegistry.Registrar, bootstrap *conf.Bootstrap) (*kratos.App, func(), error)
// Bootstrap 应用引导启动
func Bootstrap(initApp InitApp, serviceName, version *string) {
if serviceName != nil && len(*serviceName) != 0 {
Service.Name = *serviceName
}
if version != nil && len(*version) != 0 {
Service.Version = *version
}
// bootstrap
cfg, ll, reg := DoBootstrap(Service)
// init app
app, cleanup, err := initApp(ll, reg, cfg)
if err != nil {
panic(err)
}
defer cleanup()
// run the app.
if err = app.Run(); err != nil {
panic(err)
}
}

View File

@@ -0,0 +1,57 @@
package bootstrap
import (
"testing"
"github.com/go-kratos/kratos/v2"
"github.com/go-kratos/kratos/v2/log"
"github.com/go-kratos/kratos/v2/registry"
v1 "github.com/tx7do/kratos-bootstrap/api/gen/go/conf/v1"
"github.com/tx7do/kratos-bootstrap/config"
)
func initApp(logger log.Logger, registrar registry.Registrar, _ *v1.Bootstrap) (*kratos.App, func(), error) {
app := NewApp(logger, registrar)
return app, func() {
}, nil
}
func TestBootstrap(t *testing.T) {
serviceName := "test"
version := "v0.0.1"
Bootstrap(initApp, &serviceName, &version)
}
type CustomConfig struct {
Cfg string `protobuf:"bytes,1,opt,name=cfg,proto3" json:"cfg,omitempty"`
}
func initAppEx(logger log.Logger, registrar registry.Registrar, _ *v1.Bootstrap, _ *CustomConfig) (*kratos.App, func(), error) {
app := NewApp(logger, registrar)
return app, func() {
}, nil
}
func TestCustomBootstrap(t *testing.T) {
customCfg := &CustomConfig{}
config.RegisterConfig(customCfg)
Service.SetName("test")
Service.SetVersion("v0.0.1")
// bootstrap
cfg, ll, reg := DoBootstrap(Service)
// init app
app, cleanup, err := initAppEx(ll, reg, cfg, customCfg)
if err != nil {
panic(err)
}
defer cleanup()
// run the app.
if err = app.Run(); err != nil {
panic(err)
}
}

179
bootstrap/go.mod Normal file
View File

@@ -0,0 +1,179 @@
module github.com/tx7do/kratos-bootstrap/bootstrap
go 1.23
toolchain go1.23.3
replace (
github.com/armon/go-metrics => github.com/hashicorp/go-metrics v0.4.1
github.com/imdario/mergo => dario.cat/mergo v0.3.16
github.com/tx7do/kratos-bootstrap/api => ../api
github.com/tx7do/kratos-bootstrap/config => ../config
github.com/tx7do/kratos-bootstrap/logger => ../logger
github.com/tx7do/kratos-bootstrap/registry => ../registry
github.com/tx7do/kratos-bootstrap/tracer => ../tracer
github.com/tx7do/kratos-bootstrap/utils => ../utils
)
require (
github.com/go-kratos/kratos/v2 v2.8.2
github.com/google/subcommands v1.2.0
github.com/olekukonko/tablewriter v0.0.5
github.com/spf13/cobra v1.8.1
github.com/tx7do/kratos-bootstrap/api v0.0.7
github.com/tx7do/kratos-bootstrap/config v0.0.7
github.com/tx7do/kratos-bootstrap/logger v0.0.7
github.com/tx7do/kratos-bootstrap/registry v0.0.7
github.com/tx7do/kratos-bootstrap/tracer v0.0.5
github.com/tx7do/kratos-bootstrap/utils v0.1.0
golang.org/x/tools v0.27.0
)
require (
dario.cat/mergo v1.0.1 // indirect
github.com/aliyun/alibaba-cloud-sdk-go v1.63.51 // indirect
github.com/apolloconfig/agollo/v4 v4.4.0 // indirect
github.com/armon/go-metrics v0.5.3 // indirect
github.com/buger/jsonparser v1.1.1 // indirect
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
github.com/coreos/go-semver v0.3.1 // indirect
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/deckarep/golang-set v1.8.0 // indirect
github.com/emicklei/go-restful/v3 v3.12.1 // indirect
github.com/fatih/color v1.18.0 // indirect
github.com/fluent/fluent-logger-golang v1.9.0 // indirect
github.com/fsnotify/fsnotify v1.8.0 // indirect
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
github.com/go-chassis/cari v0.9.0 // indirect
github.com/go-chassis/foundation v0.4.0 // indirect
github.com/go-chassis/openlog v1.1.3 // indirect
github.com/go-chassis/sc-client v0.7.0 // indirect
github.com/go-errors/errors v1.5.1 // indirect
github.com/go-kratos/aegis v0.2.0 // indirect
github.com/go-kratos/kratos/contrib/config/apollo/v2 v2.0.0-20241105072421-f8b97f675b32 // indirect
github.com/go-kratos/kratos/contrib/config/etcd/v2 v2.0.0-20241105072421-f8b97f675b32 // indirect
github.com/go-kratos/kratos/contrib/config/kubernetes/v2 v2.0.0-20241105072421-f8b97f675b32 // indirect
github.com/go-kratos/kratos/contrib/config/nacos/v2 v2.0.0-20241105072421-f8b97f675b32 // indirect
github.com/go-kratos/kratos/contrib/log/fluent/v2 v2.0.0-20241105072421-f8b97f675b32 // indirect
github.com/go-kratos/kratos/contrib/log/logrus/v2 v2.0.0-20241105072421-f8b97f675b32 // indirect
github.com/go-kratos/kratos/contrib/log/tencent/v2 v2.0.0-20241105072421-f8b97f675b32 // indirect
github.com/go-kratos/kratos/contrib/log/zap/v2 v2.0.0-20241105072421-f8b97f675b32 // indirect
github.com/go-kratos/kratos/contrib/registry/consul/v2 v2.0.0-20241105072421-f8b97f675b32 // indirect
github.com/go-kratos/kratos/contrib/registry/etcd/v2 v2.0.0-20241105072421-f8b97f675b32 // indirect
github.com/go-kratos/kratos/contrib/registry/eureka/v2 v2.0.0-20241105072421-f8b97f675b32 // indirect
github.com/go-kratos/kratos/contrib/registry/kubernetes/v2 v2.0.0-20241105072421-f8b97f675b32 // indirect
github.com/go-kratos/kratos/contrib/registry/nacos/v2 v2.0.0-20241105072421-f8b97f675b32 // indirect
github.com/go-kratos/kratos/contrib/registry/servicecomb/v2 v2.0.0-20241105072421-f8b97f675b32 // indirect
github.com/go-kratos/kratos/contrib/registry/zookeeper/v2 v2.0.0-20241105072421-f8b97f675b32 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-openapi/jsonpointer v0.21.0 // indirect
github.com/go-openapi/jsonreference v0.21.0 // indirect
github.com/go-openapi/swag v0.23.0 // indirect
github.com/go-playground/form/v4 v4.2.1 // indirect
github.com/go-zookeeper/zk v1.0.4 // indirect
github.com/gofrs/uuid v4.4.0+incompatible // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/mock v1.6.0 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/gnostic-models v0.6.9-0.20230804172637-c7be7c783f49 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/gorilla/mux v1.8.1 // indirect
github.com/gorilla/websocket v1.5.3 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.23.0 // indirect
github.com/hashicorp/consul/api v1.30.0 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-hclog v1.6.3 // indirect
github.com/hashicorp/go-immutable-radix v1.3.1 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/go-rootcerts v1.0.2 // indirect
github.com/hashicorp/golang-lru v1.0.2 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/hashicorp/serf v0.10.1 // indirect
github.com/imdario/mergo v1.0.1 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/karlseguin/ccache/v2 v2.0.8 // indirect
github.com/klauspost/compress v1.17.11 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-runewidth v0.0.16 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/nacos-group/nacos-sdk-go v1.1.5 // indirect
github.com/opentracing/opentracing-go v1.2.1-0.20220228012449-10b1cf09e00b // indirect
github.com/openzipkin/zipkin-go v0.4.3 // indirect
github.com/patrickmn/go-cache v2.1.0+incompatible // indirect
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
github.com/philhofer/fwd v1.1.3-0.20240916144458-20a13a1f6b7c // indirect
github.com/pierrec/lz4 v2.6.1+incompatible // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/sagikazarmark/locafero v0.6.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/afero v1.11.0 // indirect
github.com/spf13/cast v1.7.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/viper v1.19.0 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/tencentcloud/tencentcloud-cls-sdk-go v1.0.11 // indirect
github.com/tinylib/msgp v1.2.4 // indirect
github.com/x448/float16 v0.8.4 // indirect
go.etcd.io/etcd/api/v3 v3.5.17 // indirect
go.etcd.io/etcd/client/pkg/v3 v3.5.17 // indirect
go.etcd.io/etcd/client/v3 v3.5.17 // indirect
go.opentelemetry.io/otel v1.32.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.32.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.32.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.32.0 // indirect
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.32.0 // indirect
go.opentelemetry.io/otel/exporters/zipkin v1.32.0 // indirect
go.opentelemetry.io/otel/metric v1.32.0 // indirect
go.opentelemetry.io/otel/sdk v1.32.0 // indirect
go.opentelemetry.io/otel/trace v1.32.0 // indirect
go.opentelemetry.io/proto/otlp v1.3.1 // indirect
go.uber.org/atomic v1.11.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.0 // indirect
golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f // indirect
golang.org/x/mod v0.22.0 // indirect
golang.org/x/net v0.31.0 // indirect
golang.org/x/oauth2 v0.24.0 // indirect
golang.org/x/sync v0.9.0 // indirect
golang.org/x/sys v0.27.0 // indirect
golang.org/x/term v0.26.0 // indirect
golang.org/x/text v0.20.0 // indirect
golang.org/x/time v0.8.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20241113202542-65e8d215514f // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20241113202542-65e8d215514f // indirect
google.golang.org/grpc v1.68.0 // indirect
google.golang.org/protobuf v1.35.1 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/api v0.31.2 // indirect
k8s.io/apimachinery v0.31.2 // indirect
k8s.io/client-go v0.31.2 // indirect
k8s.io/klog/v2 v2.130.1 // indirect
k8s.io/kube-openapi v0.0.0-20241105132330-32ad38e42d3f // indirect
k8s.io/utils v0.0.0-20241104163129-6fe5fd82f078 // indirect
sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.3 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
)

1067
bootstrap/go.sum Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,2 +0,0 @@
# Generated by buf. DO NOT EDIT.
version: v1

View File

@@ -1,9 +0,0 @@
version: v1
breaking:
use:
- FILE
lint:
use:
- DEFAULT

26
cache/redis/go.mod vendored Normal file
View File

@@ -0,0 +1,26 @@
module github.com/tx7do/kratos-bootstrap/cache/redis
go 1.22.0
toolchain go1.22.1
replace github.com/tx7do/kratos-bootstrap/api => ../../api
require (
github.com/go-kratos/kratos/v2 v2.8.2
github.com/redis/go-redis/extra/redisotel/v9 v9.7.0
github.com/redis/go-redis/v9 v9.7.0
github.com/tx7do/kratos-bootstrap/api v0.0.5
)
require (
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/redis/go-redis/extra/rediscmd/v9 v9.7.0 // indirect
go.opentelemetry.io/otel v1.32.0 // indirect
go.opentelemetry.io/otel/metric v1.32.0 // indirect
go.opentelemetry.io/otel/trace v1.32.0 // indirect
google.golang.org/protobuf v1.35.1 // indirect
)

45
cache/redis/go.sum vendored Normal file
View File

@@ -0,0 +1,45 @@
github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs=
github.com/bsm/ginkgo/v2 v2.12.0/go.mod h1:SwYbGRRDovPVboqFv0tPTcG1sN61LM1Z4ARdbAV9g4c=
github.com/bsm/gomega v1.27.10 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA=
github.com/bsm/gomega v1.27.10/go.mod h1:JyEr/xRbxbtgWNi8tIEVPUYZ5Dzef52k01W3YH0H+O0=
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
github.com/go-kratos/kratos/v2 v2.8.2 h1:EsEA7AmPQ2YQQ0FZrDWO2HgBNqeWM8z/mWKzS5UkQaQ=
github.com/go-kratos/kratos/v2 v2.8.2/go.mod h1:+Vfe3FzF0d+BfMdajA11jT0rAyJWublRE/seZQNZVxE=
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/redis/go-redis/extra/rediscmd/v9 v9.7.0 h1:BIx9TNZH/Jsr4l1i7VVxnV0JPiwYj8qyrHyuL0fGZrk=
github.com/redis/go-redis/extra/rediscmd/v9 v9.7.0/go.mod h1:eTg/YQtGYAZD5r3DlGlJptJ45AHA+/G+2NPn30PKzik=
github.com/redis/go-redis/extra/redisotel/v9 v9.7.0 h1:bQk8xiVFw+3ln4pfELVktpWgYdFpgLLU+quwSoeIof0=
github.com/redis/go-redis/extra/redisotel/v9 v9.7.0/go.mod h1:0LyN+GHLIJmKtjYRPF7nHyTTMV6E91YngoOopNifQRo=
github.com/redis/go-redis/v9 v9.7.0 h1:HhLSs+B6O021gwzl+locl0zEDnyNkxMtf/Z3NNBMa9E=
github.com/redis/go-redis/v9 v9.7.0/go.mod h1:f6zhXITC7JUJIlPEiBOTXxJgPLdZcA93GewI7inzyWw=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
go.opentelemetry.io/otel v1.32.0 h1:WnBN+Xjcteh0zdk01SVqV55d/m62NJLJdIyb4y/WO5U=
go.opentelemetry.io/otel v1.32.0/go.mod h1:00DCVSB0RQcnzlwyTfqtxSm+DRr9hpYrHjNGiBHVQIg=
go.opentelemetry.io/otel/metric v1.32.0 h1:xV2umtmNcThh2/a/aCP+h64Xx5wsj8qqnkYZktzNa0M=
go.opentelemetry.io/otel/metric v1.32.0/go.mod h1:jH7CIbbK6SH2V2wE16W05BHCtIDzauciCRLoc/SyMv8=
go.opentelemetry.io/otel/sdk v1.24.0 h1:YMPPDNymmQN3ZgczicBY3B6sf9n62Dlj9pWD3ucgoDw=
go.opentelemetry.io/otel/sdk v1.24.0/go.mod h1:KVrIYw6tEubO9E96HQpcmpTKDVn9gdv35HoYiQWGDFg=
go.opentelemetry.io/otel/trace v1.32.0 h1:WIC9mYrXf8TmY/EXuULKc8hR17vE+Hjv2cssQDe03fM=
go.opentelemetry.io/otel/trace v1.32.0/go.mod h1:+i4rkvCraA+tG6AzwloGaCtkx53Fa+L+V8e9a7YvhT8=
golang.org/x/sync v0.5.0 h1:60k92dhOjHxJkrqnwsfl8KuaHbn/5dl0lUPUklKo3qE=
golang.org/x/sync v0.5.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4=
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA=
google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

43
cache/redis/redis.go vendored Normal file
View File

@@ -0,0 +1,43 @@
package redis
import (
"github.com/go-kratos/kratos/v2/log"
"github.com/redis/go-redis/extra/redisotel/v9"
"github.com/redis/go-redis/v9"
conf "github.com/tx7do/kratos-bootstrap/api/gen/go/conf/v1"
)
// NewClient create go-redis client
func NewClient(conf *conf.Data) (rdb *redis.Client) {
if rdb = redis.NewClient(&redis.Options{
Addr: conf.GetRedis().GetAddr(),
Password: conf.GetRedis().GetPassword(),
DB: int(conf.GetRedis().GetDb()),
DialTimeout: conf.GetRedis().GetDialTimeout().AsDuration(),
WriteTimeout: conf.GetRedis().GetWriteTimeout().AsDuration(),
ReadTimeout: conf.GetRedis().GetReadTimeout().AsDuration(),
}); rdb == nil {
log.Fatalf("failed opening connection to redis")
return nil
}
// open tracing instrumentation.
if conf.GetRedis().GetEnableTracing() {
if err := redisotel.InstrumentTracing(rdb); err != nil {
log.Fatalf("failed open tracing: %s", err.Error())
panic(err)
}
}
// open metrics instrumentation.
if conf.GetRedis().GetEnableMetrics() {
if err := redisotel.InstrumentMetrics(rdb); err != nil {
log.Fatalf("failed open metrics: %s", err.Error())
panic(err)
}
}
return rdb
}

358
config.go
View File

@@ -1,358 +0,0 @@
package bootstrap
import (
"os"
"path/filepath"
"strings"
"google.golang.org/grpc"
"github.com/go-kratos/kratos/v2/config"
"github.com/go-kratos/kratos/v2/log"
// file
fileKratos "github.com/go-kratos/kratos/v2/config/file"
// etcd
etcdKratos "github.com/go-kratos/kratos/contrib/config/etcd/v2"
etcdClient "go.etcd.io/etcd/client/v3"
// consul
consulKratos "github.com/go-kratos/kratos/contrib/config/consul/v2"
consulApi "github.com/hashicorp/consul/api"
// nacos
nacosKratos "github.com/go-kratos/kratos/contrib/config/nacos/v2"
nacosClients "github.com/nacos-group/nacos-sdk-go/clients"
nacosConstant "github.com/nacos-group/nacos-sdk-go/common/constant"
nacosVo "github.com/nacos-group/nacos-sdk-go/vo"
// apollo
apolloKratos "github.com/go-kratos/kratos/contrib/config/apollo/v2"
// kubernetes
k8sKratos "github.com/go-kratos/kratos/contrib/config/kubernetes/v2"
k8sUtil "k8s.io/client-go/util/homedir"
conf "github.com/tx7do/kratos-bootstrap/gen/api/go/conf/v1"
)
var commonConfig = &conf.Bootstrap{}
var configList []interface{}
const remoteConfigSourceConfigFile = "remote.yaml"
// RegisterConfig 注册配置
func RegisterConfig(c interface{}) {
initBootstrapConfig()
configList = append(configList, c)
}
func initBootstrapConfig() {
if len(configList) > 0 {
return
}
configList = append(configList, commonConfig)
if commonConfig.Server == nil {
commonConfig.Server = &conf.Server{}
configList = append(configList, commonConfig.Server)
}
if commonConfig.Client == nil {
commonConfig.Client = &conf.Client{}
configList = append(configList, commonConfig.Client)
}
if commonConfig.Data == nil {
commonConfig.Data = &conf.Data{}
configList = append(configList, commonConfig.Data)
}
if commonConfig.Trace == nil {
commonConfig.Trace = &conf.Tracer{}
configList = append(configList, commonConfig.Trace)
}
if commonConfig.Logger == nil {
commonConfig.Logger = &conf.Logger{}
configList = append(configList, commonConfig.Logger)
}
if commonConfig.Registry == nil {
commonConfig.Registry = &conf.Registry{}
configList = append(configList, commonConfig.Registry)
}
if commonConfig.Oss == nil {
commonConfig.Oss = &conf.OSS{}
configList = append(configList, commonConfig.Oss)
}
if commonConfig.Notify == nil {
commonConfig.Notify = &conf.Notification{}
configList = append(configList, commonConfig.Notify)
}
}
// NewConfigProvider 创建一个配置
func NewConfigProvider(configPath string) config.Config {
err, rc := LoadRemoteConfigSourceConfigs(configPath)
if err != nil {
log.Error("LoadRemoteConfigSourceConfigs: ", err.Error())
}
if rc != nil {
return config.New(
config.WithSource(
NewFileConfigSource(configPath),
NewRemoteConfigSource(rc),
),
)
} else {
return config.New(
config.WithSource(
NewFileConfigSource(configPath),
),
)
}
}
// LoadBootstrapConfig 加载程序引导配置
func LoadBootstrapConfig(configPath string) error {
cfg := NewConfigProvider(configPath)
var err error
if err = cfg.Load(); err != nil {
return err
}
initBootstrapConfig()
if err = scanConfigs(cfg); err != nil {
return err
}
return nil
}
func scanConfigs(cfg config.Config) error {
initBootstrapConfig()
for _, c := range configList {
if err := cfg.Scan(c); err != nil {
return err
}
}
return nil
}
func pathExists(path string) bool {
_, err := os.Stat(path)
if err == nil {
return true
}
if os.IsNotExist(err) {
return false
}
return false
}
// LoadRemoteConfigSourceConfigs 加载远程配置源的本地配置
func LoadRemoteConfigSourceConfigs(configPath string) (error, *conf.RemoteConfig) {
configPath = configPath + "/" + remoteConfigSourceConfigFile
if !pathExists(configPath) {
return nil, nil
}
cfg := config.New(
config.WithSource(
NewFileConfigSource(configPath),
),
)
defer func(cfg config.Config) {
if err := cfg.Close(); err != nil {
panic(err)
}
}(cfg)
var err error
if err = cfg.Load(); err != nil {
return err, nil
}
if err = scanConfigs(cfg); err != nil {
return err, nil
}
return nil, commonConfig.Config
}
type ConfigType string
const (
ConfigTypeLocalFile ConfigType = "file"
ConfigTypeNacos ConfigType = "nacos"
ConfigTypeConsul ConfigType = "consul"
ConfigTypeEtcd ConfigType = "etcd"
ConfigTypeApollo ConfigType = "apollo"
ConfigTypeKubernetes ConfigType = "kubernetes"
ConfigTypePolaris ConfigType = "polaris"
)
// NewRemoteConfigSource 创建一个远程配置源
func NewRemoteConfigSource(c *conf.RemoteConfig) config.Source {
switch ConfigType(c.Type) {
default:
fallthrough
case ConfigTypeLocalFile:
return nil
case ConfigTypeNacos:
return NewNacosConfigSource(c)
case ConfigTypeConsul:
return NewConsulConfigSource(c)
case ConfigTypeEtcd:
return NewEtcdConfigSource(c)
case ConfigTypeApollo:
return NewApolloConfigSource(c)
case ConfigTypeKubernetes:
return NewKubernetesConfigSource(c)
case ConfigTypePolaris:
return NewPolarisConfigSource(c)
}
}
// getConfigKey 获取合法的配置名
func getConfigKey(configKey string, useBackslash bool) string {
if useBackslash {
return strings.Replace(configKey, `.`, `/`, -1)
} else {
return configKey
}
}
// NewFileConfigSource 创建一个本地文件配置源
func NewFileConfigSource(filePath string) config.Source {
return fileKratos.NewSource(filePath)
}
// NewNacosConfigSource 创建一个远程配置源 - Nacos
func NewNacosConfigSource(c *conf.RemoteConfig) config.Source {
srvConf := []nacosConstant.ServerConfig{
*nacosConstant.NewServerConfig(c.Nacos.Address, c.Nacos.Port),
}
cliConf := nacosConstant.ClientConfig{
TimeoutMs: 10 * 1000, // http请求超时时间单位毫秒
BeatInterval: 5 * 1000, // 心跳间隔时间,单位毫秒
UpdateThreadNum: 20, // 更新服务的线程数
LogLevel: "debug",
CacheDir: "../../configs/cache", // 缓存目录
LogDir: "../../configs/log", // 日志目录
NotLoadCacheAtStart: true, // 在启动时不读取本地缓存数据true--不读取false--读取
UpdateCacheWhenEmpty: true, // 当服务列表为空时是否更新本地缓存true--更新,false--不更新
}
nacosClient, err := nacosClients.NewConfigClient(
nacosVo.NacosClientParam{
ClientConfig: &cliConf,
ServerConfigs: srvConf,
},
)
if err != nil {
log.Fatal(err)
}
return nacosKratos.NewConfigSource(nacosClient,
nacosKratos.WithGroup(getConfigKey(c.Nacos.Key, false)),
nacosKratos.WithDataID("bootstrap.yaml"),
)
}
// NewEtcdConfigSource 创建一个远程配置源 - Etcd
func NewEtcdConfigSource(c *conf.RemoteConfig) config.Source {
cfg := etcdClient.Config{
Endpoints: c.Etcd.Endpoints,
DialTimeout: c.Etcd.Timeout.AsDuration(),
DialOptions: []grpc.DialOption{grpc.WithBlock()},
}
cli, err := etcdClient.New(cfg)
if err != nil {
panic(err)
}
source, err := etcdKratos.New(cli, etcdKratos.WithPath(getConfigKey(c.Etcd.Key, true)))
if err != nil {
log.Fatal(err)
}
return source
}
// NewConsulConfigSource 创建一个远程配置源 - Consul
func NewConsulConfigSource(c *conf.RemoteConfig) config.Source {
cfg := consulApi.DefaultConfig()
cfg.Address = c.Consul.Address
cfg.Scheme = c.Consul.Scheme
cli, err := consulApi.NewClient(cfg)
if err != nil {
log.Fatal(err)
}
source, err := consulKratos.New(cli,
consulKratos.WithPath(getConfigKey(c.Consul.Key, true)),
)
if err != nil {
log.Fatal(err)
}
return source
}
// NewApolloConfigSource 创建一个远程配置源 - Apollo
func NewApolloConfigSource(c *conf.RemoteConfig) config.Source {
source := apolloKratos.NewSource(
apolloKratos.WithAppID(c.Apollo.AppId),
apolloKratos.WithCluster(c.Apollo.Cluster),
apolloKratos.WithEndpoint(c.Apollo.Endpoint),
apolloKratos.WithNamespace(c.Apollo.Namespace),
apolloKratos.WithSecret(c.Apollo.Secret),
apolloKratos.WithEnableBackup(),
)
return source
}
// NewKubernetesConfigSource 创建一个远程配置源 - Kubernetes
func NewKubernetesConfigSource(c *conf.RemoteConfig) config.Source {
source := k8sKratos.NewSource(
k8sKratos.Namespace(c.Kubernetes.Namespace),
k8sKratos.LabelSelector(""),
k8sKratos.KubeConfig(filepath.Join(k8sUtil.HomeDir(), ".kube", "config")),
)
return source
}
// NewPolarisConfigSource 创建一个远程配置源 - Polaris
func NewPolarisConfigSource(_ *conf.RemoteConfig) config.Source {
//configApi, err := polarisApi.NewConfigAPI()
//if err != nil {
// log.Fatal(err)
//}
//
//var opts []polarisKratos.Option
//opts = append(opts, polarisKratos.WithNamespace("default"))
//opts = append(opts, polarisKratos.WithFileGroup("default"))
//opts = append(opts, polarisKratos.WithFileName("default.yaml"))
//
//source, err := polarisKratos.New(configApi, opts...)
//if err != nil {
// log.Fatal(err)
//}
//
//return source
return nil
}

25
config/apollo/client.go Normal file
View File

@@ -0,0 +1,25 @@
package apollo
import (
apolloKratos "github.com/go-kratos/kratos/contrib/config/apollo/v2"
"github.com/go-kratos/kratos/v2/config"
conf "github.com/tx7do/kratos-bootstrap/api/gen/go/conf/v1"
)
// NewConfigSource 创建一个远程配置源 - Apollo
func NewConfigSource(cfg *conf.RemoteConfig) config.Source {
if cfg == nil || cfg.Apollo == nil {
return nil
}
source := apolloKratos.NewSource(
apolloKratos.WithAppID(cfg.Apollo.AppId),
apolloKratos.WithCluster(cfg.Apollo.Cluster),
apolloKratos.WithEndpoint(cfg.Apollo.Endpoint),
apolloKratos.WithNamespace(cfg.Apollo.Namespace),
apolloKratos.WithSecret(cfg.Apollo.Secret),
apolloKratos.WithEnableBackup(),
)
return source
}

View File

@@ -0,0 +1,65 @@
package config
import conf "github.com/tx7do/kratos-bootstrap/api/gen/go/conf/v1"
var configList []interface{}
var commonConfig = &conf.Bootstrap{}
func GetBootstrapConfig() *conf.Bootstrap {
return commonConfig
}
// RegisterConfig 注册配置
func RegisterConfig(c interface{}) {
initBootstrapConfig()
configList = append(configList, c)
}
func initBootstrapConfig() {
if len(configList) > 0 {
return
}
configList = append(configList, commonConfig)
if commonConfig.Server == nil {
commonConfig.Server = &conf.Server{}
configList = append(configList, commonConfig.Server)
}
if commonConfig.Client == nil {
commonConfig.Client = &conf.Client{}
configList = append(configList, commonConfig.Client)
}
if commonConfig.Data == nil {
commonConfig.Data = &conf.Data{}
configList = append(configList, commonConfig.Data)
}
if commonConfig.Trace == nil {
commonConfig.Trace = &conf.Tracer{}
configList = append(configList, commonConfig.Trace)
}
if commonConfig.Logger == nil {
commonConfig.Logger = &conf.Logger{}
configList = append(configList, commonConfig.Logger)
}
if commonConfig.Registry == nil {
commonConfig.Registry = &conf.Registry{}
configList = append(configList, commonConfig.Registry)
}
if commonConfig.Oss == nil {
commonConfig.Oss = &conf.OSS{}
configList = append(configList, commonConfig.Oss)
}
if commonConfig.Notify == nil {
commonConfig.Notify = &conf.Notification{}
configList = append(configList, commonConfig.Notify)
}
}

127
config/config.go Normal file
View File

@@ -0,0 +1,127 @@
package config
import (
"github.com/go-kratos/kratos/v2/config"
fileKratos "github.com/go-kratos/kratos/v2/config/file"
"github.com/go-kratos/kratos/v2/log"
"github.com/tx7do/kratos-bootstrap/config/apollo"
"github.com/tx7do/kratos-bootstrap/config/consul"
"github.com/tx7do/kratos-bootstrap/config/etcd"
"github.com/tx7do/kratos-bootstrap/config/kubernetes"
"github.com/tx7do/kratos-bootstrap/config/nacos"
"github.com/tx7do/kratos-bootstrap/config/polaris"
conf "github.com/tx7do/kratos-bootstrap/api/gen/go/conf/v1"
"github.com/tx7do/kratos-bootstrap/utils"
)
// NewRemoteConfigSource 创建一个远程配置源
func NewRemoteConfigSource(c *conf.RemoteConfig) config.Source {
switch Type(c.Type) {
default:
fallthrough
case LocalFile:
return nil
case Nacos:
return nacos.NewConfigSource(c)
case Consul:
return consul.NewConfigSource(c)
case Etcd:
return etcd.NewConfigSource(c)
case Apollo:
return apollo.NewConfigSource(c)
case Kubernetes:
return kubernetes.NewConfigSource(c)
case Polaris:
return polaris.NewConfigSource(c)
}
}
// NewFileConfigSource 创建一个本地文件配置源
func NewFileConfigSource(filePath string) config.Source {
return fileKratos.NewSource(filePath)
}
// NewConfigProvider 创建一个配置
func NewConfigProvider(configPath string) config.Config {
err, rc := LoadRemoteConfigSourceConfigs(configPath)
if err != nil {
log.Error("LoadRemoteConfigSourceConfigs: ", err.Error())
}
if rc != nil {
return config.New(
config.WithSource(
NewFileConfigSource(configPath),
NewRemoteConfigSource(rc),
),
)
} else {
return config.New(
config.WithSource(
NewFileConfigSource(configPath),
),
)
}
}
// LoadBootstrapConfig 加载程序引导配置
func LoadBootstrapConfig(configPath string) error {
cfg := NewConfigProvider(configPath)
var err error
if err = cfg.Load(); err != nil {
return err
}
initBootstrapConfig()
if err = scanConfigs(cfg); err != nil {
return err
}
return nil
}
func scanConfigs(cfg config.Config) error {
initBootstrapConfig()
for _, c := range configList {
if err := cfg.Scan(c); err != nil {
return err
}
}
return nil
}
// LoadRemoteConfigSourceConfigs 加载远程配置源的本地配置
func LoadRemoteConfigSourceConfigs(configPath string) (error, *conf.RemoteConfig) {
configPath = configPath + "/" + remoteConfigSourceConfigFile
if !utils.PathExists(configPath) {
return nil, nil
}
cfg := config.New(
config.WithSource(
NewFileConfigSource(configPath),
),
)
defer func(cfg config.Config) {
if err := cfg.Close(); err != nil {
panic(err)
}
}(cfg)
var err error
if err = cfg.Load(); err != nil {
return err, nil
}
if err = scanConfigs(cfg); err != nil {
return err, nil
}
return nil, GetBootstrapConfig().Config
}

10
config/config_test.go Normal file
View File

@@ -0,0 +1,10 @@
package config
import "testing"
func TestRegisterConfig(t *testing.T) {
var cfg struct {
Test string
}
RegisterConfig(&cfg)
}

46
config/consul/client.go Normal file
View File

@@ -0,0 +1,46 @@
package consul
import (
"strings"
"github.com/go-kratos/kratos/v2/config"
"github.com/go-kratos/kratos/v2/log"
consulApi "github.com/hashicorp/consul/api"
conf "github.com/tx7do/kratos-bootstrap/api/gen/go/conf/v1"
)
// getConfigKey 获取合法的配置名
func getConfigKey(configKey string, useBackslash bool) string {
if useBackslash {
return strings.Replace(configKey, `.`, `/`, -1)
} else {
return configKey
}
}
// NewConfigSource 创建一个远程配置源 - Consul
func NewConfigSource(c *conf.RemoteConfig) config.Source {
if c == nil || c.Consul == nil {
return nil
}
cfg := consulApi.DefaultConfig()
cfg.Address = c.Consul.Address
cfg.Scheme = c.Consul.Scheme
cli, err := consulApi.NewClient(cfg)
if err != nil {
log.Fatal(err)
}
src, err := New(cli,
WithPath(getConfigKey(c.Consul.Key, true)),
)
if err != nil {
log.Fatal(err)
}
return src
}

89
config/consul/config.go Normal file
View File

@@ -0,0 +1,89 @@
package consul
import (
"context"
"errors"
"path/filepath"
"strings"
"github.com/go-kratos/kratos/v2/config"
"github.com/hashicorp/consul/api"
)
// Option is consul config option.
type Option func(o *options)
type options struct {
ctx context.Context
path string
}
// WithContext with registry context.
func WithContext(ctx context.Context) Option {
return func(o *options) {
o.ctx = ctx
}
}
// WithPath is config path
func WithPath(p string) Option {
return func(o *options) {
o.path = p
}
}
type source struct {
client *api.Client
options *options
}
func New(client *api.Client, opts ...Option) (config.Source, error) {
o := &options{
ctx: context.Background(),
path: "",
}
for _, opt := range opts {
opt(o)
}
if o.path == "" {
return nil, errors.New("path invalid")
}
return &source{
client: client,
options: o,
}, nil
}
// Load return the config values
func (s *source) Load() ([]*config.KeyValue, error) {
kv, _, err := s.client.KV().List(s.options.path, nil)
if err != nil {
return nil, err
}
pathPrefix := s.options.path
if !strings.HasSuffix(s.options.path, "/") {
pathPrefix = pathPrefix + "/"
}
kvs := make([]*config.KeyValue, 0)
for _, item := range kv {
k := strings.TrimPrefix(item.Key, pathPrefix)
if k == "" {
continue
}
kvs = append(kvs, &config.KeyValue{
Key: k,
Value: item.Value,
Format: strings.TrimPrefix(filepath.Ext(k), "."),
})
}
return kvs, nil
}
// Watch return the watcher
func (s *source) Watch() (config.Watcher, error) {
return newWatcher(s)
}

103
config/consul/watcher.go Normal file
View File

@@ -0,0 +1,103 @@
package consul
import (
"context"
"path/filepath"
"strings"
"github.com/hashicorp/consul/api"
"github.com/hashicorp/consul/api/watch"
"github.com/go-kratos/kratos/v2/config"
)
type watcher struct {
source *source
ch chan []*config.KeyValue
wp *watch.Plan
fileModifyIndex map[string]uint64
ctx context.Context
cancel context.CancelFunc
}
func (w *watcher) handle(_ uint64, data interface{}) {
if data == nil {
return
}
kv, ok := data.(api.KVPairs)
if !ok {
return
}
pathPrefix := w.source.options.path
if !strings.HasSuffix(w.source.options.path, "/") {
pathPrefix = pathPrefix + "/"
}
kvs := make([]*config.KeyValue, 0, len(kv))
for _, item := range kv {
if index, ok := w.fileModifyIndex[item.Key]; ok && item.ModifyIndex == index {
continue
}
k := strings.TrimPrefix(item.Key, pathPrefix)
if k == "" {
continue
}
kvs = append(kvs, &config.KeyValue{
Key: k,
Value: item.Value,
Format: strings.TrimPrefix(filepath.Ext(k), "."),
})
w.fileModifyIndex[item.Key] = item.ModifyIndex
}
if len(kvs) == 0 {
return
}
w.ch <- kvs
}
func newWatcher(s *source) (*watcher, error) {
ctx, cancel := context.WithCancel(context.Background())
w := &watcher{
source: s,
ch: make(chan []*config.KeyValue),
fileModifyIndex: make(map[string]uint64),
ctx: ctx,
cancel: cancel,
}
wp, err := watch.Parse(map[string]interface{}{"type": "keyprefix", "prefix": s.options.path})
if err != nil {
return nil, err
}
wp.Handler = w.handle
w.wp = wp
// wp.Run is a blocking call and will prevent newWatcher from returning
go func() {
err := wp.RunWithClientAndHclog(s.client, nil)
if err != nil {
panic(err)
}
}()
return w, nil
}
func (w *watcher) Next() ([]*config.KeyValue, error) {
select {
case kv := <-w.ch:
return kv, nil
case <-w.ctx.Done():
return nil, w.ctx.Err()
}
}
func (w *watcher) Stop() error {
w.wp.Stop()
w.cancel()
return nil
}

49
config/etcd/client.go Normal file
View File

@@ -0,0 +1,49 @@
package etcd
import (
"strings"
"github.com/go-kratos/kratos/v2/config"
"github.com/go-kratos/kratos/v2/log"
"google.golang.org/grpc"
etcdKratos "github.com/go-kratos/kratos/contrib/config/etcd/v2"
etcdClient "go.etcd.io/etcd/client/v3"
conf "github.com/tx7do/kratos-bootstrap/api/gen/go/conf/v1"
)
// getConfigKey 获取合法的配置名
func getConfigKey(configKey string, useBackslash bool) string {
if useBackslash {
return strings.Replace(configKey, `.`, `/`, -1)
} else {
return configKey
}
}
// NewConfigSource 创建一个远程配置源 - Etcd
func NewConfigSource(c *conf.RemoteConfig) config.Source {
if c == nil || c.Etcd == nil {
return nil
}
cfg := etcdClient.Config{
Endpoints: c.Etcd.Endpoints,
DialTimeout: c.Etcd.Timeout.AsDuration(),
DialOptions: []grpc.DialOption{grpc.WithBlock()},
}
cli, err := etcdClient.New(cfg)
if err != nil {
panic(err)
}
source, err := etcdKratos.New(cli, etcdKratos.WithPath(getConfigKey(c.Etcd.Key, true)))
if err != nil {
log.Fatal(err)
}
return source
}

View File

@@ -1,7 +1,12 @@
package bootstrap
package config
import "flag"
import (
"flag"
"github.com/tx7do/kratos-bootstrap/utils"
)
// CommandFlags 命令传参
type CommandFlags struct {
Conf string // 引导配置文件路径,默认为:../../configs
Env string // 开发环境dev、debug……
@@ -11,25 +16,31 @@ type CommandFlags struct {
}
func NewCommandFlags() *CommandFlags {
return &CommandFlags{
f := &CommandFlags{
Conf: "",
Env: "",
ConfigHost: "",
ConfigType: "",
Daemon: false,
}
f.defineFlag()
return f
}
func (f *CommandFlags) Init() {
func (f *CommandFlags) defineFlag() {
flag.StringVar(&f.Conf, "conf", "../../configs", "config path, eg: -conf ../../configs")
flag.StringVar(&f.Env, "env", "dev", "runtime environment, eg: -env dev")
flag.StringVar(&f.ConfigHost, "chost", "127.0.0.1:8500", "config server host, eg: -chost 127.0.0.1:8500")
flag.StringVar(&f.ConfigType, "ctype", "consul", "config server host, eg: -ctype consul")
flag.BoolVar(&f.Daemon, "d", false, "run app as a daemon with -d=true.")
}
func (f *CommandFlags) Init() {
flag.Parse()
if f.Daemon {
BeDaemon("-d")
utils.BeDaemon("-d")
}
flag.Parse()
}

133
config/go.mod Normal file
View File

@@ -0,0 +1,133 @@
module github.com/tx7do/kratos-bootstrap/config
go 1.23
toolchain go1.23.2
replace (
github.com/armon/go-metrics => github.com/hashicorp/go-metrics v0.4.1
github.com/imdario/mergo => dario.cat/mergo v0.3.16
github.com/tx7do/kratos-bootstrap/api => ../api
github.com/tx7do/kratos-bootstrap/utils => ../utils
)
require (
github.com/go-kratos/kratos/contrib/config/apollo/v2 v2.0.0-20241105072421-f8b97f675b32
github.com/go-kratos/kratos/contrib/config/etcd/v2 v2.0.0-20241105072421-f8b97f675b32
github.com/go-kratos/kratos/contrib/config/kubernetes/v2 v2.0.0-20241105072421-f8b97f675b32
github.com/go-kratos/kratos/contrib/config/nacos/v2 v2.0.0-20241105072421-f8b97f675b32
github.com/go-kratos/kratos/contrib/config/polaris/v2 v2.0.0-20241105072421-f8b97f675b32
github.com/go-kratos/kratos/v2 v2.8.2
github.com/hashicorp/consul/api v1.30.0
github.com/nacos-group/nacos-sdk-go v1.1.5
github.com/polarismesh/polaris-go v1.5.8
github.com/tx7do/kratos-bootstrap/api v0.0.7
go.etcd.io/etcd/client/v3 v3.5.17
google.golang.org/grpc v1.68.0
k8s.io/client-go v0.31.2
)
require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/dlclark/regexp2 v1.11.4 // indirect
github.com/klauspost/compress v1.17.11 // indirect
github.com/natefinch/lumberjack v2.0.0+incompatible // indirect
github.com/opentracing/opentracing-go v1.2.1-0.20220228012449-10b1cf09e00b // indirect
github.com/polarismesh/specification v1.5.3 // indirect
github.com/prometheus/client_golang v1.20.5 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.60.1 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
github.com/sagikazarmark/locafero v0.6.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spaolacci/murmur3 v1.1.0 // indirect
)
require (
dario.cat/mergo v1.0.1 // indirect
github.com/aliyun/alibaba-cloud-sdk-go v1.63.51 // indirect
github.com/apolloconfig/agollo/v4 v4.4.0 // indirect
github.com/armon/go-metrics v0.5.3 // indirect
github.com/buger/jsonparser v1.1.1 // indirect
github.com/coreos/go-semver v0.3.1 // indirect
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/emicklei/go-restful/v3 v3.12.1 // indirect
github.com/fatih/color v1.18.0 // indirect
github.com/fsnotify/fsnotify v1.8.0 // indirect
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
github.com/go-errors/errors v1.5.1 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-openapi/jsonpointer v0.21.0 // indirect
github.com/go-openapi/jsonreference v0.21.0 // indirect
github.com/go-openapi/swag v0.23.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/gnostic-models v0.6.9-0.20230804172637-c7be7c783f49 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-hclog v1.6.3 // indirect
github.com/hashicorp/go-immutable-radix v1.3.1 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/go-rootcerts v1.0.2 // indirect
github.com/hashicorp/golang-lru v1.0.2 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/hashicorp/serf v0.10.1 // indirect
github.com/imdario/mergo v1.0.1 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/spf13/afero v1.11.0 // indirect
github.com/spf13/cast v1.7.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/viper v1.19.0 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/tx7do/kratos-bootstrap/utils v0.1.0
github.com/x448/float16 v0.8.4 // indirect
go.etcd.io/etcd/api/v3 v3.5.17 // indirect
go.etcd.io/etcd/client/pkg/v3 v3.5.17 // indirect
go.uber.org/atomic v1.11.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.0 // indirect
golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f // indirect
golang.org/x/net v0.31.0 // indirect
golang.org/x/oauth2 v0.24.0 // indirect
golang.org/x/sync v0.9.0 // indirect
golang.org/x/sys v0.27.0 // indirect
golang.org/x/term v0.26.0 // indirect
golang.org/x/text v0.20.0 // indirect
golang.org/x/time v0.8.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20241113202542-65e8d215514f // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20241113202542-65e8d215514f // indirect
google.golang.org/protobuf v1.35.1 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/api v0.31.2 // indirect
k8s.io/apimachinery v0.31.2 // indirect
k8s.io/klog/v2 v2.130.1 // indirect
k8s.io/kube-openapi v0.0.0-20241105132330-32ad38e42d3f // indirect
k8s.io/utils v0.0.0-20241104163129-6fe5fd82f078 // indirect
sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.3 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
)

1335
config/go.sum Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,26 @@
package kubernetes
import (
"path/filepath"
k8sKratos "github.com/go-kratos/kratos/contrib/config/kubernetes/v2"
k8sUtil "k8s.io/client-go/util/homedir"
"github.com/go-kratos/kratos/v2/config"
conf "github.com/tx7do/kratos-bootstrap/api/gen/go/conf/v1"
)
// NewConfigSource 创建一个远程配置源 - Kubernetes
func NewConfigSource(c *conf.RemoteConfig) config.Source {
if c == nil || c.Kubernetes == nil {
return nil
}
source := k8sKratos.NewSource(
k8sKratos.Namespace(c.Kubernetes.Namespace),
k8sKratos.LabelSelector(""),
k8sKratos.KubeConfig(filepath.Join(k8sUtil.HomeDir(), ".kube", "config")),
)
return source
}

61
config/nacos/client.go Normal file
View File

@@ -0,0 +1,61 @@
package nacos
import (
"strings"
"github.com/go-kratos/kratos/v2/config"
"github.com/go-kratos/kratos/v2/log"
nacosKratos "github.com/go-kratos/kratos/contrib/config/nacos/v2"
nacosClients "github.com/nacos-group/nacos-sdk-go/clients"
nacosConstant "github.com/nacos-group/nacos-sdk-go/common/constant"
nacosVo "github.com/nacos-group/nacos-sdk-go/vo"
conf "github.com/tx7do/kratos-bootstrap/api/gen/go/conf/v1"
)
// getConfigKey 获取合法的配置名
func getConfigKey(configKey string, useBackslash bool) string {
if useBackslash {
return strings.Replace(configKey, `.`, `/`, -1)
} else {
return configKey
}
}
// NewConfigSource 创建一个远程配置源 - Nacos
func NewConfigSource(c *conf.RemoteConfig) config.Source {
if c == nil || c.Nacos == nil {
return nil
}
srvConf := []nacosConstant.ServerConfig{
*nacosConstant.NewServerConfig(c.Nacos.Address, c.Nacos.Port),
}
cliConf := nacosConstant.ClientConfig{
TimeoutMs: 10 * 1000, // http请求超时时间单位毫秒
BeatInterval: 5 * 1000, // 心跳间隔时间,单位毫秒
UpdateThreadNum: 20, // 更新服务的线程数
LogLevel: "debug",
CacheDir: "../../configs/cache", // 缓存目录
LogDir: "../../configs/log", // 日志目录
NotLoadCacheAtStart: true, // 在启动时不读取本地缓存数据true--不读取false--读取
UpdateCacheWhenEmpty: true, // 当服务列表为空时是否更新本地缓存true--更新,false--不更新
}
nacosClient, err := nacosClients.NewConfigClient(
nacosVo.NacosClientParam{
ClientConfig: &cliConf,
ServerConfigs: srvConf,
},
)
if err != nil {
log.Fatal(err)
}
return nacosKratos.NewConfigSource(nacosClient,
nacosKratos.WithGroup(getConfigKey(c.Nacos.Key, false)),
nacosKratos.WithDataID("bootstrap.yaml"),
)
}

15
config/options.go Normal file
View File

@@ -0,0 +1,15 @@
package config
const remoteConfigSourceConfigFile = "remote.yaml"
type Type string
const (
LocalFile Type = "file"
Nacos Type = "nacos"
Consul Type = "consul"
Etcd Type = "etcd"
Apollo Type = "apollo"
Kubernetes Type = "kubernetes"
Polaris Type = "polaris"
)

32
config/polaris/client.go Normal file
View File

@@ -0,0 +1,32 @@
package polaris
import (
//polarisKratos "github.com/go-kratos/kratos/contrib/config/polaris/v2"
"github.com/go-kratos/kratos/v2/config"
//"github.com/go-kratos/kratos/v2/log"
//
//polarisApi "github.com/polarismesh/polaris-go"
conf "github.com/tx7do/kratos-bootstrap/api/gen/go/conf/v1"
)
// NewConfigSource 创建一个远程配置源 - Polaris
func NewConfigSource(_ *conf.RemoteConfig) config.Source {
//configApi, err := polarisApi.NewConfigAPI()
//if err != nil {
// log.Fatal(err)
//}
//
//var opts []polarisKratos.Option
//opts = append(opts, polarisKratos.WithNamespace("default"))
//opts = append(opts, polarisKratos.WithFileGroup("default"))
//opts = append(opts, polarisKratos.WithFileName("default.yaml"))
//
//source, err := polarisKratos.New(configApi, opts...)
//if err != nil {
// log.Fatal(err)
//}
//
//return source
return nil
}

View File

@@ -0,0 +1,77 @@
package cassandra
import (
"crypto/tls"
"github.com/gocql/gocql"
"github.com/go-kratos/kratos/v2/log"
conf "github.com/tx7do/kratos-bootstrap/api/gen/go/conf/v1"
"github.com/tx7do/kratos-bootstrap/utils"
)
func NewCassandraClient(cfg *conf.Bootstrap, l *log.Helper) *gocql.Session {
if cfg.Data == nil || cfg.Data.Cassandra == nil {
l.Warn("cassandra config is nil")
return nil
}
clusterConfig := gocql.NewCluster(cfg.Data.Cassandra.Address)
// 设置用户名密码
clusterConfig.Authenticator = gocql.PasswordAuthenticator{
Username: cfg.Data.Cassandra.Username,
Password: cfg.Data.Cassandra.Password,
}
clusterConfig.Keyspace = cfg.Data.Cassandra.Keyspace
// 设置ssl
if cfg.Data.Cassandra.Tls != nil {
var tlsCfg *tls.Config
var err error
if cfg.Data.Cassandra.Tls.File != nil {
if tlsCfg, err = utils.LoadServerTlsConfigFile(
cfg.Data.Cassandra.Tls.File.GetKeyPath(),
cfg.Data.Cassandra.Tls.File.GetCertPath(),
cfg.Data.Cassandra.Tls.File.GetCaPath(),
cfg.Data.Cassandra.Tls.InsecureSkipVerify,
); err != nil {
panic(err)
}
}
if tlsCfg == nil && cfg.Data.Cassandra.Tls.Config != nil {
if tlsCfg, err = utils.LoadServerTlsConfig(
cfg.Data.Cassandra.Tls.Config.GetKeyPem(),
cfg.Data.Cassandra.Tls.Config.GetCertPem(),
cfg.Data.Cassandra.Tls.Config.GetCaPem(),
cfg.Data.Cassandra.Tls.InsecureSkipVerify,
); err != nil {
panic(err)
}
}
if tlsCfg != nil {
clusterConfig.SslOpts = &gocql.SslOptions{Config: tlsCfg}
}
}
// 设置超时时间
clusterConfig.ConnectTimeout = cfg.Data.Cassandra.ConnectTimeout.AsDuration()
clusterConfig.Timeout = cfg.Data.Cassandra.Timeout.AsDuration()
clusterConfig.Consistency = gocql.Consistency(cfg.Data.Cassandra.Consistency)
// 禁止主机查找
clusterConfig.DisableInitialHostLookup = cfg.Data.Cassandra.DisableInitialHostLookup
session, err := clusterConfig.CreateSession()
if err != nil {
l.Fatalf("failed opening connection to cassandra: %v", err)
return nil
}
return session
}

23
database/cassandra/go.mod Normal file
View File

@@ -0,0 +1,23 @@
module github.com/tx7do/kratos-bootstrap/database/cassandra
go 1.23.0
toolchain go1.23.3
replace github.com/tx7do/kratos-bootstrap/api => ../../api
require (
github.com/go-kratos/kratos/v2 v2.8.2
github.com/gocql/gocql v1.7.0
github.com/tx7do/kratos-bootstrap/api v0.0.6
github.com/tx7do/kratos-bootstrap/utils v0.1.0
)
require (
github.com/golang/snappy v0.0.4 // indirect
github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed // indirect
github.com/kr/text v0.2.0 // indirect
golang.org/x/sync v0.9.0 // indirect
google.golang.org/protobuf v1.35.1 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
)

37
database/cassandra/go.sum Normal file
View File

@@ -0,0 +1,37 @@
github.com/bitly/go-hostpool v0.0.0-20171023180738-a3a6125de932 h1:mXoPYz/Ul5HYEDvkta6I8/rnYM5gSdSV2tJ6XbZuEtY=
github.com/bitly/go-hostpool v0.0.0-20171023180738-a3a6125de932/go.mod h1:NOuUCSz6Q9T7+igc/hlvDOUdtWKryOrtFyIVABv/p7k=
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869 h1:DDGfHa7BWjL4YnC6+E63dPcxHo2sUxDIu8g3QgEJdRY=
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869/go.mod h1:Ekp36dRnpXw/yCqJaO+ZrUyxD+3VXMFFr56k5XYrpB4=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/go-kratos/kratos/v2 v2.8.2 h1:EsEA7AmPQ2YQQ0FZrDWO2HgBNqeWM8z/mWKzS5UkQaQ=
github.com/go-kratos/kratos/v2 v2.8.2/go.mod h1:+Vfe3FzF0d+BfMdajA11jT0rAyJWublRE/seZQNZVxE=
github.com/gocql/gocql v1.7.0 h1:O+7U7/1gSN7QTEAaMEsJc1Oq2QHXvCWoF3DFK9HDHus=
github.com/gocql/gocql v1.7.0/go.mod h1:vnlvXyFZeLBF0Wy+RS8hrOdbn0UWsWtdg07XJnFxZ+4=
github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM=
github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed h1:5upAirOpQc1Q53c0bnx2ufif5kANL7bfZWcc6VJWJd8=
github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed/go.mod h1:tMWxXQ9wFIaZeTI9F+hmhFiGpFmhOHzyShyFUhRm0H4=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M=
github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/tx7do/kratos-bootstrap/utils v0.1.0 h1:nY1VtIVnnGsOSj4HVhjFBk3qTxjIKDPV7lVR8ZT+gFk=
github.com/tx7do/kratos-bootstrap/utils v0.1.0/go.mod h1:AuXQsL0dtIoOKmAaxiJnBg/9inx7kXX/z7YQeLJ1qmw=
golang.org/x/sync v0.9.0 h1:fEo0HyrW1GIgZdpbhCRO0PkJajUS5H9IFUztCgEo2jQ=
golang.org/x/sync v0.9.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA=
google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc=
gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw=

View File

@@ -0,0 +1,72 @@
package clickhouse
import (
"crypto/tls"
"github.com/ClickHouse/clickhouse-go/v2"
"github.com/go-kratos/kratos/v2/log"
conf "github.com/tx7do/kratos-bootstrap/api/gen/go/conf/v1"
"github.com/tx7do/kratos-bootstrap/utils"
)
func NewClickHouseClient(cfg *conf.Bootstrap, l *log.Helper) clickhouse.Conn {
if cfg.Data == nil || cfg.Data.Clickhouse == nil {
l.Warn("ClickHouse config is nil")
return nil
}
options := &clickhouse.Options{
Addr: []string{cfg.Data.Clickhouse.Address},
Auth: clickhouse.Auth{
Database: cfg.Data.Clickhouse.Database,
Username: cfg.Data.Clickhouse.Username,
Password: cfg.Data.Clickhouse.Password,
},
Debug: cfg.Data.Clickhouse.Debug,
DialTimeout: cfg.Data.Clickhouse.DialTimeout.AsDuration(),
MaxOpenConns: int(cfg.Data.Clickhouse.MaxOpenConns),
MaxIdleConns: int(cfg.Data.Clickhouse.MaxIdleConns),
ConnMaxLifetime: cfg.Data.Clickhouse.ConnMaxLifeTime.AsDuration(),
}
// 设置ssl
if cfg.Data.Clickhouse.Tls != nil {
var tlsCfg *tls.Config
var err error
if cfg.Data.Clickhouse.Tls.File != nil {
if tlsCfg, err = utils.LoadServerTlsConfigFile(
cfg.Data.Clickhouse.Tls.File.GetKeyPath(),
cfg.Data.Clickhouse.Tls.File.GetCertPath(),
cfg.Data.Clickhouse.Tls.File.GetCaPath(),
cfg.Data.Clickhouse.Tls.InsecureSkipVerify,
); err != nil {
panic(err)
}
}
if tlsCfg == nil && cfg.Data.Clickhouse.Tls.Config != nil {
if tlsCfg, err = utils.LoadServerTlsConfig(
cfg.Data.Clickhouse.Tls.Config.GetKeyPem(),
cfg.Data.Clickhouse.Tls.Config.GetCertPem(),
cfg.Data.Clickhouse.Tls.Config.GetCaPem(),
cfg.Data.Clickhouse.Tls.InsecureSkipVerify,
); err != nil {
panic(err)
}
}
if tlsCfg != nil {
options.TLS = tlsCfg
}
}
conn, err := clickhouse.Open(options)
if err != nil {
l.Fatalf("failed opening connection to clickhouse: %v", err)
return nil
}
return conn
}

View File

@@ -0,0 +1,33 @@
module github.com/tx7do/kratos-bootstrap/database/clickhouse
go 1.23.0
toolchain go1.23.3
replace github.com/tx7do/kratos-bootstrap/api => ../../api
require (
github.com/ClickHouse/clickhouse-go/v2 v2.30.0
github.com/go-kratos/kratos/v2 v2.8.2
github.com/tx7do/kratos-bootstrap/api v0.0.7
github.com/tx7do/kratos-bootstrap/utils v0.1.0
)
require (
github.com/ClickHouse/ch-go v0.63.1 // indirect
github.com/andybalholm/brotli v1.1.1 // indirect
github.com/go-faster/city v1.0.1 // indirect
github.com/go-faster/errors v0.7.1 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/klauspost/compress v1.17.11 // indirect
github.com/paulmach/orb v0.11.1 // indirect
github.com/pierrec/lz4/v4 v4.1.21 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/segmentio/asm v1.2.0 // indirect
github.com/shopspring/decimal v1.4.0 // indirect
go.opentelemetry.io/otel v1.32.0 // indirect
go.opentelemetry.io/otel/trace v1.32.0 // indirect
golang.org/x/sys v0.27.0 // indirect
google.golang.org/protobuf v1.35.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

121
database/clickhouse/go.sum Normal file
View File

@@ -0,0 +1,121 @@
github.com/ClickHouse/ch-go v0.63.1 h1:s2JyZvWLTCSAGdtjMBBmAgQQHMco6pawLJMOXi0FODM=
github.com/ClickHouse/ch-go v0.63.1/go.mod h1:I1kJJCL3WJcBMGe1m+HVK0+nREaG+JOYYBWjrDrF3R0=
github.com/ClickHouse/clickhouse-go v1.5.4 h1:cKjXeYLNWVJIx2J1K6H2CqyRmfwVJVY1OV1coaaFcI0=
github.com/ClickHouse/clickhouse-go/v2 v2.30.0 h1:AG4D/hW39qa58+JHQIFOSnxyL46H6h2lrmGGk17dhFo=
github.com/ClickHouse/clickhouse-go/v2 v2.30.0/go.mod h1:i9ZQAojcayW3RsdCb3YR+n+wC2h65eJsZCscZ1Z1wyo=
github.com/andybalholm/brotli v1.1.1 h1:PR2pgnyFznKEugtsUo0xLdDop5SKXd5Qf5ysW+7XdTA=
github.com/andybalholm/brotli v1.1.1/go.mod h1:05ib4cKhjx3OQYUY22hTVd34Bc8upXjOLL2rKwwZBoA=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/go-faster/city v1.0.1 h1:4WAxSZ3V2Ws4QRDrscLEDcibJY8uf41H6AhXDrNDcGw=
github.com/go-faster/city v1.0.1/go.mod h1:jKcUJId49qdW3L1qKHH/3wPeUstCVpVSXTM6vO3VcTw=
github.com/go-faster/errors v0.7.1 h1:MkJTnDoEdi9pDabt1dpWf7AA8/BaSYZqibYyhZ20AYg=
github.com/go-faster/errors v0.7.1/go.mod h1:5ySTjWFiphBs07IKuiL69nxdfd5+fzh1u7FPGZP2quo=
github.com/go-kratos/kratos/v2 v2.8.2 h1:EsEA7AmPQ2YQQ0FZrDWO2HgBNqeWM8z/mWKzS5UkQaQ=
github.com/go-kratos/kratos/v2 v2.8.2/go.mod h1:+Vfe3FzF0d+BfMdajA11jT0rAyJWublRE/seZQNZVxE=
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
github.com/klauspost/compress v1.17.11 h1:In6xLpyWOi1+C7tXUUWv2ot1QvBjxevKAaI6IXrJmUc=
github.com/klauspost/compress v1.17.11/go.mod h1:pMDklpSncoRMuLFrf1W9Ss9KT+0rH90U12bZKk7uwG0=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc=
github.com/paulmach/orb v0.11.1 h1:3koVegMC4X/WeiXYz9iswopaTwMem53NzTJuTF20JzU=
github.com/paulmach/orb v0.11.1/go.mod h1:5mULz1xQfs3bmQm63QEJA6lNGujuRafwA5S/EnuLaLU=
github.com/paulmach/protoscan v0.2.1/go.mod h1:SpcSwydNLrxUGSDvXvO0P7g7AuhJ7lcKfDlhJCDw2gY=
github.com/pierrec/lz4/v4 v4.1.21 h1:yOVMLb6qSIDP67pl/5F7RepeKYu/VmTyEXvuMI5d9mQ=
github.com/pierrec/lz4/v4 v4.1.21/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M=
github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA=
github.com/segmentio/asm v1.2.0 h1:9BQrFxC+YOHJlTlHGkTrFWf59nbL3XnCoFLTwDCI7ys=
github.com/segmentio/asm v1.2.0/go.mod h1:BqMnlJP91P8d+4ibuonYZw9mfnzI9HfxselHZr5aAcs=
github.com/shopspring/decimal v1.4.0 h1:bxl37RwXBklmTi0C79JfXCEBD1cqqHt0bbgBAGFp81k=
github.com/shopspring/decimal v1.4.0/go.mod h1:gawqmDU56v4yIKSwfBSFip1HdCCXN8/+DMd9qYNcwME=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
github.com/tx7do/kratos-bootstrap/utils v0.1.0 h1:nY1VtIVnnGsOSj4HVhjFBk3qTxjIKDPV7lVR8ZT+gFk=
github.com/tx7do/kratos-bootstrap/utils v0.1.0/go.mod h1:AuXQsL0dtIoOKmAaxiJnBg/9inx7kXX/z7YQeLJ1qmw=
github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI=
github.com/xdg-go/scram v1.1.1/go.mod h1:RaEWvsqvNKKvBPvcKeFjrG2cJqOkHTiyTpzz23ni57g=
github.com/xdg-go/stringprep v1.0.3/go.mod h1:W3f5j4i+9rC0kuIEJL0ky1VpHXQU3ocBgklLGvcBnW8=
github.com/xyproto/randomstring v1.0.5 h1:YtlWPoRdgMu3NZtP45drfy1GKoojuR7hmRcnhZqKjWU=
github.com/xyproto/randomstring v1.0.5/go.mod h1:rgmS5DeNXLivK7YprL0pY+lTuhNQW3iGxZ18UQApw/E=
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
go.mongodb.org/mongo-driver v1.11.4/go.mod h1:PTSz5yu21bkT/wXpkS7WR5f0ddqw5quethTUn9WM+2g=
go.opentelemetry.io/otel v1.32.0 h1:WnBN+Xjcteh0zdk01SVqV55d/m62NJLJdIyb4y/WO5U=
go.opentelemetry.io/otel v1.32.0/go.mod h1:00DCVSB0RQcnzlwyTfqtxSm+DRr9hpYrHjNGiBHVQIg=
go.opentelemetry.io/otel/trace v1.32.0 h1:WIC9mYrXf8TmY/EXuULKc8hR17vE+Hjv2cssQDe03fM=
go.opentelemetry.io/otel/trace v1.32.0/go.mod h1:+i4rkvCraA+tG6AzwloGaCtkx53Fa+L+V8e9a7YvhT8=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.27.0 h1:wBqf8DvsY9Y/2P8gAfPDEYNuS30J4lPHJxXSb/nJZ+s=
golang.org/x/sys v0.27.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA=
google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

45
database/ent/client.go Normal file
View File

@@ -0,0 +1,45 @@
package ent
import (
_ "github.com/go-sql-driver/mysql"
_ "github.com/jackc/pgx/v4/stdlib"
_ "github.com/lib/pq"
"github.com/go-kratos/kratos/v2/log"
conf "github.com/tx7do/kratos-bootstrap/api/gen/go/conf/v1"
)
// NewEntClient 创建Ent ORM数据库客户端
func NewEntClient[T ClientInterface](cfg *conf.Bootstrap, l *log.Helper, db T) *ClientWrapper[T] {
if cfg.Data == nil || cfg.Data.Database == nil {
l.Warn("database config is nil")
return nil
}
drv, err := CreateDriver(
cfg.Data.Database.GetDriver(),
cfg.Data.Database.GetSource(),
cfg.Data.Database.GetEnableTrace(),
cfg.Data.Database.GetEnableMetrics(),
)
if err != nil {
l.Fatalf("failed opening connection to db: %v", err)
return nil
}
wrapperClient := NewEntClientWrapper(db, drv)
if cfg.Data.Database.MaxIdleConnections != nil &&
cfg.Data.Database.MaxOpenConnections != nil &&
cfg.Data.Database.ConnectionMaxLifetime != nil {
wrapperClient.SetConnectionOption(
int(cfg.Data.Database.GetMaxIdleConnections()),
int(cfg.Data.Database.GetMaxOpenConnections()),
cfg.Data.Database.GetConnectionMaxLifetime().AsDuration(),
)
}
return wrapperClient
}

View File

@@ -0,0 +1,119 @@
package ent
import (
"context"
"database/sql"
"errors"
"fmt"
"time"
"go.opentelemetry.io/otel/attribute"
semconv "go.opentelemetry.io/otel/semconv/v1.10.0"
"github.com/XSAM/otelsql"
entSql "entgo.io/ent/dialect/sql"
)
type ClientInterface interface {
Close() error
}
type ClientWrapper[T ClientInterface] struct {
db T
drv *entSql.Driver
}
func NewEntClientWrapper[T ClientInterface](db T, drv *entSql.Driver) *ClientWrapper[T] {
return &ClientWrapper[T]{
db: db,
drv: drv,
}
}
func (c *ClientWrapper[T]) Client() T {
return c.db
}
func (c *ClientWrapper[T]) Driver() *entSql.Driver {
return c.drv
}
func (c *ClientWrapper[T]) DB() *sql.DB {
return c.drv.DB()
}
// Close 关闭数据库连接
func (c *ClientWrapper[T]) Close() error {
return c.db.Close()
}
// Query 查询数据
func (c *ClientWrapper[T]) Query(ctx context.Context, query string, args, v any) error {
return c.Driver().Query(ctx, query, args, v)
}
func (c *ClientWrapper[T]) Exec(ctx context.Context, query string, args, v any) error {
return c.Driver().Exec(ctx, query, args, v)
}
// SetConnectionOption 设置连接配置
func (c *ClientWrapper[T]) SetConnectionOption(maxIdleConnections, maxOpenConnections int, connMaxLifetime time.Duration) {
// 连接池中最多保留的空闲连接数量
c.DB().SetMaxIdleConns(maxIdleConnections)
// 连接池在同一时间打开连接的最大数量
c.DB().SetMaxOpenConns(maxOpenConnections)
// 连接可重用的最大时间长度
c.DB().SetConnMaxLifetime(connMaxLifetime)
}
func driverNameToSemConvKeyValue(driverName string) attribute.KeyValue {
switch driverName {
case "mariadb":
return semconv.DBSystemMariaDB
case "mysql":
return semconv.DBSystemMySQL
case "postgresql":
return semconv.DBSystemPostgreSQL
case "sqlite":
return semconv.DBSystemSqlite
default:
return semconv.DBSystemKey.String(driverName)
}
}
// CreateDriver 创建数据库驱动
func CreateDriver(driverName, dsn string, enableTrace, enableMetrics bool) (*entSql.Driver, error) {
var db *sql.DB
var drv *entSql.Driver
var err error
if enableTrace {
// Connect to database
if db, err = otelsql.Open(driverName, dsn, otelsql.WithAttributes(
driverNameToSemConvKeyValue(driverName),
)); err != nil {
return nil, errors.New(fmt.Sprintf("failed opening connection to db: %v", err))
}
drv = entSql.OpenDB(driverName, db)
} else {
if drv, err = entSql.Open(driverName, dsn); err != nil {
return nil, errors.New(fmt.Sprintf("failed opening connection to db: %v", err))
}
db = drv.DB()
}
// Register DB stats to meter
if enableMetrics {
err = otelsql.RegisterDBStatsMetrics(db, otelsql.WithAttributes(
driverNameToSemConvKeyValue(driverName),
))
if err != nil {
return nil, errors.New(fmt.Sprintf("failed register otel meter: %v", err))
}
}
return drv, nil
}

39
database/ent/go.mod Normal file
View File

@@ -0,0 +1,39 @@
module github.com/tx7do/kratos-bootstrap/database/ent
go 1.23.0
toolchain go1.23.3
replace github.com/tx7do/kratos-bootstrap/api => ../../api
require (
entgo.io/ent v0.14.1
github.com/XSAM/otelsql v0.35.0
github.com/go-kratos/kratos/v2 v2.8.2
github.com/go-sql-driver/mysql v1.8.1
github.com/jackc/pgx/v4 v4.18.3
github.com/lib/pq v1.10.9
github.com/tx7do/kratos-bootstrap/api v0.0.5
go.opentelemetry.io/otel v1.32.0
)
require (
filippo.io/edwards25519 v1.1.0 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/jackc/chunkreader/v2 v2.0.1 // indirect
github.com/jackc/pgconn v1.14.3 // indirect
github.com/jackc/pgio v1.0.0 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgproto3/v2 v2.3.3 // indirect
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
github.com/jackc/pgtype v1.14.4 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/shopspring/decimal v1.4.0 // indirect
go.opentelemetry.io/otel/metric v1.32.0 // indirect
go.opentelemetry.io/otel/trace v1.32.0 // indirect
golang.org/x/crypto v0.29.0 // indirect
golang.org/x/text v0.20.0 // indirect
google.golang.org/protobuf v1.35.1 // indirect
)

257
database/ent/go.sum Normal file
View File

@@ -0,0 +1,257 @@
entgo.io/ent v0.14.1 h1:fUERL506Pqr92EPHJqr8EYxbPioflJo6PudkrEA8a/s=
entgo.io/ent v0.14.1/go.mod h1:MH6XLG0KXpkcDQhKiHfANZSzR55TJyPL5IGNpI8wpco=
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60=
github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM=
github.com/Masterminds/semver/v3 v3.1.1 h1:hLg3sBzpNErnxhQtUy/mmLR2I9foDujNK030IGemrRc=
github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs=
github.com/XSAM/otelsql v0.35.0 h1:nMdbU/XLmBIB6qZF61uDqy46E0LVA4ZgF/FCNw8Had4=
github.com/XSAM/otelsql v0.35.0/go.mod h1:wO028mnLzmBpstK8XPsoeRLl/kgt417yjAwOGDIptTc=
github.com/cockroachdb/apd v1.1.0 h1:3LFP3629v+1aKXU5Q37mxmRxX/pIu1nijXydLShEq5I=
github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ=
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY=
github.com/go-kratos/kratos/v2 v2.8.2 h1:EsEA7AmPQ2YQQ0FZrDWO2HgBNqeWM8z/mWKzS5UkQaQ=
github.com/go-kratos/kratos/v2 v2.8.2/go.mod h1:+Vfe3FzF0d+BfMdajA11jT0rAyJWublRE/seZQNZVxE=
github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A=
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
github.com/go-sql-driver/mysql v1.8.1 h1:LedoTUt/eveggdHS9qUFC1EFSa8bU2+1pZjSRpvNJ1Y=
github.com/go-sql-driver/mysql v1.8.1/go.mod h1:wEBSXgmK//2ZFJyE+qWnIsVGmvmEKlqwuVSjsCm7DZg=
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
github.com/gofrs/uuid v4.0.0+incompatible h1:1SD/1F5pU8p29ybwgQSwpQk+mwdRrXCYuPhW6m+TnJw=
github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/jackc/chunkreader v1.0.0/go.mod h1:RT6O25fNZIuasFJRyZ4R/Y2BbhasbmZXF9QQ7T3kePo=
github.com/jackc/chunkreader/v2 v2.0.0/go.mod h1:odVSm741yZoC3dpHEUXIqA9tQRhFrgOHwnPIn9lDKlk=
github.com/jackc/chunkreader/v2 v2.0.1 h1:i+RDz65UE+mmpjTfyz0MoVTnzeYxroil2G82ki7MGG8=
github.com/jackc/chunkreader/v2 v2.0.1/go.mod h1:odVSm741yZoC3dpHEUXIqA9tQRhFrgOHwnPIn9lDKlk=
github.com/jackc/pgconn v0.0.0-20190420214824-7e0022ef6ba3/go.mod h1:jkELnwuX+w9qN5YIfX0fl88Ehu4XC3keFuOJJk9pcnA=
github.com/jackc/pgconn v0.0.0-20190824142844-760dd75542eb/go.mod h1:lLjNuW/+OfW9/pnVKPazfWOgNfH2aPem8YQ7ilXGvJE=
github.com/jackc/pgconn v0.0.0-20190831204454-2fabfa3c18b7/go.mod h1:ZJKsE/KZfsUgOEh9hBm+xYTstcNHg7UPMVJqRfQxq4s=
github.com/jackc/pgconn v1.8.0/go.mod h1:1C2Pb36bGIP9QHGBYCjnyhqu7Rv3sGshaQUvmfGIB/o=
github.com/jackc/pgconn v1.9.0/go.mod h1:YctiPyvzfU11JFxoXokUOOKQXQmDMoJL9vJzHH8/2JY=
github.com/jackc/pgconn v1.9.1-0.20210724152538-d89c8390a530/go.mod h1:4z2w8XhRbP1hYxkpTuBjTS3ne3J48K83+u0zoyvg2pI=
github.com/jackc/pgconn v1.14.3 h1:bVoTr12EGANZz66nZPkMInAV/KHD2TxH9npjXXgiB3w=
github.com/jackc/pgconn v1.14.3/go.mod h1:RZbme4uasqzybK2RK5c65VsHxoyaml09lx3tXOcO/VM=
github.com/jackc/pgio v1.0.0 h1:g12B9UwVnzGhueNavwioyEEpAmqMe1E/BN9ES+8ovkE=
github.com/jackc/pgio v1.0.0/go.mod h1:oP+2QK2wFfUWgr+gxjoBH9KGBb31Eio69xUb0w5bYf8=
github.com/jackc/pgmock v0.0.0-20190831213851-13a1b77aafa2/go.mod h1:fGZlG77KXmcq05nJLRkk0+p82V8B8Dw8KN2/V9c/OAE=
github.com/jackc/pgmock v0.0.0-20201204152224-4fe30f7445fd/go.mod h1:hrBW0Enj2AZTNpt/7Y5rr2xe/9Mn757Wtb2xeBzPv2c=
github.com/jackc/pgmock v0.0.0-20210724152146-4ad1a8207f65 h1:DadwsjnMwFjfWc9y5Wi/+Zz7xoE5ALHsRQlOctkOiHc=
github.com/jackc/pgmock v0.0.0-20210724152146-4ad1a8207f65/go.mod h1:5R2h2EEX+qri8jOWMbJCtaPWkrrNc7OHwsp2TCqp7ak=
github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=
github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=
github.com/jackc/pgproto3 v1.1.0/go.mod h1:eR5FA3leWg7p9aeAqi37XOTgTIbkABlvcPB3E5rlc78=
github.com/jackc/pgproto3/v2 v2.0.0-alpha1.0.20190420180111-c116219b62db/go.mod h1:bhq50y+xrl9n5mRYyCBFKkpRVTLYJVWeCc+mEAI3yXA=
github.com/jackc/pgproto3/v2 v2.0.0-alpha1.0.20190609003834-432c2951c711/go.mod h1:uH0AWtUmuShn0bcesswc4aBTWGvw0cAxIJp+6OB//Wg=
github.com/jackc/pgproto3/v2 v2.0.0-rc3/go.mod h1:ryONWYqW6dqSg1Lw6vXNMXoBJhpzvWKnT95C46ckYeM=
github.com/jackc/pgproto3/v2 v2.0.0-rc3.0.20190831210041-4c03ce451f29/go.mod h1:ryONWYqW6dqSg1Lw6vXNMXoBJhpzvWKnT95C46ckYeM=
github.com/jackc/pgproto3/v2 v2.0.6/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA=
github.com/jackc/pgproto3/v2 v2.1.1/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA=
github.com/jackc/pgproto3/v2 v2.3.3 h1:1HLSx5H+tXR9pW3in3zaztoEwQYRC9SQaYUHjTSUOag=
github.com/jackc/pgproto3/v2 v2.3.3/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA=
github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b/go.mod h1:vsD4gTJCa9TptPL8sPkXrLZ+hDuNrZCnj29CQpr4X1E=
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM=
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 h1:iCEnooe7UlwOQYpKFhBabPMi4aNAfoODPEFNiAnClxo=
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM=
github.com/jackc/pgtype v0.0.0-20190421001408-4ed0de4755e0/go.mod h1:hdSHsc1V01CGwFsrv11mJRHWJ6aifDLfdV3aVjFF0zg=
github.com/jackc/pgtype v0.0.0-20190824184912-ab885b375b90/go.mod h1:KcahbBH1nCMSo2DXpzsoWOAfFkdEtEJpPbVLq8eE+mc=
github.com/jackc/pgtype v0.0.0-20190828014616-a8802b16cc59/go.mod h1:MWlu30kVJrUS8lot6TQqcg7mtthZ9T0EoIBFiJcmcyw=
github.com/jackc/pgtype v1.8.1-0.20210724151600-32e20a603178/go.mod h1:C516IlIV9NKqfsMCXTdChteoXmwgUceqaLfjg2e3NlM=
github.com/jackc/pgtype v1.14.0/go.mod h1:LUMuVrfsFfdKGLw+AFFVv6KtHOFMwRgDDzBt76IqCA4=
github.com/jackc/pgtype v1.14.4 h1:fKuNiCumbKTAIxQwXfB/nsrnkEI6bPJrrSiMKgbJ2j8=
github.com/jackc/pgtype v1.14.4/go.mod h1:aKeozOde08iifGosdJpz9MBZonJOUJxqNpPBcMJTlVA=
github.com/jackc/pgx/v4 v4.0.0-20190420224344-cc3461e65d96/go.mod h1:mdxmSJJuR08CZQyj1PVQBHy9XOp5p8/SHH6a0psbY9Y=
github.com/jackc/pgx/v4 v4.0.0-20190421002000-1b8f0016e912/go.mod h1:no/Y67Jkk/9WuGR0JG/JseM9irFbnEPbuWV2EELPNuM=
github.com/jackc/pgx/v4 v4.0.0-pre1.0.20190824185557-6972a5742186/go.mod h1:X+GQnOEnf1dqHGpw7JmHqHc1NxDoalibchSk9/RWuDc=
github.com/jackc/pgx/v4 v4.12.1-0.20210724153913-640aa07df17c/go.mod h1:1QD0+tgSXP7iUjYm9C1NxKhny7lq6ee99u/z+IHFcgs=
github.com/jackc/pgx/v4 v4.18.2/go.mod h1:Ey4Oru5tH5sB6tV7hDmfWFahwF15Eb7DNXlRKx2CkVw=
github.com/jackc/pgx/v4 v4.18.3 h1:dE2/TrEsGX3RBprb3qryqSV9Y60iZN1C6i8IrmW9/BA=
github.com/jackc/pgx/v4 v4.18.3/go.mod h1:Ey4Oru5tH5sB6tV7hDmfWFahwF15Eb7DNXlRKx2CkVw=
github.com/jackc/puddle v0.0.0-20190413234325-e4ced69a3a2b/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
github.com/jackc/puddle v0.0.0-20190608224051-11cab39313c9/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
github.com/jackc/puddle v1.1.3/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
github.com/jackc/puddle v1.3.0/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/lib/pq v1.1.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/lib/pq v1.10.2/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw=
github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ=
github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ=
github.com/rs/zerolog v1.13.0/go.mod h1:YbFCdg8HfsridGWAh22vktObvhZbQsZXe4/zB0OKkWU=
github.com/rs/zerolog v1.15.0/go.mod h1:xYTKnLHcpfU2225ny5qZjxnj9NvkumZYjJHlAThCjNc=
github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24/go.mod h1:M+9NzErvs504Cn4c5DxATwIqPbtswREoFCre64PpcG4=
github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
github.com/shopspring/decimal v1.4.0 h1:bxl37RwXBklmTi0C79JfXCEBD1cqqHt0bbgBAGFp81k=
github.com/shopspring/decimal v1.4.0/go.mod h1:gawqmDU56v4yIKSwfBSFip1HdCCXN8/+DMd9qYNcwME=
github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q=
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
github.com/zenazn/goji v0.9.0/go.mod h1:7S9M489iMyHBNxwZnk9/EHS098H4/F6TATF2mIxtB1Q=
go.opentelemetry.io/otel v1.32.0 h1:WnBN+Xjcteh0zdk01SVqV55d/m62NJLJdIyb4y/WO5U=
go.opentelemetry.io/otel v1.32.0/go.mod h1:00DCVSB0RQcnzlwyTfqtxSm+DRr9hpYrHjNGiBHVQIg=
go.opentelemetry.io/otel/metric v1.32.0 h1:xV2umtmNcThh2/a/aCP+h64Xx5wsj8qqnkYZktzNa0M=
go.opentelemetry.io/otel/metric v1.32.0/go.mod h1:jH7CIbbK6SH2V2wE16W05BHCtIDzauciCRLoc/SyMv8=
go.opentelemetry.io/otel/sdk v1.31.0 h1:xLY3abVHYZ5HSfOg3l2E5LUj2Cwva5Y7yGxnSW9H5Gk=
go.opentelemetry.io/otel/sdk v1.31.0/go.mod h1:TfRbMdhvxIIr/B2N2LQW2S5v9m3gOQ/08KsbbO5BPT0=
go.opentelemetry.io/otel/sdk/metric v1.31.0 h1:i9hxxLJF/9kkvfHppyLL55aW7iIJz4JjxTeYusH7zMc=
go.opentelemetry.io/otel/sdk/metric v1.31.0/go.mod h1:CRInTMVvNhUKgSAMbKyTMxqOBC0zgyxzW55lZzX43Y8=
go.opentelemetry.io/otel/trace v1.32.0 h1:WIC9mYrXf8TmY/EXuULKc8hR17vE+Hjv2cssQDe03fM=
go.opentelemetry.io/otel/trace v1.32.0/go.mod h1:+i4rkvCraA+tG6AzwloGaCtkx53Fa+L+V8e9a7YvhT8=
go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4=
go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU=
go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA=
go.uber.org/zap v1.9.1/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190411191339-88737f569e3a/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE=
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20201203163018-be400aefbc4c/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
golang.org/x/crypto v0.20.0/go.mod h1:Xwo95rrVNIoSMx9wa1JroENMToLWn3RNVrTBpLHgZPQ=
golang.org/x/crypto v0.29.0 h1:L5SG1JTTXupVV3n6sUqMTeWbjAyfPwoda2DLX8J8FrQ=
golang.org/x/crypto v0.29.0/go.mod h1:+F4F4N5hv6v38hfeYwTdx20oUvLLc+QfrE9Ax9HtgRg=
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.9.0 h1:fEo0HyrW1GIgZdpbhCRO0PkJajUS5H9IFUztCgEo2jQ=
golang.org/x/sync v0.9.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.27.0 h1:wBqf8DvsY9Y/2P8gAfPDEYNuS30J4lPHJxXSb/nJZ+s=
golang.org/x/sys v0.27.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=
golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/text v0.20.0 h1:gK/Kv2otX8gz+wn7Rmb3vT96ZwuoxnQlY+HlJVj7Qug=
golang.org/x/text v0.20.0/go.mod h1:D4IsuqiFMhST5bX19pQ9ikHC2GsaKyk/oF+pn3ducp4=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20190425163242-31fd60d6bfdc/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
golang.org/x/tools v0.0.0-20190823170909-c4a336ef6a2f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20200103221440-774c71fcf114/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA=
google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/inconshreveable/log15.v2 v2.0.0-20180818164646-67afb5ed74ec/go.mod h1:aPpfJ7XW+gOuirDoZ8gHhLh3kZ1B08FtV2bbmy7Jv3s=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=

102
database/gorm/client.go Normal file
View File

@@ -0,0 +1,102 @@
package gorm
import (
"gorm.io/driver/bigquery"
"gorm.io/driver/clickhouse"
"gorm.io/driver/mysql"
"gorm.io/driver/postgres"
"gorm.io/driver/sqlite"
"gorm.io/driver/sqlserver"
"gorm.io/plugin/opentelemetry/tracing"
"gorm.io/plugin/prometheus"
"gorm.io/gorm"
"github.com/go-kratos/kratos/v2/log"
conf "github.com/tx7do/kratos-bootstrap/api/gen/go/conf/v1"
)
// NewGormClient 创建GORM数据库客户端
func NewGormClient(cfg *conf.Bootstrap, l *log.Helper, migrates []interface{}) *gorm.DB {
if cfg.Data == nil || cfg.Data.Database == nil {
l.Warn("database config is nil")
return nil
}
var driver gorm.Dialector
switch cfg.Data.Database.Driver {
default:
fallthrough
case "mysql":
driver = mysql.Open(cfg.Data.Database.Source)
break
case "postgres":
driver = postgres.Open(cfg.Data.Database.Source)
break
case "clickhouse":
driver = clickhouse.Open(cfg.Data.Database.Source)
break
case "sqlite":
driver = sqlite.Open(cfg.Data.Database.Source)
break
case "sqlserver":
driver = sqlserver.Open(cfg.Data.Database.Source)
break
case "bigquery":
driver = bigquery.Open(cfg.Data.Database.Source)
break
}
db, err := gorm.Open(driver, &gorm.Config{})
if err != nil {
l.Fatalf("failed opening connection to db: %v", err)
return nil
}
// 运行数据库迁移工具
if cfg.Data.Database.Migrate {
if err = db.AutoMigrate(
migrates...,
); err != nil {
l.Fatalf("failed creating schema resources: %v", err)
return nil
}
}
if cfg.Data.Database.GetEnableTrace() {
if err = db.Use(tracing.NewPlugin()); err != nil {
l.Fatalf("failed enable trace: %v", err)
return nil
}
}
if cfg.Data.Database.GetEnableMetrics() {
if err = db.Use(prometheus.New(prometheus.Config{
RefreshInterval: 15, // refresh metrics interval (default 15 seconds)
StartServer: true, // start http server to expose metrics
DBName: cfg.Data.Database.GetPrometheusDbName(), // `DBName` as metrics label
PushAddr: cfg.Data.Database.GetPrometheusPushAddr(), // push metrics if `PushAddr` configured
HTTPServerPort: cfg.Data.Database.GetPrometheusHttpPort(), // configure http server port, default port 8080 (if you have configured multiple instances, only the first `HTTPServerPort` will be used to start server)
})); err != nil {
l.Fatalf("failed enable metrics: %v", err)
return nil
}
}
sqlDB, err := db.DB()
if sqlDB != nil {
if cfg.Data.Database.MaxIdleConnections != nil {
sqlDB.SetMaxIdleConns(int(cfg.Data.Database.GetMaxIdleConnections()))
}
if cfg.Data.Database.MaxOpenConnections != nil {
sqlDB.SetMaxOpenConns(int(cfg.Data.Database.GetMaxOpenConnections()))
}
if cfg.Data.Database.ConnectionMaxLifetime != nil {
sqlDB.SetConnMaxLifetime(cfg.Data.Database.GetConnectionMaxLifetime().AsDuration())
}
}
return db
}

104
database/gorm/go.mod Normal file
View File

@@ -0,0 +1,104 @@
module github.com/tx7do/kratos-bootstrap/database/gorm
go 1.23.0
toolchain go1.23.3
replace github.com/tx7do/kratos-bootstrap/api => ../../api
require (
github.com/go-kratos/kratos/v2 v2.8.2
github.com/tx7do/kratos-bootstrap/api v0.0.5
gorm.io/driver/bigquery v1.2.0
gorm.io/driver/clickhouse v0.6.1
gorm.io/driver/mysql v1.5.7
gorm.io/driver/postgres v1.5.9
gorm.io/driver/sqlite v1.5.6
gorm.io/driver/sqlserver v1.5.4
gorm.io/gorm v1.25.12
gorm.io/plugin/opentelemetry v0.1.8
gorm.io/plugin/prometheus v0.1.0
)
require (
cloud.google.com/go v0.112.0 // indirect
cloud.google.com/go/bigquery v1.58.0 // indirect
cloud.google.com/go/compute v1.23.3 // indirect
cloud.google.com/go/compute/metadata v0.2.3 // indirect
cloud.google.com/go/iam v1.1.5 // indirect
filippo.io/edwards25519 v1.1.0 // indirect
github.com/ClickHouse/ch-go v0.63.1 // indirect
github.com/ClickHouse/clickhouse-go/v2 v2.30.0 // indirect
github.com/andybalholm/brotli v1.1.1 // indirect
github.com/apache/arrow/go/v12 v12.0.1 // indirect
github.com/apache/thrift v0.16.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/go-faster/city v1.0.1 // indirect
github.com/go-faster/errors v0.7.1 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-sql-driver/mysql v1.8.1 // indirect
github.com/goccy/go-json v0.9.11 // indirect
github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 // indirect
github.com/golang-sql/sqlexp v0.1.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/flatbuffers v2.0.8+incompatible // indirect
github.com/google/s2a-go v0.1.7 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect
github.com/googleapis/gax-go/v2 v2.12.0 // indirect
github.com/hashicorp/go-version v1.7.0 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
github.com/jackc/pgx/v5 v5.7.1 // indirect
github.com/jackc/puddle/v2 v2.2.2 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/klauspost/asmfmt v1.3.2 // indirect
github.com/klauspost/compress v1.17.11 // indirect
github.com/klauspost/cpuid/v2 v2.0.9 // indirect
github.com/mattn/go-sqlite3 v1.14.24 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/microsoft/go-mssqldb v1.7.2 // indirect
github.com/minio/asm2plan9s v0.0.0-20200509001527-cdd76441f9d8 // indirect
github.com/minio/c2goasm v0.0.0-20190812172519-36a3d3bbc4f3 // indirect
github.com/paulmach/orb v0.11.1 // indirect
github.com/pierrec/lz4/v4 v4.1.21 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/prometheus/client_golang v1.17.0 // indirect
github.com/prometheus/client_model v0.4.1-0.20230718164431-9a2bf3000d16 // indirect
github.com/prometheus/common v0.44.0 // indirect
github.com/prometheus/procfs v0.11.1 // indirect
github.com/segmentio/asm v1.2.0 // indirect
github.com/shopspring/decimal v1.4.0 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/zeebo/xxh3 v1.0.2 // indirect
go.opencensus.io v0.24.0 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.46.1 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 // indirect
go.opentelemetry.io/otel v1.32.0 // indirect
go.opentelemetry.io/otel/metric v1.32.0 // indirect
go.opentelemetry.io/otel/trace v1.32.0 // indirect
golang.org/x/crypto v0.29.0 // indirect
golang.org/x/mod v0.17.0 // indirect
golang.org/x/net v0.30.0 // indirect
golang.org/x/oauth2 v0.16.0 // indirect
golang.org/x/sync v0.9.0 // indirect
golang.org/x/sys v0.27.0 // indirect
golang.org/x/text v0.20.0 // indirect
golang.org/x/time v0.5.0 // indirect
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 // indirect
google.golang.org/api v0.155.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto v0.0.0-20240123012728-ef4313101c80 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240318140521-94a12d6c2237 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237 // indirect
google.golang.org/grpc v1.62.1 // indirect
google.golang.org/protobuf v1.35.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

1260
database/gorm/go.sum Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,29 @@
package influxdb
import (
"github.com/InfluxCommunity/influxdb3-go/influxdb3"
"github.com/go-kratos/kratos/v2/log"
conf "github.com/tx7do/kratos-bootstrap/api/gen/go/conf/v1"
)
func NewInfluxClient(cfg *conf.Bootstrap, l *log.Helper) *influxdb3.Client {
if cfg.Data == nil || cfg.Data.Influxdb == nil {
l.Warn("influxdb config is nil")
return nil
}
client, err := influxdb3.New(influxdb3.ClientConfig{
Host: cfg.Data.Influxdb.Address,
Token: cfg.Data.Influxdb.Token,
Database: cfg.Data.Influxdb.Bucket,
Organization: cfg.Data.Influxdb.Organization,
})
if err != nil {
l.Fatalf("failed opening connection to influxdb: %v", err)
return nil
}
return client
}

36
database/influxdb/go.mod Normal file
View File

@@ -0,0 +1,36 @@
module github.com/tx7do/kratos-bootstrap/database/influxdb
go 1.23.0
toolchain go1.23.3
replace github.com/tx7do/kratos-bootstrap/api => ../../api
require (
github.com/InfluxCommunity/influxdb3-go v0.14.0
github.com/go-kratos/kratos/v2 v2.8.2
github.com/tx7do/kratos-bootstrap/api v0.0.5
)
require (
github.com/apache/arrow/go/v15 v15.0.2 // indirect
github.com/frankban/quicktest v1.14.0 // indirect
github.com/goccy/go-json v0.10.3 // indirect
github.com/google/flatbuffers v24.3.25+incompatible // indirect
github.com/influxdata/line-protocol/v2 v2.2.1 // indirect
github.com/klauspost/compress v1.17.11 // indirect
github.com/klauspost/cpuid/v2 v2.2.9 // indirect
github.com/pierrec/lz4/v4 v4.1.21 // indirect
github.com/zeebo/xxh3 v1.0.2 // indirect
golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f // indirect
golang.org/x/mod v0.22.0 // indirect
golang.org/x/net v0.31.0 // indirect
golang.org/x/sync v0.9.0 // indirect
golang.org/x/sys v0.27.0 // indirect
golang.org/x/text v0.20.0 // indirect
golang.org/x/tools v0.27.0 // indirect
golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20241113202542-65e8d215514f // indirect
google.golang.org/grpc v1.68.0 // indirect
google.golang.org/protobuf v1.35.1 // indirect
)

93
database/influxdb/go.sum Normal file
View File

@@ -0,0 +1,93 @@
github.com/InfluxCommunity/influxdb3-go v0.14.0 h1:lFEJRZM+hQzuCz36k6YKeE6CE9oKBfKkIO2bYLghar0=
github.com/InfluxCommunity/influxdb3-go v0.14.0/go.mod h1:+0XXsEt0XMP0o7WBvDXLCJ8MxmxfgjG3mLrYPRRWsLs=
github.com/apache/arrow/go/v15 v15.0.2 h1:60IliRbiyTWCWjERBCkO1W4Qun9svcYoZrSLcyOsMLE=
github.com/apache/arrow/go/v15 v15.0.2/go.mod h1:DGXsR3ajT524njufqf95822i+KTh+yea1jass9YXgjA=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/frankban/quicktest v1.11.0/go.mod h1:K+q6oSqb0W0Ininfk863uOk1lMy69l/P6txr3mVT54s=
github.com/frankban/quicktest v1.11.2/go.mod h1:K+q6oSqb0W0Ininfk863uOk1lMy69l/P6txr3mVT54s=
github.com/frankban/quicktest v1.13.0/go.mod h1:qLE0fzW0VuyUAJgPU19zByoIr0HtCHN/r/VLSOOIySU=
github.com/frankban/quicktest v1.14.0 h1:+cqqvzZV87b4adx/5ayVOaYZ2CrvM4ejQvUdBzPPUss=
github.com/frankban/quicktest v1.14.0/go.mod h1:NeW+ay9A/U67EYXNFA1nPE8e/tnQv/09mUdL/ijj8og=
github.com/go-kratos/kratos/v2 v2.8.2 h1:EsEA7AmPQ2YQQ0FZrDWO2HgBNqeWM8z/mWKzS5UkQaQ=
github.com/go-kratos/kratos/v2 v2.8.2/go.mod h1:+Vfe3FzF0d+BfMdajA11jT0rAyJWublRE/seZQNZVxE=
github.com/goccy/go-json v0.10.3 h1:KZ5WoDbxAIgm2HNbYckL0se1fHD6rz5j4ywS6ebzDqA=
github.com/goccy/go-json v0.10.3/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
github.com/google/flatbuffers v24.3.25+incompatible h1:CX395cjN9Kke9mmalRoL3d81AtFUxJM+yDthflgJGkI=
github.com/google/flatbuffers v24.3.25+incompatible/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8=
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/influxdata/line-protocol-corpus v0.0.0-20210519164801-ca6fa5da0184/go.mod h1:03nmhxzZ7Xk2pdG+lmMd7mHDfeVOYFyhOgwO61qWU98=
github.com/influxdata/line-protocol-corpus v0.0.0-20210922080147-aa28ccfb8937 h1:MHJNQ+p99hFATQm6ORoLmpUCF7ovjwEFshs/NHzAbig=
github.com/influxdata/line-protocol-corpus v0.0.0-20210922080147-aa28ccfb8937/go.mod h1:BKR9c0uHSmRgM/se9JhFHtTT7JTO67X23MtKMHtZcpo=
github.com/influxdata/line-protocol/v2 v2.0.0-20210312151457-c52fdecb625a/go.mod h1:6+9Xt5Sq1rWx+glMgxhcg2c0DUaehK+5TDcPZ76GypY=
github.com/influxdata/line-protocol/v2 v2.1.0/go.mod h1:QKw43hdUBg3GTk2iC3iyCxksNj7PX9aUSeYOYE/ceHY=
github.com/influxdata/line-protocol/v2 v2.2.1 h1:EAPkqJ9Km4uAxtMRgUubJyqAr6zgWM0dznKMLRauQRE=
github.com/influxdata/line-protocol/v2 v2.2.1/go.mod h1:DmB3Cnh+3oxmG6LOBIxce4oaL4CPj3OmMPgvauXh+tM=
github.com/klauspost/compress v1.17.11 h1:In6xLpyWOi1+C7tXUUWv2ot1QvBjxevKAaI6IXrJmUc=
github.com/klauspost/compress v1.17.11/go.mod h1:pMDklpSncoRMuLFrf1W9Ss9KT+0rH90U12bZKk7uwG0=
github.com/klauspost/cpuid/v2 v2.2.9 h1:66ze0taIn2H33fBvCkXuv9BmCwDfafmiIVpKV9kKGuY=
github.com/klauspost/cpuid/v2 v2.2.9/go.mod h1:rqkxqrZ1EhYM9G+hXH7YdowN5R5RGN6NK4QwQ3WMXF8=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
github.com/pierrec/lz4/v4 v4.1.21 h1:yOVMLb6qSIDP67pl/5F7RepeKYu/VmTyEXvuMI5d9mQ=
github.com/pierrec/lz4/v4 v4.1.21/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M=
github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/zeebo/assert v1.3.0 h1:g7C04CbJuIDKNPFHmsk4hwZDO5O+kntRxzaUoNXj+IQ=
github.com/zeebo/assert v1.3.0/go.mod h1:Pq9JiuJQpG8JLJdtkwrJESF0Foym2/D9XMU5ciN/wJ0=
github.com/zeebo/xxh3 v1.0.2 h1:xZmwmqxHZA8AI603jOQ0tMqmBr9lPeFwGg6d+xy9DC0=
github.com/zeebo/xxh3 v1.0.2/go.mod h1:5NWz9Sef7zIDm2JHfFlcQvNekmcEl9ekUZQQKCYaDcA=
golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f h1:XdNn9LlyWAhLVp6P/i8QYBW+hlyhrhei9uErw2B5GJo=
golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f/go.mod h1:D5SMRVC3C2/4+F/DB1wZsLRnSNimn2Sp/NPsCrsv8ak=
golang.org/x/mod v0.22.0 h1:D4nJWe9zXqHOmWqj4VMOJhvzj7bEZg4wEYa759z1pH4=
golang.org/x/mod v0.22.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY=
golang.org/x/net v0.31.0 h1:68CPQngjLL0r2AlUKiSxtQFKvzRVbnzLwMUn5SzcLHo=
golang.org/x/net v0.31.0/go.mod h1:P4fl1q7dY2hnZFxEk4pPSkDHF+QqjitcnDjUQyMM+pM=
golang.org/x/sync v0.9.0 h1:fEo0HyrW1GIgZdpbhCRO0PkJajUS5H9IFUztCgEo2jQ=
golang.org/x/sync v0.9.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.27.0 h1:wBqf8DvsY9Y/2P8gAfPDEYNuS30J4lPHJxXSb/nJZ+s=
golang.org/x/sys v0.27.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.20.0 h1:gK/Kv2otX8gz+wn7Rmb3vT96ZwuoxnQlY+HlJVj7Qug=
golang.org/x/text v0.20.0/go.mod h1:D4IsuqiFMhST5bX19pQ9ikHC2GsaKyk/oF+pn3ducp4=
golang.org/x/tools v0.27.0 h1:qEKojBykQkQ4EynWy4S8Weg69NumxKdn40Fce3uc/8o=
golang.org/x/tools v0.27.0/go.mod h1:sUi0ZgbwW9ZPAq26Ekut+weQPR5eIM6GQLQ1Yjm1H0Q=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da h1:noIWHXmPHxILtqtCOPIhSt0ABwskkZKjD3bXGnZGpNY=
golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da/go.mod h1:NDW/Ps6MPRej6fsCIbMTohpP40sJ/P/vI1MoTEGwX90=
gonum.org/v1/gonum v0.12.0 h1:xKuo6hzt+gMav00meVPUlXwSdoEJP46BR+wdxQEFK2o=
gonum.org/v1/gonum v0.12.0/go.mod h1:73TDxJfAAHeA8Mk9mf8NlIppyhQNo5GLTcYeqgo2lvY=
google.golang.org/genproto/googleapis/rpc v0.0.0-20241113202542-65e8d215514f h1:C1QccEa9kUwvMgEUORqQD9S17QesQijxjZ84sO82mfo=
google.golang.org/genproto/googleapis/rpc v0.0.0-20241113202542-65e8d215514f/go.mod h1:GX3210XPVPUjJbTUbvwI8f2IpZDMZuPJWDzDuebbviI=
google.golang.org/grpc v1.68.0 h1:aHQeeJbo8zAkAa3pRzrVjZlbz6uSfeOXlJNQM0RAbz0=
google.golang.org/grpc v1.68.0/go.mod h1:fmSPC5AsjSBCK54MyHRx48kpOti1/jRfOlwEWywNjWA=
google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA=
google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

View File

@@ -0,0 +1,36 @@
package mongodb
import (
"context"
"fmt"
"github.com/go-kratos/kratos/v2/log"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
conf "github.com/tx7do/kratos-bootstrap/api/gen/go/conf/v1"
)
// NewMongoClient 创建MongoDB客户端
func NewMongoClient(ctx context.Context, cfg *conf.Bootstrap, l *log.Helper) *mongo.Client {
if cfg.Data == nil || cfg.Data.Mongodb == nil {
l.Warn("Mongodb config is nil")
return nil
}
var opts []*options.ClientOptions
uri := fmt.Sprintf("mongodb://%s:%s@%s",
cfg.Data.Mongodb.Username, cfg.Data.Mongodb.Password, cfg.Data.Mongodb.Address,
)
opts = append(opts, options.Client().ApplyURI(uri))
cli, err := mongo.Connect(ctx, opts...)
if err != nil {
l.Fatalf("failed opening connection to mongodb: %v", err)
return nil
}
return cli
}

27
database/mongodb/go.mod Normal file
View File

@@ -0,0 +1,27 @@
module github.com/tx7do/kratos-bootstrap/database/mongodb
go 1.23.0
toolchain go1.23.3
replace github.com/tx7do/kratos-bootstrap/api => ../../api
require (
github.com/go-kratos/kratos/v2 v2.8.2
github.com/tx7do/kratos-bootstrap/api v0.0.5
go.mongodb.org/mongo-driver v1.17.1
)
require (
github.com/golang/snappy v0.0.4 // indirect
github.com/klauspost/compress v1.17.11 // indirect
github.com/montanaflynn/stats v0.7.1 // indirect
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
github.com/xdg-go/scram v1.1.2 // indirect
github.com/xdg-go/stringprep v1.0.4 // indirect
github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 // indirect
golang.org/x/crypto v0.29.0 // indirect
golang.org/x/sync v0.9.0 // indirect
golang.org/x/text v0.20.0 // indirect
google.golang.org/protobuf v1.35.1 // indirect
)

54
database/mongodb/go.sum Normal file
View File

@@ -0,0 +1,54 @@
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/go-kratos/kratos/v2 v2.8.2 h1:EsEA7AmPQ2YQQ0FZrDWO2HgBNqeWM8z/mWKzS5UkQaQ=
github.com/go-kratos/kratos/v2 v2.8.2/go.mod h1:+Vfe3FzF0d+BfMdajA11jT0rAyJWublRE/seZQNZVxE=
github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM=
github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/klauspost/compress v1.17.11 h1:In6xLpyWOi1+C7tXUUWv2ot1QvBjxevKAaI6IXrJmUc=
github.com/klauspost/compress v1.17.11/go.mod h1:pMDklpSncoRMuLFrf1W9Ss9KT+0rH90U12bZKk7uwG0=
github.com/montanaflynn/stats v0.7.1 h1:etflOAAHORrCC44V+aR6Ftzort912ZU+YLiSTuV8eaE=
github.com/montanaflynn/stats v0.7.1/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow=
github.com/xdg-go/pbkdf2 v1.0.0 h1:Su7DPu48wXMwC3bs7MCNG+z4FhcyEuz5dlvchbq0B0c=
github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI=
github.com/xdg-go/scram v1.1.2 h1:FHX5I5B4i4hKRVRBCFRxq1iQRej7WO3hhBuJf+UUySY=
github.com/xdg-go/scram v1.1.2/go.mod h1:RT/sEzTbU5y00aCK8UOx6R7YryM0iF1N2MOmC3kKLN4=
github.com/xdg-go/stringprep v1.0.4 h1:XLI/Ng3O1Atzq0oBs3TWm+5ZVgkq2aqdlvP9JtoZ6c8=
github.com/xdg-go/stringprep v1.0.4/go.mod h1:mPGuuIYwz7CmR2bT9j4GbQqutWS1zV24gijq1dTyGkM=
github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 h1:ilQV1hzziu+LLM3zUTJ0trRztfwgjqKnBWNtSRkbmwM=
github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78/go.mod h1:aL8wCCfTfSfmXjznFBSZNN13rSJjlIOI1fUNAtF7rmI=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
go.mongodb.org/mongo-driver v1.17.1 h1:Wic5cJIwJgSpBhe3lx3+/RybR5PiYRMpVFgO7cOHyIM=
go.mongodb.org/mongo-driver v1.17.1/go.mod h1:wwWm/+BuOddhcq3n68LKRmgk2wXzmF6s0SFOa0GINL4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.29.0 h1:L5SG1JTTXupVV3n6sUqMTeWbjAyfPwoda2DLX8J8FrQ=
golang.org/x/crypto v0.29.0/go.mod h1:+F4F4N5hv6v38hfeYwTdx20oUvLLc+QfrE9Ax9HtgRg=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.9.0 h1:fEo0HyrW1GIgZdpbhCRO0PkJajUS5H9IFUztCgEo2jQ=
golang.org/x/sync v0.9.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
golang.org/x/text v0.20.0 h1:gK/Kv2otX8gz+wn7Rmb3vT96ZwuoxnQlY+HlJVj7Qug=
golang.org/x/text v0.20.0/go.mod h1:D4IsuqiFMhST5bX19pQ9ikHC2GsaKyk/oF+pn3ducp4=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA=
google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=

View File

@@ -1,916 +0,0 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.31.0
// protoc (unknown)
// source: conf/v1/kratos_conf_data.proto
package v1
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
durationpb "google.golang.org/protobuf/types/known/durationpb"
reflect "reflect"
sync "sync"
)
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 Data struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Database *Data_Database `protobuf:"bytes,1,opt,name=database,proto3" json:"database,omitempty"` // 数据库DSN
Redis *Data_Redis `protobuf:"bytes,10,opt,name=redis,proto3" json:"redis,omitempty"` // Redis
Mongodb *Data_MongoDB `protobuf:"bytes,11,opt,name=mongodb,proto3" json:"mongodb,omitempty"` // MongoDB数据库
ElasticSearch *Data_ElasticSearch `protobuf:"bytes,12,opt,name=elastic_search,json=elasticSearch,proto3" json:"elastic_search,omitempty"` // ElasticSearch数据库
Clickhouse *Data_ClickHouse `protobuf:"bytes,20,opt,name=clickhouse,proto3" json:"clickhouse,omitempty"` // ClickHouse数据库
Influxdb *Data_InfluxDB `protobuf:"bytes,21,opt,name=influxdb,proto3" json:"influxdb,omitempty"` // InfluxDB数据库
Doris *Data_Doris `protobuf:"bytes,22,opt,name=doris,proto3" json:"doris,omitempty"` // Doris数据库
Kafka *Data_Kafka `protobuf:"bytes,30,opt,name=kafka,proto3" json:"kafka,omitempty"` // Kafka服务
}
func (x *Data) Reset() {
*x = Data{}
if protoimpl.UnsafeEnabled {
mi := &file_conf_v1_kratos_conf_data_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Data) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Data) ProtoMessage() {}
func (x *Data) ProtoReflect() protoreflect.Message {
mi := &file_conf_v1_kratos_conf_data_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use Data.ProtoReflect.Descriptor instead.
func (*Data) Descriptor() ([]byte, []int) {
return file_conf_v1_kratos_conf_data_proto_rawDescGZIP(), []int{0}
}
func (x *Data) GetDatabase() *Data_Database {
if x != nil {
return x.Database
}
return nil
}
func (x *Data) GetRedis() *Data_Redis {
if x != nil {
return x.Redis
}
return nil
}
func (x *Data) GetMongodb() *Data_MongoDB {
if x != nil {
return x.Mongodb
}
return nil
}
func (x *Data) GetElasticSearch() *Data_ElasticSearch {
if x != nil {
return x.ElasticSearch
}
return nil
}
func (x *Data) GetClickhouse() *Data_ClickHouse {
if x != nil {
return x.Clickhouse
}
return nil
}
func (x *Data) GetInfluxdb() *Data_InfluxDB {
if x != nil {
return x.Influxdb
}
return nil
}
func (x *Data) GetDoris() *Data_Doris {
if x != nil {
return x.Doris
}
return nil
}
func (x *Data) GetKafka() *Data_Kafka {
if x != nil {
return x.Kafka
}
return nil
}
// 数据库
type Data_Database struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Driver string `protobuf:"bytes,1,opt,name=driver,proto3" json:"driver,omitempty"` // 驱动名mysql、postgresql、mongodb、sqlite……
Source string `protobuf:"bytes,2,opt,name=source,proto3" json:"source,omitempty"` // 数据源DSN字符串
Migrate bool `protobuf:"varint,3,opt,name=migrate,proto3" json:"migrate,omitempty"` // 数据迁移开关
Debug bool `protobuf:"varint,4,opt,name=debug,proto3" json:"debug,omitempty"` // 调试开关
MaxIdleConnections int32 `protobuf:"varint,5,opt,name=max_idle_connections,json=maxIdleConnections,proto3" json:"max_idle_connections,omitempty"` // 连接池最大空闲连接数
MaxOpenConnections int32 `protobuf:"varint,6,opt,name=max_open_connections,json=maxOpenConnections,proto3" json:"max_open_connections,omitempty"` // 连接池最大打开连接数
ConnectionMaxLifetime *durationpb.Duration `protobuf:"bytes,7,opt,name=connection_max_lifetime,json=connectionMaxLifetime,proto3" json:"connection_max_lifetime,omitempty"` // 连接可重用的最大时间长度
}
func (x *Data_Database) Reset() {
*x = Data_Database{}
if protoimpl.UnsafeEnabled {
mi := &file_conf_v1_kratos_conf_data_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Data_Database) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Data_Database) ProtoMessage() {}
func (x *Data_Database) ProtoReflect() protoreflect.Message {
mi := &file_conf_v1_kratos_conf_data_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use Data_Database.ProtoReflect.Descriptor instead.
func (*Data_Database) Descriptor() ([]byte, []int) {
return file_conf_v1_kratos_conf_data_proto_rawDescGZIP(), []int{0, 0}
}
func (x *Data_Database) GetDriver() string {
if x != nil {
return x.Driver
}
return ""
}
func (x *Data_Database) GetSource() string {
if x != nil {
return x.Source
}
return ""
}
func (x *Data_Database) GetMigrate() bool {
if x != nil {
return x.Migrate
}
return false
}
func (x *Data_Database) GetDebug() bool {
if x != nil {
return x.Debug
}
return false
}
func (x *Data_Database) GetMaxIdleConnections() int32 {
if x != nil {
return x.MaxIdleConnections
}
return 0
}
func (x *Data_Database) GetMaxOpenConnections() int32 {
if x != nil {
return x.MaxOpenConnections
}
return 0
}
func (x *Data_Database) GetConnectionMaxLifetime() *durationpb.Duration {
if x != nil {
return x.ConnectionMaxLifetime
}
return nil
}
// redis
type Data_Redis struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Network string `protobuf:"bytes,1,opt,name=network,proto3" json:"network,omitempty"` // 网络
Addr string `protobuf:"bytes,2,opt,name=addr,proto3" json:"addr,omitempty"` // 服务端地址
Password string `protobuf:"bytes,3,opt,name=password,proto3" json:"password,omitempty"` // 密码
Db int32 `protobuf:"varint,4,opt,name=db,proto3" json:"db,omitempty"` // 数据库索引
DialTimeout *durationpb.Duration `protobuf:"bytes,5,opt,name=dial_timeout,json=dialTimeout,proto3" json:"dial_timeout,omitempty"` // 连接超时时间
ReadTimeout *durationpb.Duration `protobuf:"bytes,6,opt,name=read_timeout,json=readTimeout,proto3" json:"read_timeout,omitempty"` // 读取超时时间
WriteTimeout *durationpb.Duration `protobuf:"bytes,7,opt,name=write_timeout,json=writeTimeout,proto3" json:"write_timeout,omitempty"` // 写入超时时间
}
func (x *Data_Redis) Reset() {
*x = Data_Redis{}
if protoimpl.UnsafeEnabled {
mi := &file_conf_v1_kratos_conf_data_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Data_Redis) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Data_Redis) ProtoMessage() {}
func (x *Data_Redis) ProtoReflect() protoreflect.Message {
mi := &file_conf_v1_kratos_conf_data_proto_msgTypes[2]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use Data_Redis.ProtoReflect.Descriptor instead.
func (*Data_Redis) Descriptor() ([]byte, []int) {
return file_conf_v1_kratos_conf_data_proto_rawDescGZIP(), []int{0, 1}
}
func (x *Data_Redis) GetNetwork() string {
if x != nil {
return x.Network
}
return ""
}
func (x *Data_Redis) GetAddr() string {
if x != nil {
return x.Addr
}
return ""
}
func (x *Data_Redis) GetPassword() string {
if x != nil {
return x.Password
}
return ""
}
func (x *Data_Redis) GetDb() int32 {
if x != nil {
return x.Db
}
return 0
}
func (x *Data_Redis) GetDialTimeout() *durationpb.Duration {
if x != nil {
return x.DialTimeout
}
return nil
}
func (x *Data_Redis) GetReadTimeout() *durationpb.Duration {
if x != nil {
return x.ReadTimeout
}
return nil
}
func (x *Data_Redis) GetWriteTimeout() *durationpb.Duration {
if x != nil {
return x.WriteTimeout
}
return nil
}
// MongoDB
type Data_MongoDB struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"`
}
func (x *Data_MongoDB) Reset() {
*x = Data_MongoDB{}
if protoimpl.UnsafeEnabled {
mi := &file_conf_v1_kratos_conf_data_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Data_MongoDB) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Data_MongoDB) ProtoMessage() {}
func (x *Data_MongoDB) ProtoReflect() protoreflect.Message {
mi := &file_conf_v1_kratos_conf_data_proto_msgTypes[3]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use Data_MongoDB.ProtoReflect.Descriptor instead.
func (*Data_MongoDB) Descriptor() ([]byte, []int) {
return file_conf_v1_kratos_conf_data_proto_rawDescGZIP(), []int{0, 2}
}
func (x *Data_MongoDB) GetAddress() string {
if x != nil {
return x.Address
}
return ""
}
// ClickHouse
type Data_ClickHouse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"`
}
func (x *Data_ClickHouse) Reset() {
*x = Data_ClickHouse{}
if protoimpl.UnsafeEnabled {
mi := &file_conf_v1_kratos_conf_data_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Data_ClickHouse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Data_ClickHouse) ProtoMessage() {}
func (x *Data_ClickHouse) ProtoReflect() protoreflect.Message {
mi := &file_conf_v1_kratos_conf_data_proto_msgTypes[4]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use Data_ClickHouse.ProtoReflect.Descriptor instead.
func (*Data_ClickHouse) Descriptor() ([]byte, []int) {
return file_conf_v1_kratos_conf_data_proto_rawDescGZIP(), []int{0, 3}
}
func (x *Data_ClickHouse) GetAddress() string {
if x != nil {
return x.Address
}
return ""
}
// InfluxDB
type Data_InfluxDB struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"`
Token string `protobuf:"bytes,2,opt,name=token,proto3" json:"token,omitempty"`
Orgnization string `protobuf:"bytes,3,opt,name=orgnization,proto3" json:"orgnization,omitempty"`
Bucket string `protobuf:"bytes,4,opt,name=bucket,proto3" json:"bucket,omitempty"`
}
func (x *Data_InfluxDB) Reset() {
*x = Data_InfluxDB{}
if protoimpl.UnsafeEnabled {
mi := &file_conf_v1_kratos_conf_data_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Data_InfluxDB) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Data_InfluxDB) ProtoMessage() {}
func (x *Data_InfluxDB) ProtoReflect() protoreflect.Message {
mi := &file_conf_v1_kratos_conf_data_proto_msgTypes[5]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use Data_InfluxDB.ProtoReflect.Descriptor instead.
func (*Data_InfluxDB) Descriptor() ([]byte, []int) {
return file_conf_v1_kratos_conf_data_proto_rawDescGZIP(), []int{0, 4}
}
func (x *Data_InfluxDB) GetAddress() string {
if x != nil {
return x.Address
}
return ""
}
func (x *Data_InfluxDB) GetToken() string {
if x != nil {
return x.Token
}
return ""
}
func (x *Data_InfluxDB) GetOrgnization() string {
if x != nil {
return x.Orgnization
}
return ""
}
func (x *Data_InfluxDB) GetBucket() string {
if x != nil {
return x.Bucket
}
return ""
}
// Kafka
type Data_Kafka struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Addrs []string `protobuf:"bytes,1,rep,name=addrs,proto3" json:"addrs,omitempty"` // 对端网络地址
Codec string `protobuf:"bytes,2,opt,name=codec,proto3" json:"codec,omitempty"` // 编解码器
}
func (x *Data_Kafka) Reset() {
*x = Data_Kafka{}
if protoimpl.UnsafeEnabled {
mi := &file_conf_v1_kratos_conf_data_proto_msgTypes[6]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Data_Kafka) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Data_Kafka) ProtoMessage() {}
func (x *Data_Kafka) ProtoReflect() protoreflect.Message {
mi := &file_conf_v1_kratos_conf_data_proto_msgTypes[6]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use Data_Kafka.ProtoReflect.Descriptor instead.
func (*Data_Kafka) Descriptor() ([]byte, []int) {
return file_conf_v1_kratos_conf_data_proto_rawDescGZIP(), []int{0, 5}
}
func (x *Data_Kafka) GetAddrs() []string {
if x != nil {
return x.Addrs
}
return nil
}
func (x *Data_Kafka) GetCodec() string {
if x != nil {
return x.Codec
}
return ""
}
type Data_Doris struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"`
}
func (x *Data_Doris) Reset() {
*x = Data_Doris{}
if protoimpl.UnsafeEnabled {
mi := &file_conf_v1_kratos_conf_data_proto_msgTypes[7]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Data_Doris) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Data_Doris) ProtoMessage() {}
func (x *Data_Doris) ProtoReflect() protoreflect.Message {
mi := &file_conf_v1_kratos_conf_data_proto_msgTypes[7]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use Data_Doris.ProtoReflect.Descriptor instead.
func (*Data_Doris) Descriptor() ([]byte, []int) {
return file_conf_v1_kratos_conf_data_proto_rawDescGZIP(), []int{0, 6}
}
func (x *Data_Doris) GetAddress() string {
if x != nil {
return x.Address
}
return ""
}
type Data_ElasticSearch struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"`
}
func (x *Data_ElasticSearch) Reset() {
*x = Data_ElasticSearch{}
if protoimpl.UnsafeEnabled {
mi := &file_conf_v1_kratos_conf_data_proto_msgTypes[8]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Data_ElasticSearch) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Data_ElasticSearch) ProtoMessage() {}
func (x *Data_ElasticSearch) ProtoReflect() protoreflect.Message {
mi := &file_conf_v1_kratos_conf_data_proto_msgTypes[8]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use Data_ElasticSearch.ProtoReflect.Descriptor instead.
func (*Data_ElasticSearch) Descriptor() ([]byte, []int) {
return file_conf_v1_kratos_conf_data_proto_rawDescGZIP(), []int{0, 7}
}
func (x *Data_ElasticSearch) GetAddress() string {
if x != nil {
return x.Address
}
return ""
}
var File_conf_v1_kratos_conf_data_proto protoreflect.FileDescriptor
var file_conf_v1_kratos_conf_data_proto_rawDesc = []byte{
0x0a, 0x1e, 0x63, 0x6f, 0x6e, 0x66, 0x2f, 0x76, 0x31, 0x2f, 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73,
0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x12, 0x04, 0x63, 0x6f, 0x6e, 0x66, 0x1a, 0x1e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e,
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x90, 0x0a, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, 0x12,
0x2f, 0x0a, 0x08, 0x64, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28,
0x0b, 0x32, 0x13, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x2e, 0x44, 0x61,
0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x52, 0x08, 0x64, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65,
0x12, 0x26, 0x0a, 0x05, 0x72, 0x65, 0x64, 0x69, 0x73, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0b, 0x32,
0x10, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x2e, 0x52, 0x65, 0x64, 0x69,
0x73, 0x52, 0x05, 0x72, 0x65, 0x64, 0x69, 0x73, 0x12, 0x2c, 0x0a, 0x07, 0x6d, 0x6f, 0x6e, 0x67,
0x6f, 0x64, 0x62, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x63, 0x6f, 0x6e, 0x66,
0x2e, 0x44, 0x61, 0x74, 0x61, 0x2e, 0x4d, 0x6f, 0x6e, 0x67, 0x6f, 0x44, 0x42, 0x52, 0x07, 0x6d,
0x6f, 0x6e, 0x67, 0x6f, 0x64, 0x62, 0x12, 0x3f, 0x0a, 0x0e, 0x65, 0x6c, 0x61, 0x73, 0x74, 0x69,
0x63, 0x5f, 0x73, 0x65, 0x61, 0x72, 0x63, 0x68, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18,
0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x2e, 0x45, 0x6c, 0x61, 0x73, 0x74,
0x69, 0x63, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x52, 0x0d, 0x65, 0x6c, 0x61, 0x73, 0x74, 0x69,
0x63, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x12, 0x35, 0x0a, 0x0a, 0x63, 0x6c, 0x69, 0x63, 0x6b,
0x68, 0x6f, 0x75, 0x73, 0x65, 0x18, 0x14, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x63, 0x6f,
0x6e, 0x66, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x2e, 0x43, 0x6c, 0x69, 0x63, 0x6b, 0x48, 0x6f, 0x75,
0x73, 0x65, 0x52, 0x0a, 0x63, 0x6c, 0x69, 0x63, 0x6b, 0x68, 0x6f, 0x75, 0x73, 0x65, 0x12, 0x2f,
0x0a, 0x08, 0x69, 0x6e, 0x66, 0x6c, 0x75, 0x78, 0x64, 0x62, 0x18, 0x15, 0x20, 0x01, 0x28, 0x0b,
0x32, 0x13, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x2e, 0x49, 0x6e, 0x66,
0x6c, 0x75, 0x78, 0x44, 0x42, 0x52, 0x08, 0x69, 0x6e, 0x66, 0x6c, 0x75, 0x78, 0x64, 0x62, 0x12,
0x26, 0x0a, 0x05, 0x64, 0x6f, 0x72, 0x69, 0x73, 0x18, 0x16, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10,
0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x2e, 0x44, 0x6f, 0x72, 0x69, 0x73,
0x52, 0x05, 0x64, 0x6f, 0x72, 0x69, 0x73, 0x12, 0x26, 0x0a, 0x05, 0x6b, 0x61, 0x66, 0x6b, 0x61,
0x18, 0x1e, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x2e, 0x44, 0x61,
0x74, 0x61, 0x2e, 0x4b, 0x61, 0x66, 0x6b, 0x61, 0x52, 0x05, 0x6b, 0x61, 0x66, 0x6b, 0x61, 0x1a,
0xa1, 0x02, 0x0a, 0x08, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x12, 0x16, 0x0a, 0x06,
0x64, 0x72, 0x69, 0x76, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x64, 0x72,
0x69, 0x76, 0x65, 0x72, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x18, 0x02,
0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x12, 0x18, 0x0a, 0x07,
0x6d, 0x69, 0x67, 0x72, 0x61, 0x74, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x6d,
0x69, 0x67, 0x72, 0x61, 0x74, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x64, 0x65, 0x62, 0x75, 0x67, 0x18,
0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x64, 0x65, 0x62, 0x75, 0x67, 0x12, 0x30, 0x0a, 0x14,
0x6d, 0x61, 0x78, 0x5f, 0x69, 0x64, 0x6c, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74,
0x69, 0x6f, 0x6e, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x12, 0x6d, 0x61, 0x78, 0x49,
0x64, 0x6c, 0x65, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x30,
0x0a, 0x14, 0x6d, 0x61, 0x78, 0x5f, 0x6f, 0x70, 0x65, 0x6e, 0x5f, 0x63, 0x6f, 0x6e, 0x6e, 0x65,
0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, 0x12, 0x6d, 0x61,
0x78, 0x4f, 0x70, 0x65, 0x6e, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73,
0x12, 0x51, 0x0a, 0x17, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x6d,
0x61, 0x78, 0x5f, 0x6c, 0x69, 0x66, 0x65, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28,
0x0b, 0x32, 0x19, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x62, 0x75, 0x66, 0x2e, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x15, 0x63, 0x6f,
0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x4d, 0x61, 0x78, 0x4c, 0x69, 0x66, 0x65, 0x74,
0x69, 0x6d, 0x65, 0x1a, 0x9d, 0x02, 0x0a, 0x05, 0x52, 0x65, 0x64, 0x69, 0x73, 0x12, 0x18, 0x0a,
0x07, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07,
0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x12, 0x12, 0x0a, 0x04, 0x61, 0x64, 0x64, 0x72, 0x18,
0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x61, 0x64, 0x64, 0x72, 0x12, 0x1a, 0x0a, 0x08, 0x70,
0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70,
0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x12, 0x0e, 0x0a, 0x02, 0x64, 0x62, 0x18, 0x04, 0x20,
0x01, 0x28, 0x05, 0x52, 0x02, 0x64, 0x62, 0x12, 0x3c, 0x0a, 0x0c, 0x64, 0x69, 0x61, 0x6c, 0x5f,
0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e,
0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e,
0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0b, 0x64, 0x69, 0x61, 0x6c, 0x54, 0x69,
0x6d, 0x65, 0x6f, 0x75, 0x74, 0x12, 0x3c, 0x0a, 0x0c, 0x72, 0x65, 0x61, 0x64, 0x5f, 0x74, 0x69,
0x6d, 0x65, 0x6f, 0x75, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x67, 0x6f,
0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, 0x75,
0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0b, 0x72, 0x65, 0x61, 0x64, 0x54, 0x69, 0x6d, 0x65,
0x6f, 0x75, 0x74, 0x12, 0x3e, 0x0a, 0x0d, 0x77, 0x72, 0x69, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d,
0x65, 0x6f, 0x75, 0x74, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x67, 0x6f, 0x6f,
0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, 0x75, 0x72,
0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0c, 0x77, 0x72, 0x69, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65,
0x6f, 0x75, 0x74, 0x1a, 0x23, 0x0a, 0x07, 0x4d, 0x6f, 0x6e, 0x67, 0x6f, 0x44, 0x42, 0x12, 0x18,
0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x1a, 0x26, 0x0a, 0x0a, 0x43, 0x6c, 0x69, 0x63,
0x6b, 0x48, 0x6f, 0x75, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73,
0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73,
0x1a, 0x74, 0x0a, 0x08, 0x49, 0x6e, 0x66, 0x6c, 0x75, 0x78, 0x44, 0x42, 0x12, 0x18, 0x0a, 0x07,
0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61,
0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18,
0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x20, 0x0a, 0x0b,
0x6f, 0x72, 0x67, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28,
0x09, 0x52, 0x0b, 0x6f, 0x72, 0x67, 0x6e, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x16,
0x0a, 0x06, 0x62, 0x75, 0x63, 0x6b, 0x65, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06,
0x62, 0x75, 0x63, 0x6b, 0x65, 0x74, 0x1a, 0x33, 0x0a, 0x05, 0x4b, 0x61, 0x66, 0x6b, 0x61, 0x12,
0x14, 0x0a, 0x05, 0x61, 0x64, 0x64, 0x72, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x05,
0x61, 0x64, 0x64, 0x72, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x6f, 0x64, 0x65, 0x63, 0x18, 0x02,
0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x63, 0x6f, 0x64, 0x65, 0x63, 0x1a, 0x21, 0x0a, 0x05, 0x44,
0x6f, 0x72, 0x69, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18,
0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x1a, 0x29,
0x0a, 0x0d, 0x45, 0x6c, 0x61, 0x73, 0x74, 0x69, 0x63, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x12,
0x18, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09,
0x52, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x42, 0x85, 0x01, 0x0a, 0x08, 0x63, 0x6f,
0x6d, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x42, 0x13, 0x4b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x43, 0x6f,
0x6e, 0x66, 0x44, 0x61, 0x74, 0x61, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x34, 0x67,
0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x74, 0x78, 0x37, 0x64, 0x6f, 0x2f,
0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2d, 0x62, 0x6f, 0x6f, 0x74, 0x73, 0x74, 0x72, 0x61, 0x70,
0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x67, 0x6f, 0x2f, 0x63, 0x6f, 0x6e, 0x66,
0x2f, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x58, 0x58, 0xaa, 0x02, 0x04, 0x43, 0x6f, 0x6e, 0x66,
0xca, 0x02, 0x04, 0x43, 0x6f, 0x6e, 0x66, 0xe2, 0x02, 0x10, 0x43, 0x6f, 0x6e, 0x66, 0x5c, 0x47,
0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x04, 0x43, 0x6f, 0x6e,
0x66, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
file_conf_v1_kratos_conf_data_proto_rawDescOnce sync.Once
file_conf_v1_kratos_conf_data_proto_rawDescData = file_conf_v1_kratos_conf_data_proto_rawDesc
)
func file_conf_v1_kratos_conf_data_proto_rawDescGZIP() []byte {
file_conf_v1_kratos_conf_data_proto_rawDescOnce.Do(func() {
file_conf_v1_kratos_conf_data_proto_rawDescData = protoimpl.X.CompressGZIP(file_conf_v1_kratos_conf_data_proto_rawDescData)
})
return file_conf_v1_kratos_conf_data_proto_rawDescData
}
var file_conf_v1_kratos_conf_data_proto_msgTypes = make([]protoimpl.MessageInfo, 9)
var file_conf_v1_kratos_conf_data_proto_goTypes = []interface{}{
(*Data)(nil), // 0: conf.Data
(*Data_Database)(nil), // 1: conf.Data.Database
(*Data_Redis)(nil), // 2: conf.Data.Redis
(*Data_MongoDB)(nil), // 3: conf.Data.MongoDB
(*Data_ClickHouse)(nil), // 4: conf.Data.ClickHouse
(*Data_InfluxDB)(nil), // 5: conf.Data.InfluxDB
(*Data_Kafka)(nil), // 6: conf.Data.Kafka
(*Data_Doris)(nil), // 7: conf.Data.Doris
(*Data_ElasticSearch)(nil), // 8: conf.Data.ElasticSearch
(*durationpb.Duration)(nil), // 9: google.protobuf.Duration
}
var file_conf_v1_kratos_conf_data_proto_depIdxs = []int32{
1, // 0: conf.Data.database:type_name -> conf.Data.Database
2, // 1: conf.Data.redis:type_name -> conf.Data.Redis
3, // 2: conf.Data.mongodb:type_name -> conf.Data.MongoDB
8, // 3: conf.Data.elastic_search:type_name -> conf.Data.ElasticSearch
4, // 4: conf.Data.clickhouse:type_name -> conf.Data.ClickHouse
5, // 5: conf.Data.influxdb:type_name -> conf.Data.InfluxDB
7, // 6: conf.Data.doris:type_name -> conf.Data.Doris
6, // 7: conf.Data.kafka:type_name -> conf.Data.Kafka
9, // 8: conf.Data.Database.connection_max_lifetime:type_name -> google.protobuf.Duration
9, // 9: conf.Data.Redis.dial_timeout:type_name -> google.protobuf.Duration
9, // 10: conf.Data.Redis.read_timeout:type_name -> google.protobuf.Duration
9, // 11: conf.Data.Redis.write_timeout:type_name -> google.protobuf.Duration
12, // [12:12] is the sub-list for method output_type
12, // [12:12] is the sub-list for method input_type
12, // [12:12] is the sub-list for extension type_name
12, // [12:12] is the sub-list for extension extendee
0, // [0:12] is the sub-list for field type_name
}
func init() { file_conf_v1_kratos_conf_data_proto_init() }
func file_conf_v1_kratos_conf_data_proto_init() {
if File_conf_v1_kratos_conf_data_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_conf_v1_kratos_conf_data_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Data); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_conf_v1_kratos_conf_data_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Data_Database); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_conf_v1_kratos_conf_data_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Data_Redis); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_conf_v1_kratos_conf_data_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Data_MongoDB); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_conf_v1_kratos_conf_data_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Data_ClickHouse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_conf_v1_kratos_conf_data_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Data_InfluxDB); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_conf_v1_kratos_conf_data_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Data_Kafka); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_conf_v1_kratos_conf_data_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Data_Doris); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_conf_v1_kratos_conf_data_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Data_ElasticSearch); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_conf_v1_kratos_conf_data_proto_rawDesc,
NumEnums: 0,
NumMessages: 9,
NumExtensions: 0,
NumServices: 0,
},
GoTypes: file_conf_v1_kratos_conf_data_proto_goTypes,
DependencyIndexes: file_conf_v1_kratos_conf_data_proto_depIdxs,
MessageInfos: file_conf_v1_kratos_conf_data_proto_msgTypes,
}.Build()
File_conf_v1_kratos_conf_data_proto = out.File
file_conf_v1_kratos_conf_data_proto_rawDesc = nil
file_conf_v1_kratos_conf_data_proto_goTypes = nil
file_conf_v1_kratos_conf_data_proto_depIdxs = nil
}

190
go.mod
View File

@@ -1,191 +1,5 @@
module github.com/tx7do/kratos-bootstrap
go 1.20
go 1.23
require (
github.com/go-chassis/sc-client v0.7.0
github.com/go-kratos/aegis v0.2.0
github.com/go-kratos/kratos/contrib/config/apollo/v2 v2.0.0-20231023125239-6cdd81811e10
github.com/go-kratos/kratos/contrib/config/consul/v2 v2.0.0-20231102162905-3fc8fb7a0a0b
github.com/go-kratos/kratos/contrib/config/etcd/v2 v2.0.0-20231102162905-3fc8fb7a0a0b
github.com/go-kratos/kratos/contrib/config/kubernetes/v2 v2.0.0-20231023125239-6cdd81811e10
github.com/go-kratos/kratos/contrib/config/nacos/v2 v2.0.0-20231023125239-6cdd81811e10
github.com/go-kratos/kratos/contrib/log/aliyun/v2 v2.0.0-20231023125239-6cdd81811e10
github.com/go-kratos/kratos/contrib/log/fluent/v2 v2.0.0-20231023125239-6cdd81811e10
github.com/go-kratos/kratos/contrib/log/logrus/v2 v2.0.0-20231023125239-6cdd81811e10
github.com/go-kratos/kratos/contrib/log/tencent/v2 v2.0.0-20231023125239-6cdd81811e10
github.com/go-kratos/kratos/contrib/log/zap/v2 v2.0.0-20231023125239-6cdd81811e10
github.com/go-kratos/kratos/contrib/registry/consul/v2 v2.0.0-20231102162905-3fc8fb7a0a0b
github.com/go-kratos/kratos/contrib/registry/etcd/v2 v2.0.0-20231023125239-6cdd81811e10
github.com/go-kratos/kratos/contrib/registry/eureka/v2 v2.0.0-20231023125239-6cdd81811e10
github.com/go-kratos/kratos/contrib/registry/kubernetes/v2 v2.0.0-20231023125239-6cdd81811e10
github.com/go-kratos/kratos/contrib/registry/nacos/v2 v2.0.0-20231023125239-6cdd81811e10
github.com/go-kratos/kratos/contrib/registry/servicecomb/v2 v2.0.0-20231023125239-6cdd81811e10
github.com/go-kratos/kratos/contrib/registry/zookeeper/v2 v2.0.0-20231023125239-6cdd81811e10
github.com/go-kratos/kratos/v2 v2.7.1
github.com/go-redis/redis/extra/redisotel/v8 v8.11.5
github.com/go-redis/redis/v8 v8.11.5
github.com/go-zookeeper/zk v1.0.3
github.com/google/gnostic v0.5.7-v3refs
github.com/google/subcommands v1.2.0
github.com/gorilla/handlers v1.5.1
github.com/hashicorp/consul/api v1.26.1
github.com/minio/minio-go/v7 v7.0.63
github.com/nacos-group/nacos-sdk-go v1.1.4
github.com/olekukonko/tablewriter v0.0.5
github.com/sirupsen/logrus v1.9.3
github.com/spf13/cobra v1.7.0
github.com/stretchr/testify v1.8.4
go.etcd.io/etcd/client/v3 v3.5.10
go.opentelemetry.io/otel v1.19.0
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.19.0
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.19.0
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.19.0
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.19.0
go.opentelemetry.io/otel/exporters/zipkin v1.19.0
go.opentelemetry.io/otel/sdk v1.19.0
go.uber.org/zap v1.26.0
golang.org/x/tools v0.14.0
google.golang.org/grpc v1.59.0
google.golang.org/protobuf v1.31.0
gopkg.in/natefinch/lumberjack.v2 v2.2.1
k8s.io/client-go v0.28.3
)
require (
github.com/aliyun/alibaba-cloud-sdk-go v1.62.589 // indirect
github.com/aliyun/aliyun-log-go-sdk v0.1.64 // indirect
github.com/apolloconfig/agollo/v4 v4.3.1 // indirect
github.com/armon/go-metrics v0.4.1 // indirect
github.com/buger/jsonparser v1.1.1 // indirect
github.com/cenkalti/backoff v2.2.1+incompatible // indirect
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/coreos/go-semver v0.3.1 // indirect
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/deckarep/golang-set v1.8.0 // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
github.com/fatih/color v1.15.0 // indirect
github.com/felixge/httpsnoop v1.0.3 // indirect
github.com/fluent/fluent-logger-golang v1.9.0 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/go-chassis/cari v0.9.0 // indirect
github.com/go-chassis/foundation v0.4.0 // indirect
github.com/go-chassis/openlog v1.1.3 // indirect
github.com/go-errors/errors v1.5.1 // indirect
github.com/go-kit/kit v0.13.0 // indirect
github.com/go-kit/log v0.2.1 // indirect
github.com/go-logfmt/logfmt v0.6.0 // indirect
github.com/go-logr/logr v1.3.0 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/go-openapi/jsonpointer v0.20.0 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/swag v0.22.4 // indirect
github.com/go-playground/form/v4 v4.2.1 // indirect
github.com/go-redis/redis/extra/rediscmd/v8 v8.11.5 // indirect
github.com/gofrs/uuid v4.4.0+incompatible // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/mock v1.6.0 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/gnostic-models v0.6.9-0.20230804172637-c7be7c783f49 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/uuid v1.3.1 // indirect
github.com/gorilla/mux v1.8.0 // indirect
github.com/gorilla/websocket v1.5.1 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.18.0 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-hclog v1.5.0 // indirect
github.com/hashicorp/go-immutable-radix v1.3.1 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/go-rootcerts v1.0.2 // indirect
github.com/hashicorp/golang-lru v1.0.2 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/hashicorp/serf v0.10.1 // indirect
github.com/imdario/mergo v0.3.16 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/karlseguin/ccache/v2 v2.0.8 // indirect
github.com/klauspost/compress v1.17.2 // indirect
github.com/klauspost/cpuid/v2 v2.2.5 // indirect
github.com/lufia/plan9stats v0.0.0-20230326075908-cb1d2100619a // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-runewidth v0.0.15 // indirect
github.com/minio/md5-simd v1.1.2 // indirect
github.com/minio/sha256-simd v1.0.1 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/opentracing/opentracing-go v1.2.1-0.20220228012449-10b1cf09e00b // indirect
github.com/openzipkin/zipkin-go v0.4.2 // indirect
github.com/patrickmn/go-cache v2.1.0+incompatible // indirect
github.com/pelletier/go-toml/v2 v2.1.0 // indirect
github.com/philhofer/fwd v1.1.2 // indirect
github.com/pierrec/lz4 v2.6.1+incompatible // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/power-devops/perfstat v0.0.0-20221212215047-62379fc7944b // indirect
github.com/rivo/uniseg v0.4.4 // indirect
github.com/rs/xid v1.5.0 // indirect
github.com/sagikazarmark/locafero v0.3.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/shirou/gopsutil/v3 v3.23.6 // indirect
github.com/shoenig/go-m1cpu v0.1.6 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/afero v1.10.0 // indirect
github.com/spf13/cast v1.5.1 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/viper v1.17.0 // indirect
github.com/stretchr/objx v0.5.1 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/tencentcloud/tencentcloud-cls-sdk-go v1.0.6 // indirect
github.com/tinylib/msgp v1.1.8 // indirect
github.com/tklauser/go-sysconf v0.3.11 // indirect
github.com/tklauser/numcpus v0.6.1 // indirect
github.com/yusufpapurcu/wmi v1.2.3 // indirect
go.etcd.io/etcd/api/v3 v3.5.10 // indirect
go.etcd.io/etcd/client/pkg/v3 v3.5.10 // indirect
go.opentelemetry.io/otel/metric v1.19.0 // indirect
go.opentelemetry.io/otel/trace v1.19.0 // indirect
go.opentelemetry.io/proto/otlp v1.0.0 // indirect
go.uber.org/atomic v1.11.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/crypto v0.14.0 // indirect
golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect
golang.org/x/mod v0.13.0 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/oauth2 v0.13.0 // indirect
golang.org/x/sync v0.4.0 // indirect
golang.org/x/sys v0.14.0 // indirect
golang.org/x/term v0.13.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/time v0.3.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto v0.0.0-20231030173426-d783a09b4405 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20231030173426-d783a09b4405 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231030173426-d783a09b4405 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/api v0.28.3 // indirect
k8s.io/apimachinery v0.28.3 // indirect
k8s.io/klog/v2 v2.100.1 // indirect
k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 // indirect
k8s.io/utils v0.0.0-20230726121419-3b25d923346b // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.3.0 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
)
toolchain go1.23.2

1412
go.sum

File diff suppressed because it is too large Load Diff

109
grpc.go
View File

@@ -1,109 +0,0 @@
package bootstrap
import (
"context"
"time"
"google.golang.org/grpc"
"github.com/go-kratos/aegis/ratelimit"
"github.com/go-kratos/aegis/ratelimit/bbr"
"github.com/go-kratos/kratos/v2/log"
"github.com/go-kratos/kratos/v2/registry"
"github.com/go-kratos/kratos/v2/middleware"
midRateLimit "github.com/go-kratos/kratos/v2/middleware/ratelimit"
"github.com/go-kratos/kratos/v2/middleware/recovery"
"github.com/go-kratos/kratos/v2/middleware/tracing"
"github.com/go-kratos/kratos/v2/middleware/validate"
kratosGrpc "github.com/go-kratos/kratos/v2/transport/grpc"
conf "github.com/tx7do/kratos-bootstrap/gen/api/go/conf/v1"
)
const defaultTimeout = 5 * time.Second
// CreateGrpcClient 创建GRPC客户端
func CreateGrpcClient(ctx context.Context, r registry.Discovery, serviceName string, cfg *conf.Bootstrap, m ...middleware.Middleware) grpc.ClientConnInterface {
endpoint := "discovery:///" + serviceName
var ms []middleware.Middleware
timeout := defaultTimeout
if cfg.Client != nil && cfg.Client.Grpc != nil {
if cfg.Client.Grpc.Timeout != nil {
timeout = cfg.Client.Grpc.Timeout.AsDuration()
}
if cfg.Client.Grpc.Middleware != nil {
if cfg.Client.Grpc.Middleware.GetEnableRecovery() {
ms = append(ms, recovery.Recovery())
}
if cfg.Client.Grpc.Middleware.GetEnableTracing() {
ms = append(ms, tracing.Client())
}
if cfg.Client.Grpc.Middleware.GetEnableValidate() {
ms = append(ms, validate.Validator())
}
}
}
ms = append(ms, m...)
conn, err := kratosGrpc.DialInsecure(
ctx,
kratosGrpc.WithEndpoint(endpoint),
kratosGrpc.WithDiscovery(r),
kratosGrpc.WithTimeout(timeout),
kratosGrpc.WithMiddleware(ms...),
)
if err != nil {
log.Fatalf("dial grpc client [%s] failed: %s", serviceName, err.Error())
}
return conn
}
// CreateGrpcServer 创建GRPC服务端
func CreateGrpcServer(cfg *conf.Bootstrap, m ...middleware.Middleware) *kratosGrpc.Server {
var opts []kratosGrpc.ServerOption
var ms []middleware.Middleware
if cfg.Server != nil && cfg.Server.Grpc != nil && cfg.Server.Grpc.Middleware != nil {
if cfg.Server.Grpc.Middleware.GetEnableRecovery() {
ms = append(ms, recovery.Recovery())
}
if cfg.Server.Grpc.Middleware.GetEnableTracing() {
ms = append(ms, tracing.Server())
}
if cfg.Server.Grpc.Middleware.GetEnableValidate() {
ms = append(ms, validate.Validator())
}
if cfg.Server.Grpc.Middleware.GetEnableCircuitBreaker() {
}
if cfg.Server.Grpc.Middleware.Limiter != nil {
var limiter ratelimit.Limiter
switch cfg.Server.Grpc.Middleware.Limiter.GetName() {
case "bbr":
limiter = bbr.NewLimiter()
}
ms = append(ms, midRateLimit.Server(midRateLimit.WithLimiter(limiter)))
}
}
ms = append(ms, m...)
opts = append(opts, kratosGrpc.Middleware(ms...))
if cfg.Server.Grpc.Network != "" {
opts = append(opts, kratosGrpc.Network(cfg.Server.Grpc.Network))
}
if cfg.Server.Grpc.Addr != "" {
opts = append(opts, kratosGrpc.Address(cfg.Server.Grpc.Addr))
}
if cfg.Server.Grpc.Timeout != nil {
opts = append(opts, kratosGrpc.Timeout(cfg.Server.Grpc.Timeout.AsDuration()))
}
srv := kratosGrpc.NewServer(opts...)
return srv
}

179
logger.go
View File

@@ -1,179 +0,0 @@
package bootstrap
import (
"os"
"github.com/sirupsen/logrus"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
"gopkg.in/natefinch/lumberjack.v2"
aliyunLogger "github.com/go-kratos/kratos/contrib/log/aliyun/v2"
fluentLogger "github.com/go-kratos/kratos/contrib/log/fluent/v2"
logrusLogger "github.com/go-kratos/kratos/contrib/log/logrus/v2"
tencentLogger "github.com/go-kratos/kratos/contrib/log/tencent/v2"
zapLogger "github.com/go-kratos/kratos/contrib/log/zap/v2"
"github.com/go-kratos/kratos/v2/log"
"github.com/go-kratos/kratos/v2/middleware/tracing"
conf "github.com/tx7do/kratos-bootstrap/gen/api/go/conf/v1"
)
type LoggerType string
const (
LoggerTypeStd LoggerType = "std"
LoggerTypeFluent LoggerType = "fluent"
LoggerTypeLogrus LoggerType = "logrus"
LoggerTypeZap LoggerType = "zap"
LoggerTypeAliyun LoggerType = "aliyun"
LoggerTypeTencent LoggerType = "tencent"
)
// NewLoggerProvider 创建一个新的日志记录器提供者
func NewLoggerProvider(cfg *conf.Logger, serviceInfo *ServiceInfo) log.Logger {
l := NewLogger(cfg)
return log.With(
l,
"service.id", serviceInfo.Id,
"service.name", serviceInfo.Name,
"service.version", serviceInfo.Version,
"ts", log.DefaultTimestamp,
"caller", log.DefaultCaller,
"trace_id", tracing.TraceID(),
"span_id", tracing.SpanID(),
)
}
// NewLogger 创建一个新的日志记录器
func NewLogger(cfg *conf.Logger) log.Logger {
if cfg == nil {
return NewStdLogger()
}
switch LoggerType(cfg.Type) {
default:
fallthrough
case LoggerTypeStd:
return NewStdLogger()
case LoggerTypeFluent:
return NewFluentLogger(cfg)
case LoggerTypeZap:
return NewZapLogger(cfg)
case LoggerTypeLogrus:
return NewLogrusLogger(cfg)
case LoggerTypeAliyun:
return NewAliyunLogger(cfg)
case LoggerTypeTencent:
return NewTencentLogger(cfg)
}
}
// NewStdLogger 创建一个新的日志记录器 - Kratos内置控制台输出
func NewStdLogger() log.Logger {
l := log.NewStdLogger(os.Stdout)
return l
}
// NewZapLogger 创建一个新的日志记录器 - Zap
func NewZapLogger(cfg *conf.Logger) log.Logger {
encoderConfig := zap.NewProductionEncoderConfig()
encoderConfig.EncodeTime = zapcore.ISO8601TimeEncoder
encoderConfig.TimeKey = "time"
encoderConfig.EncodeLevel = zapcore.CapitalLevelEncoder
encoderConfig.EncodeDuration = zapcore.SecondsDurationEncoder
encoderConfig.EncodeCaller = zapcore.ShortCallerEncoder
jsonEncoder := zapcore.NewJSONEncoder(encoderConfig)
lumberJackLogger := &lumberjack.Logger{
Filename: cfg.Zap.Filename,
MaxSize: int(cfg.Zap.MaxSize),
MaxBackups: int(cfg.Zap.MaxBackups),
MaxAge: int(cfg.Zap.MaxAge),
}
writeSyncer := zapcore.AddSync(lumberJackLogger)
var lvl = new(zapcore.Level)
if err := lvl.UnmarshalText([]byte(cfg.Zap.Level)); err != nil {
return nil
}
core := zapcore.NewCore(jsonEncoder, writeSyncer, lvl)
logger := zap.New(core).WithOptions()
wrapped := zapLogger.NewLogger(logger)
return wrapped
}
// NewLogrusLogger 创建一个新的日志记录器 - Logrus
func NewLogrusLogger(cfg *conf.Logger) log.Logger {
loggerLevel, err := logrus.ParseLevel(cfg.Logrus.Level)
if err != nil {
loggerLevel = logrus.InfoLevel
}
var loggerFormatter logrus.Formatter
switch cfg.Logrus.Formatter {
default:
fallthrough
case "text":
loggerFormatter = &logrus.TextFormatter{
DisableColors: cfg.Logrus.DisableColors,
DisableTimestamp: cfg.Logrus.DisableTimestamp,
TimestampFormat: cfg.Logrus.TimestampFormat,
}
break
case "json":
loggerFormatter = &logrus.JSONFormatter{
DisableTimestamp: cfg.Logrus.DisableTimestamp,
TimestampFormat: cfg.Logrus.TimestampFormat,
}
break
}
logger := logrus.New()
logger.Level = loggerLevel
logger.Formatter = loggerFormatter
wrapped := logrusLogger.NewLogger(logger)
return wrapped
}
// NewFluentLogger 创建一个新的日志记录器 - Fluent
func NewFluentLogger(cfg *conf.Logger) log.Logger {
wrapped, err := fluentLogger.NewLogger(cfg.Fluent.Endpoint)
if err != nil {
panic("create fluent logger failed")
return nil
}
return wrapped
}
// NewAliyunLogger 创建一个新的日志记录器 - Aliyun
func NewAliyunLogger(cfg *conf.Logger) log.Logger {
wrapped := aliyunLogger.NewAliyunLog(
aliyunLogger.WithProject(cfg.Aliyun.Project),
aliyunLogger.WithEndpoint(cfg.Aliyun.Endpoint),
aliyunLogger.WithAccessKey(cfg.Aliyun.AccessKey),
aliyunLogger.WithAccessSecret(cfg.Aliyun.AccessSecret),
)
return wrapped
}
// NewTencentLogger 创建一个新的日志记录器 - Tencent
func NewTencentLogger(cfg *conf.Logger) log.Logger {
wrapped, err := tencentLogger.NewLogger(
tencentLogger.WithTopicID(cfg.Tencent.TopicId),
tencentLogger.WithEndpoint(cfg.Tencent.Endpoint),
tencentLogger.WithAccessKey(cfg.Tencent.AccessKey),
tencentLogger.WithAccessSecret(cfg.Tencent.AccessSecret),
)
if err != nil {
panic(err)
return nil
}
return wrapped
}

23
logger/aliyun/client.go Normal file
View File

@@ -0,0 +1,23 @@
package aliyun
import (
aliyunLogger "github.com/go-kratos/kratos/contrib/log/aliyun/v2"
"github.com/go-kratos/kratos/v2/log"
conf "github.com/tx7do/kratos-bootstrap/api/gen/go/conf/v1"
)
// NewLogger 创建一个新的日志记录器 - Aliyun
func NewLogger(cfg *conf.Logger) log.Logger {
if cfg == nil || cfg.Aliyun == nil {
return nil
}
wrapped := aliyunLogger.NewAliyunLog(
aliyunLogger.WithProject(cfg.Aliyun.Project),
aliyunLogger.WithEndpoint(cfg.Aliyun.Endpoint),
aliyunLogger.WithAccessKey(cfg.Aliyun.AccessKey),
aliyunLogger.WithAccessSecret(cfg.Aliyun.AccessSecret),
)
return wrapped
}

22
logger/fluent/client.go Normal file
View File

@@ -0,0 +1,22 @@
package fluent
import (
fluentLogger "github.com/go-kratos/kratos/contrib/log/fluent/v2"
"github.com/go-kratos/kratos/v2/log"
conf "github.com/tx7do/kratos-bootstrap/api/gen/go/conf/v1"
)
// NewLogger 创建一个新的日志记录器 - Fluent
func NewLogger(cfg *conf.Logger) log.Logger {
if cfg == nil || cfg.Fluent == nil {
return nil
}
wrapped, err := fluentLogger.NewLogger(cfg.Fluent.Endpoint)
if err != nil {
panic("create fluent logger failed")
return nil
}
return wrapped
}

68
logger/go.mod Normal file
View File

@@ -0,0 +1,68 @@
module github.com/tx7do/kratos-bootstrap/logger
go 1.23
toolchain go1.23.2
replace (
github.com/armon/go-metrics => github.com/hashicorp/go-metrics v0.4.1
github.com/imdario/mergo => dario.cat/mergo v0.3.16
github.com/tx7do/kratos-bootstrap/api => ../api
github.com/tx7do/kratos-bootstrap/utils => ../utils
)
require (
github.com/go-kratos/kratos/contrib/log/aliyun/v2 v2.0.0-20241105072421-f8b97f675b32
github.com/go-kratos/kratos/contrib/log/fluent/v2 v2.0.0-20241105072421-f8b97f675b32
github.com/go-kratos/kratos/contrib/log/logrus/v2 v2.0.0-20241105072421-f8b97f675b32
github.com/go-kratos/kratos/contrib/log/tencent/v2 v2.0.0-20241105072421-f8b97f675b32
github.com/go-kratos/kratos/contrib/log/zap/v2 v2.0.0-20241105072421-f8b97f675b32
github.com/go-kratos/kratos/v2 v2.8.2
github.com/sirupsen/logrus v1.9.3
github.com/tx7do/kratos-bootstrap/api v0.0.7
github.com/tx7do/kratos-bootstrap/utils v0.1.0
go.uber.org/zap v1.27.0
gopkg.in/natefinch/lumberjack.v2 v2.2.1
)
require (
github.com/aliyun/aliyun-log-go-sdk v0.1.84 // indirect
github.com/cenkalti/backoff v2.2.1+incompatible // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/fluent/fluent-logger-golang v1.9.0 // indirect
github.com/go-kit/kit v0.13.0 // indirect
github.com/go-kit/log v0.2.1 // indirect
github.com/go-kratos/aegis v0.2.0 // indirect
github.com/go-logfmt/logfmt v0.6.0 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-playground/form/v4 v4.2.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/gorilla/mux v1.8.1 // indirect
github.com/klauspost/compress v1.17.11 // indirect
github.com/philhofer/fwd v1.1.3-0.20240916144458-20a13a1f6b7c // indirect
github.com/pierrec/lz4 v2.6.1+incompatible // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/rogpeppe/go-internal v1.13.1 // indirect
github.com/tencentcloud/tencentcloud-cls-sdk-go v1.0.11 // indirect
github.com/tinylib/msgp v1.2.4 // indirect
go.opentelemetry.io/otel v1.32.0 // indirect
go.opentelemetry.io/otel/metric v1.32.0 // indirect
go.opentelemetry.io/otel/sdk v1.32.0 // indirect
go.opentelemetry.io/otel/trace v1.32.0 // indirect
go.uber.org/atomic v1.11.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/net v0.31.0 // indirect
golang.org/x/sync v0.9.0 // indirect
golang.org/x/sys v0.27.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20241113202542-65e8d215514f // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20241113202542-65e8d215514f // indirect
google.golang.org/grpc v1.68.0 // indirect
google.golang.org/protobuf v1.35.1 // indirect
gopkg.in/ini.v1 v1.66.4 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

203
logger/go.sum Normal file
View File

@@ -0,0 +1,203 @@
github.com/Netflix/go-env v0.0.0-20220526054621-78278af1949d h1:wvStE9wLpws31NiWUx+38wny1msZ/tm+eL5xmm4Y7So=
github.com/Netflix/go-env v0.0.0-20220526054621-78278af1949d/go.mod h1:9XMFaCeRyW7fC9XJOWQ+NdAv8VLG7ys7l3x4ozEGLUQ=
github.com/alibabacloud-go/alibabacloud-gateway-spi v0.0.4 h1:iC9YFYKDGEy3n/FtqJnOkZsene9olVspKmkX5A2YBEo=
github.com/alibabacloud-go/alibabacloud-gateway-spi v0.0.4/go.mod h1:sCavSAvdzOjul4cEqeVtvlSaSScfNsTQ+46HwlTL1hc=
github.com/alibabacloud-go/darabonba-openapi/v2 v2.0.4 h1:7Q2FEyqxeZeIkwYMwRC3uphxV4i7O2eV4ETe21d6lS4=
github.com/alibabacloud-go/darabonba-openapi/v2 v2.0.4/go.mod h1:5JHVmnHvGzR2wNdgaW1zDLQG8kOC4Uec8ubkMogW7OQ=
github.com/alibabacloud-go/debug v0.0.0-20190504072949-9472017b5c68 h1:NqugFkGxx1TXSh/pBcU00Y6bljgDPaFdh5MUSeJ7e50=
github.com/alibabacloud-go/debug v0.0.0-20190504072949-9472017b5c68/go.mod h1:6pb/Qy8c+lqua8cFpEy7g39NRRqOWc3rOwAy8m5Y2BY=
github.com/alibabacloud-go/endpoint-util v1.1.0 h1:r/4D3VSw888XGaeNpP994zDUaxdgTSHBbVfZlzf6b5Q=
github.com/alibabacloud-go/endpoint-util v1.1.0/go.mod h1:O5FuCALmCKs2Ff7JFJMudHs0I5EBgecXXxZRyswlEjE=
github.com/alibabacloud-go/openapi-util v0.1.0 h1:0z75cIULkDrdEhkLWgi9tnLe+KhAFE/r5Pb3312/eAY=
github.com/alibabacloud-go/openapi-util v0.1.0/go.mod h1:sQuElr4ywwFRlCCberQwKRFhRzIyG4QTP/P4y1CJ6Ws=
github.com/alibabacloud-go/sts-20150401/v2 v2.0.1 h1:CevZp0VdG7Q+1J3qwNj+JL7ztKxsL27+tknbdTK9Y6M=
github.com/alibabacloud-go/sts-20150401/v2 v2.0.1/go.mod h1:8wJW1xC4mVcdRXzOvWJYfCCxmvFzZ0VB9iilVjBeWBc=
github.com/alibabacloud-go/tea v1.1.19 h1:Xroq0M+pr0mC834Djj3Fl4ZA8+GGoA0i7aWse1vmgf4=
github.com/alibabacloud-go/tea v1.1.19/go.mod h1:nXxjm6CIFkBhwW4FQkNrolwbfon8Svy6cujmKFUq98A=
github.com/alibabacloud-go/tea-utils v1.3.1 h1:iWQeRzRheqCMuiF3+XkfybB3kTgUXkXX+JMrqfLeB2I=
github.com/alibabacloud-go/tea-utils v1.3.1/go.mod h1:EI/o33aBfj3hETm4RLiAxF/ThQdSngxrpF8rKUDJjPE=
github.com/alibabacloud-go/tea-utils/v2 v2.0.1 h1:K6kwgo+UiYx+/kr6CO0PN5ACZDzE3nnn9d77215AkTs=
github.com/alibabacloud-go/tea-utils/v2 v2.0.1/go.mod h1:U5MTY10WwlquGPS34DOeomUGBB0gXbLueiq5Trwu0C4=
github.com/alibabacloud-go/tea-xml v1.1.2 h1:oLxa7JUXm2EDFzMg+7oRsYc+kutgCVwm+bZlhhmvW5M=
github.com/alibabacloud-go/tea-xml v1.1.2/go.mod h1:Rq08vgCcCAjHyRi/M7xlHKUykZCEtyBy9+DPF6GgEu8=
github.com/aliyun/aliyun-log-go-sdk v0.1.84 h1:7mMuHO/E3AtOM0P6HT62jJa6OnJRRXVWEWszaVThe4A=
github.com/aliyun/aliyun-log-go-sdk v0.1.84/go.mod h1:qNjBnTjQl8UeHhGmoZ7iredr2xyVBD1Ueu3JgOALR5U=
github.com/aliyun/credentials-go v1.1.2 h1:qU1vwGIBb3UJ8BwunHDRFtAhS6jnQLnde/yk0+Ih2GY=
github.com/aliyun/credentials-go v1.1.2/go.mod h1:ozcZaMR5kLM7pwtCMEpVmQ242suV6qTJya2bDq4X1Tw=
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869 h1:DDGfHa7BWjL4YnC6+E63dPcxHo2sUxDIu8g3QgEJdRY=
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869/go.mod h1:Ekp36dRnpXw/yCqJaO+ZrUyxD+3VXMFFr56k5XYrpB4=
github.com/cenkalti/backoff v2.2.1+incompatible h1:tNowT99t7UNflLxfYYSlKYsBpXdEet03Pg2g16Swow4=
github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM=
github.com/clbanning/mxj v1.8.4 h1:HuhwZtbyvyOw+3Z1AowPkU87JkJUSv751ELWaiTpj8I=
github.com/clbanning/mxj/v2 v2.5.5 h1:oT81vUeEiQQ/DcHbzSytRngP6Ky9O+L+0Bw0zSJag9E=
github.com/clbanning/mxj/v2 v2.5.5/go.mod h1:hNiWqW14h+kc+MdF9C6/YoRfjEJoR3ou6tn/Qo+ve2s=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/fluent/fluent-logger-golang v1.9.0 h1:zUdY44CHX2oIUc7VTNZc+4m+ORuO/mldQDA7czhWXEg=
github.com/fluent/fluent-logger-golang v1.9.0/go.mod h1:2/HCT/jTy78yGyeNGQLGQsjF3zzzAuy6Xlk6FCMV5eU=
github.com/frankban/quicktest v1.14.0 h1:+cqqvzZV87b4adx/5ayVOaYZ2CrvM4ejQvUdBzPPUss=
github.com/frankban/quicktest v1.14.0/go.mod h1:NeW+ay9A/U67EYXNFA1nPE8e/tnQv/09mUdL/ijj8og=
github.com/go-kit/kit v0.13.0 h1:OoneCcHKHQ03LfBpoQCUfCluwd2Vt3ohz+kvbJneZAU=
github.com/go-kit/kit v0.13.0/go.mod h1:phqEHMMUbyrCFCTgH48JueqrM3md2HcAZ8N3XE4FKDg=
github.com/go-kit/log v0.2.1 h1:MRVx0/zhvdseW+Gza6N9rVzU/IVzaeE1SFI4raAhmBU=
github.com/go-kit/log v0.2.1/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0=
github.com/go-kratos/aegis v0.2.0 h1:dObzCDWn3XVjUkgxyBp6ZeWtx/do0DPZ7LY3yNSJLUQ=
github.com/go-kratos/aegis v0.2.0/go.mod h1:v0R2m73WgEEYB3XYu6aE2WcMwsZkJ/Rzuf5eVccm7bI=
github.com/go-kratos/kratos/contrib/log/aliyun/v2 v2.0.0-20241105072421-f8b97f675b32 h1:WyeJFqcon/Bl+CNgnwDd8TOGRxtbcmw4mfAXWFx5d54=
github.com/go-kratos/kratos/contrib/log/aliyun/v2 v2.0.0-20241105072421-f8b97f675b32/go.mod h1:9CH0XdDTKVnxVCd2kxGuEWqVusst2/igZmHtMnwld7M=
github.com/go-kratos/kratos/contrib/log/fluent/v2 v2.0.0-20241105072421-f8b97f675b32 h1:y1iMjnjm7bUpJir3OzXrdYDhRC9+66l/yTpceeh5Hak=
github.com/go-kratos/kratos/contrib/log/fluent/v2 v2.0.0-20241105072421-f8b97f675b32/go.mod h1:VRMY6Dwydf9GKHvb6nYwpWLKlSMm330xRpreMGaHUV8=
github.com/go-kratos/kratos/contrib/log/logrus/v2 v2.0.0-20241105072421-f8b97f675b32 h1:5l1UoUjSCAX7wfHHT2ntZjbZWEfqI9gfE+f6ZLET8kI=
github.com/go-kratos/kratos/contrib/log/logrus/v2 v2.0.0-20241105072421-f8b97f675b32/go.mod h1:N75qK1uUCbitb++n79dRnCj4M6GeOU9MpUH1mO3yvvE=
github.com/go-kratos/kratos/contrib/log/tencent/v2 v2.0.0-20241105072421-f8b97f675b32 h1:yTNrTJe+R7+CENNOGltterymGPiIFcZt3b3xxMhsGEk=
github.com/go-kratos/kratos/contrib/log/tencent/v2 v2.0.0-20241105072421-f8b97f675b32/go.mod h1:91Iwi+G+72M256UKXXHT4rsRJo686ADlCHZFPyK4Q80=
github.com/go-kratos/kratos/contrib/log/zap/v2 v2.0.0-20241105072421-f8b97f675b32 h1:Auyu3uKRKyu3rqf0JqnP0hP+VhQhB32USqpLYbVZdcA=
github.com/go-kratos/kratos/contrib/log/zap/v2 v2.0.0-20241105072421-f8b97f675b32/go.mod h1:fPWjHTVUaj0TGHA70pn+4o9q5jYNw4bQHRArS+OH74U=
github.com/go-kratos/kratos/v2 v2.8.2 h1:EsEA7AmPQ2YQQ0FZrDWO2HgBNqeWM8z/mWKzS5UkQaQ=
github.com/go-kratos/kratos/v2 v2.8.2/go.mod h1:+Vfe3FzF0d+BfMdajA11jT0rAyJWublRE/seZQNZVxE=
github.com/go-logfmt/logfmt v0.6.0 h1:wGYYu3uicYdqXVgoYbvnkrPVXkuLM1p1ifugDMEdRi4=
github.com/go-logfmt/logfmt v0.6.0/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs=
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A=
github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
github.com/go-playground/form/v4 v4.2.1 h1:HjdRDKO0fftVMU5epjPW2SOREcZ6/wLUzEobqUGJuPw=
github.com/go-playground/form/v4 v4.2.1/go.mod h1:q1a2BY+AQUUzhl6xA/6hBetay6dEIhMHjgvJiGo6K7U=
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY=
github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ=
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/klauspost/compress v1.15.1/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
github.com/klauspost/compress v1.17.11 h1:In6xLpyWOi1+C7tXUUWv2ot1QvBjxevKAaI6IXrJmUc=
github.com/klauspost/compress v1.17.11/go.mod h1:pMDklpSncoRMuLFrf1W9Ss9KT+0rH90U12bZKk7uwG0=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
github.com/philhofer/fwd v1.1.3-0.20240916144458-20a13a1f6b7c h1:dAMKvw0MlJT1GshSTtih8C2gDs04w8dReiOGXrGLNoY=
github.com/philhofer/fwd v1.1.3-0.20240916144458-20a13a1f6b7c/go.mod h1:RqIHx9QI14HlwKwm98g9Re5prTQ6LdeRQn+gXJFxsJM=
github.com/pierrec/lz4 v2.6.1+incompatible h1:9UY3+iC23yxF0UfGaYrGplQ+79Rg+h/q9FV9ix19jjM=
github.com/pierrec/lz4 v2.6.1+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII=
github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o=
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/tencentcloud/tencentcloud-cls-sdk-go v1.0.11 h1:LJshkcQ14A/7XCgqalheBHv8qLwwOXr/xqttQbjWdHM=
github.com/tencentcloud/tencentcloud-cls-sdk-go v1.0.11/go.mod h1:WU+0TXfVbSctEsUUf4KmIKnfr+tknbjcsnx/TrEIPH4=
github.com/tinylib/msgp v1.2.4 h1:yLFeUGostXXSGW5vxfT5dXG/qzkn4schv2I7at5+hVU=
github.com/tinylib/msgp v1.2.4/go.mod h1:ykjzy2wzgrlvpDCRc4LA8UXy6D8bzMSuAF3WD57Gok0=
github.com/tjfoc/gmsm v1.3.2 h1:7JVkAn5bvUJ7HtU08iW6UiD+UTmJTIToHCfeFzkcCxM=
github.com/tjfoc/gmsm v1.3.2/go.mod h1:HaUcFuY0auTiaHB9MHFGCPx5IaLhTUd2atbCFBQXn9w=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
go.opentelemetry.io/otel v1.32.0 h1:WnBN+Xjcteh0zdk01SVqV55d/m62NJLJdIyb4y/WO5U=
go.opentelemetry.io/otel v1.32.0/go.mod h1:00DCVSB0RQcnzlwyTfqtxSm+DRr9hpYrHjNGiBHVQIg=
go.opentelemetry.io/otel/metric v1.32.0 h1:xV2umtmNcThh2/a/aCP+h64Xx5wsj8qqnkYZktzNa0M=
go.opentelemetry.io/otel/metric v1.32.0/go.mod h1:jH7CIbbK6SH2V2wE16W05BHCtIDzauciCRLoc/SyMv8=
go.opentelemetry.io/otel/sdk v1.32.0 h1:RNxepc9vK59A8XsgZQouW8ue8Gkb4jpWtJm9ge5lEG4=
go.opentelemetry.io/otel/sdk v1.32.0/go.mod h1:LqgegDBjKMmb2GC6/PrTnteJG39I8/vJCAP9LlJXEjU=
go.opentelemetry.io/otel/trace v1.32.0 h1:WIC9mYrXf8TmY/EXuULKc8hR17vE+Hjv2cssQDe03fM=
go.opentelemetry.io/otel/trace v1.32.0/go.mod h1:+i4rkvCraA+tG6AzwloGaCtkx53Fa+L+V8e9a7YvhT8=
go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE=
go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0=
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8=
go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.31.0 h1:68CPQngjLL0r2AlUKiSxtQFKvzRVbnzLwMUn5SzcLHo=
golang.org/x/net v0.31.0/go.mod h1:P4fl1q7dY2hnZFxEk4pPSkDHF+QqjitcnDjUQyMM+pM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.9.0 h1:fEo0HyrW1GIgZdpbhCRO0PkJajUS5H9IFUztCgEo2jQ=
golang.org/x/sync v0.9.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.27.0 h1:wBqf8DvsY9Y/2P8gAfPDEYNuS30J4lPHJxXSb/nJZ+s=
golang.org/x/sys v0.27.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.20.0 h1:gK/Kv2otX8gz+wn7Rmb3vT96ZwuoxnQlY+HlJVj7Qug=
golang.org/x/text v0.20.0/go.mod h1:D4IsuqiFMhST5bX19pQ9ikHC2GsaKyk/oF+pn3ducp4=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/genproto/googleapis/api v0.0.0-20241113202542-65e8d215514f h1:M65LEviCfuZTfrfzwwEoxVtgvfkFkBUbFnRbxCXuXhU=
google.golang.org/genproto/googleapis/api v0.0.0-20241113202542-65e8d215514f/go.mod h1:Yo94eF2nj7igQt+TiJ49KxjIH8ndLYPZMIRSiRcEbg0=
google.golang.org/genproto/googleapis/rpc v0.0.0-20241113202542-65e8d215514f h1:C1QccEa9kUwvMgEUORqQD9S17QesQijxjZ84sO82mfo=
google.golang.org/genproto/googleapis/rpc v0.0.0-20241113202542-65e8d215514f/go.mod h1:GX3210XPVPUjJbTUbvwI8f2IpZDMZuPJWDzDuebbviI=
google.golang.org/grpc v1.68.0 h1:aHQeeJbo8zAkAa3pRzrVjZlbz6uSfeOXlJNQM0RAbz0=
google.golang.org/grpc v1.68.0/go.mod h1:fmSPC5AsjSBCK54MyHRx48kpOti1/jRfOlwEWywNjWA=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA=
google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/ini.v1 v1.66.4 h1:SsAcf+mM7mRZo2nJNGt8mZCjG8ZRaNGMURJw7BsIST4=
gopkg.in/ini.v1 v1.66.4/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc=
gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

62
logger/logger.go Normal file
View File

@@ -0,0 +1,62 @@
package logger
import (
"os"
"github.com/go-kratos/kratos/v2/log"
"github.com/go-kratos/kratos/v2/middleware/tracing"
"github.com/tx7do/kratos-bootstrap/logger/fluent"
"github.com/tx7do/kratos-bootstrap/logger/logrus"
"github.com/tx7do/kratos-bootstrap/logger/tencent"
"github.com/tx7do/kratos-bootstrap/logger/zap"
conf "github.com/tx7do/kratos-bootstrap/api/gen/go/conf/v1"
"github.com/tx7do/kratos-bootstrap/utils"
)
// NewLogger 创建一个新的日志记录器
func NewLogger(cfg *conf.Logger) log.Logger {
if cfg == nil {
return NewStdLogger()
}
switch Type(cfg.Type) {
default:
fallthrough
case Std:
return NewStdLogger()
case Fluent:
return fluent.NewLogger(cfg)
case Zap:
return zap.NewLogger(cfg)
case Logrus:
return logrus.NewLogger(cfg)
case Aliyun:
return nil
case Tencent:
return tencent.NewLogger(cfg)
}
}
// NewLoggerProvider 创建一个新的日志记录器提供者
func NewLoggerProvider(cfg *conf.Logger, serviceInfo *utils.ServiceInfo) log.Logger {
l := NewLogger(cfg)
return log.With(
l,
"service.id", serviceInfo.Id,
"service.name", serviceInfo.Name,
"service.version", serviceInfo.Version,
"ts", log.DefaultTimestamp,
"caller", log.DefaultCaller,
"trace_id", tracing.TraceID(),
"span_id", tracing.SpanID(),
)
}
// NewStdLogger 创建一个新的日志记录器 - Kratos内置控制台输出
func NewStdLogger() log.Logger {
l := log.NewStdLogger(os.Stdout)
return l
}

48
logger/logrus/client.go Normal file
View File

@@ -0,0 +1,48 @@
package logrus
import (
logrusLogger "github.com/go-kratos/kratos/contrib/log/logrus/v2"
"github.com/go-kratos/kratos/v2/log"
"github.com/sirupsen/logrus"
conf "github.com/tx7do/kratos-bootstrap/api/gen/go/conf/v1"
)
// NewLogger 创建一个新的日志记录器 - Logrus
func NewLogger(cfg *conf.Logger) log.Logger {
if cfg == nil || cfg.Logrus == nil {
return nil
}
loggerLevel, err := logrus.ParseLevel(cfg.Logrus.Level)
if err != nil {
loggerLevel = logrus.InfoLevel
}
var loggerFormatter logrus.Formatter
switch cfg.Logrus.Formatter {
default:
fallthrough
case "text":
loggerFormatter = &logrus.TextFormatter{
DisableColors: cfg.Logrus.DisableColors,
DisableTimestamp: cfg.Logrus.DisableTimestamp,
TimestampFormat: cfg.Logrus.TimestampFormat,
}
break
case "json":
loggerFormatter = &logrus.JSONFormatter{
DisableTimestamp: cfg.Logrus.DisableTimestamp,
TimestampFormat: cfg.Logrus.TimestampFormat,
}
break
}
logger := logrus.New()
logger.Level = loggerLevel
logger.Formatter = loggerFormatter
wrapped := logrusLogger.NewLogger(logger)
return wrapped
}

12
logger/options.go Normal file
View File

@@ -0,0 +1,12 @@
package logger
type Type string
const (
Std Type = "std"
Fluent Type = "fluent"
Logrus Type = "logrus"
Zap Type = "zap"
Aliyun Type = "aliyun"
Tencent Type = "tencent"
)

27
logger/tencent/client.go Normal file
View File

@@ -0,0 +1,27 @@
package tencent
import (
tencentLogger "github.com/go-kratos/kratos/contrib/log/tencent/v2"
"github.com/go-kratos/kratos/v2/log"
conf "github.com/tx7do/kratos-bootstrap/api/gen/go/conf/v1"
)
// NewLogger 创建一个新的日志记录器 - Tencent
func NewLogger(cfg *conf.Logger) log.Logger {
if cfg == nil || cfg.Tencent == nil {
return nil
}
wrapped, err := tencentLogger.NewLogger(
tencentLogger.WithTopicID(cfg.Tencent.TopicId),
tencentLogger.WithEndpoint(cfg.Tencent.Endpoint),
tencentLogger.WithAccessKey(cfg.Tencent.AccessKey),
tencentLogger.WithAccessSecret(cfg.Tencent.AccessSecret),
)
if err != nil {
panic(err)
return nil
}
return wrapped
}

48
logger/zap/client.go Normal file
View File

@@ -0,0 +1,48 @@
package zap
import (
zapLogger "github.com/go-kratos/kratos/contrib/log/zap/v2"
"github.com/go-kratos/kratos/v2/log"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
"gopkg.in/natefinch/lumberjack.v2"
conf "github.com/tx7do/kratos-bootstrap/api/gen/go/conf/v1"
)
// NewLogger 创建一个新的日志记录器 - Zap
func NewLogger(cfg *conf.Logger) log.Logger {
if cfg == nil || cfg.Zap == nil {
return nil
}
encoderConfig := zap.NewProductionEncoderConfig()
encoderConfig.EncodeTime = zapcore.ISO8601TimeEncoder
encoderConfig.TimeKey = "time"
encoderConfig.EncodeLevel = zapcore.CapitalLevelEncoder
encoderConfig.EncodeDuration = zapcore.SecondsDurationEncoder
encoderConfig.EncodeCaller = zapcore.ShortCallerEncoder
jsonEncoder := zapcore.NewJSONEncoder(encoderConfig)
lumberJackLogger := &lumberjack.Logger{
Filename: cfg.Zap.Filename,
MaxSize: int(cfg.Zap.MaxSize),
MaxBackups: int(cfg.Zap.MaxBackups),
MaxAge: int(cfg.Zap.MaxAge),
}
writeSyncer := zapcore.AddSync(lumberJackLogger)
var lvl = new(zapcore.Level)
if err := lvl.UnmarshalText([]byte(cfg.Zap.Level)); err != nil {
return nil
}
core := zapcore.NewCore(jsonEncoder, writeSyncer, lvl)
logger := zap.New(core).WithOptions()
wrapped := zapLogger.NewLogger(logger)
return wrapped
}

31
oss/minio/go.mod Normal file
View File

@@ -0,0 +1,31 @@
module github.com/tx7do/kratos-bootstrap/oss/minio
go 1.22.0
toolchain go1.22.1
replace github.com/tx7do/kratos-bootstrap/api => ../../api
require (
github.com/go-kratos/kratos/v2 v2.8.2
github.com/minio/minio-go/v7 v7.0.80
github.com/tx7do/kratos-bootstrap/api v0.0.5
)
require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/go-ini/ini v1.67.0 // indirect
github.com/goccy/go-json v0.10.3 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/klauspost/compress v1.17.11 // indirect
github.com/klauspost/cpuid/v2 v2.2.9 // indirect
github.com/minio/md5-simd v1.1.2 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rs/xid v1.6.0 // indirect
golang.org/x/crypto v0.29.0 // indirect
golang.org/x/net v0.31.0 // indirect
golang.org/x/sys v0.27.0 // indirect
golang.org/x/text v0.20.0 // indirect
google.golang.org/protobuf v1.35.1 // indirect
)

Some files were not shown because too many files have changed in this diff Show More