feat: first version.
This commit is contained in:
26
api/conf/v1/bootstrap.proto
Normal file
26
api/conf/v1/bootstrap.proto
Normal file
@@ -0,0 +1,26 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package conf;
|
||||
|
||||
option go_package = "github.com/tx7do/kratos-bootstrap/gen/api/go/conf/v1;conf";
|
||||
|
||||
import "conf/v1/tracer.proto";
|
||||
import "conf/v1/data.proto";
|
||||
import "conf/v1/server.proto";
|
||||
import "conf/v1/client.proto";
|
||||
import "conf/v1/logger.proto";
|
||||
import "conf/v1/registry.proto";
|
||||
import "conf/v1/oss.proto";
|
||||
import "conf/v1/config.proto";
|
||||
|
||||
// 引导信息
|
||||
message Bootstrap {
|
||||
Server server = 1;
|
||||
Client client = 2;
|
||||
Data data = 3;
|
||||
Tracer trace = 4;
|
||||
Logger logger = 5;
|
||||
Registry registry = 6;
|
||||
RemoteConfig config = 7;
|
||||
OSS oss = 8;
|
||||
}
|
||||
26
api/conf/v1/client.proto
Normal file
26
api/conf/v1/client.proto
Normal file
@@ -0,0 +1,26 @@
|
||||
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/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服务
|
||||
}
|
||||
53
api/conf/v1/config.proto
Normal file
53
api/conf/v1/config.proto
Normal file
@@ -0,0 +1,53 @@
|
||||
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;
|
||||
}
|
||||
31
api/conf/v1/data.proto
Normal file
31
api/conf/v1/data.proto
Normal file
@@ -0,0 +1,31 @@
|
||||
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; // 数据迁移开关
|
||||
}
|
||||
|
||||
// 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; // 写入超时时间
|
||||
}
|
||||
|
||||
Database database = 1; // 数据库
|
||||
Redis redis = 2; // Redis
|
||||
}
|
||||
55
api/conf/v1/logger.proto
Normal file
55
api/conf/v1/logger.proto
Normal file
@@ -0,0 +1,55 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package conf;
|
||||
|
||||
option go_package = "github.com/tx7do/kratos-bootstrap/gen/api/go/conf/v1;conf";
|
||||
|
||||
// 日志
|
||||
message Logger {
|
||||
// Zap
|
||||
message Zap {
|
||||
string filename = 1; //
|
||||
string level = 2; //
|
||||
int32 max_size = 3; //
|
||||
int32 max_age = 4; //
|
||||
int32 max_backups = 5; //
|
||||
}
|
||||
|
||||
// logrus
|
||||
message Logrus {
|
||||
string level = 1; // 日志等级
|
||||
string formatter = 2; // 输出格式:text, json.
|
||||
string timestamp_format = 3; // 定义时间戳格式,例如:"2006-01-02 15:04:05"
|
||||
bool disable_colors = 4; // 不需要彩色日志
|
||||
bool disable_timestamp = 5; // 不需要时间戳
|
||||
}
|
||||
|
||||
// Fluent
|
||||
message Fluent {
|
||||
string endpoint = 1; // 公网接入地址
|
||||
}
|
||||
|
||||
// 阿里云
|
||||
message Aliyun {
|
||||
string endpoint = 1; // 公网接入地址
|
||||
string project = 2; //
|
||||
string access_key = 3; // 访问密钥ID
|
||||
string access_secret = 4; // 访问密钥
|
||||
}
|
||||
|
||||
// 腾讯
|
||||
message Tencent {
|
||||
string endpoint = 1; // 公网接入地址
|
||||
string topic_id = 2; //
|
||||
string access_key = 3; // 访问密钥ID
|
||||
string access_secret = 4; // 访问密钥
|
||||
}
|
||||
|
||||
string type = 1;
|
||||
|
||||
Zap zap = 2;
|
||||
Logrus logrus = 3;
|
||||
Fluent fluent = 4;
|
||||
Aliyun aliyun = 5;
|
||||
Tencent tencent = 6;
|
||||
}
|
||||
38
api/conf/v1/middleware.proto
Normal file
38
api/conf/v1/middleware.proto
Normal file
@@ -0,0 +1,38 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package conf;
|
||||
|
||||
option go_package = "github.com/tx7do/kratos-bootstrap/gen/api/go/conf/v1;conf";
|
||||
|
||||
import "google/protobuf/duration.proto";
|
||||
|
||||
message Middleware {
|
||||
// JWT校验
|
||||
message Auth {
|
||||
string method = 1; // JWT签名的算法,支持算法:HS256
|
||||
string key = 2; // JWT 秘钥
|
||||
}
|
||||
|
||||
// 限流器
|
||||
message RateLimiter {
|
||||
string name = 1; // 限流器名字,支持:bbr。
|
||||
}
|
||||
|
||||
// 性能指标
|
||||
message Metrics {
|
||||
bool histogram = 1; // 直方图
|
||||
bool counter = 2; // 计数器
|
||||
bool gauge = 3; // 仪表盘
|
||||
bool summary = 4; // 摘要
|
||||
}
|
||||
|
||||
bool enable_logging = 1; // 日志开关
|
||||
bool enable_recovery = 2; // 异常恢复
|
||||
bool enable_tracing = 3; // 链路追踪开关
|
||||
bool enable_validate = 4; // 参数校验开关
|
||||
bool enable_circuit_breaker = 5; // 熔断器
|
||||
|
||||
RateLimiter limiter = 6;
|
||||
Metrics metrics = 7;
|
||||
Auth auth = 8;
|
||||
}
|
||||
20
api/conf/v1/oss.proto
Normal file
20
api/conf/v1/oss.proto
Normal file
@@ -0,0 +1,20 @@
|
||||
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;
|
||||
}
|
||||
82
api/conf/v1/registry.proto
Normal file
82
api/conf/v1/registry.proto
Normal file
@@ -0,0 +1,82 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package conf;
|
||||
|
||||
option go_package = "github.com/tx7do/kratos-bootstrap/gen/api/go/conf/v1;conf";
|
||||
|
||||
import "google/protobuf/duration.proto";
|
||||
|
||||
// 注册发现中心
|
||||
message Registry {
|
||||
// Consul
|
||||
message Consul {
|
||||
string scheme = 1; // 网络样式
|
||||
string address = 2; // 服务端地址
|
||||
bool health_check = 3; // 健康检查
|
||||
}
|
||||
|
||||
// Etcd
|
||||
message Etcd {
|
||||
repeated string endpoints = 1;
|
||||
}
|
||||
|
||||
// ZooKeeper
|
||||
message ZooKeeper {
|
||||
repeated string endpoints = 1;
|
||||
google.protobuf.Duration timeout = 2;
|
||||
}
|
||||
|
||||
// Nacos
|
||||
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: 不更新
|
||||
}
|
||||
|
||||
// Kubernetes
|
||||
message Kubernetes {
|
||||
|
||||
}
|
||||
|
||||
// Eureka
|
||||
message Eureka {
|
||||
repeated string endpoints = 1;
|
||||
google.protobuf.Duration heartbeat_interval = 2;
|
||||
google.protobuf.Duration refresh_interval = 3;
|
||||
string path = 4;
|
||||
}
|
||||
|
||||
// Polaris
|
||||
message Polaris {
|
||||
string address = 1; // 服务端地址
|
||||
int32 port = 2; // 服务端端口
|
||||
int32 instance_count = 3;
|
||||
string namespace = 4;
|
||||
string service = 5;
|
||||
string token = 6;
|
||||
}
|
||||
|
||||
// Servicecomb
|
||||
message Servicecomb {
|
||||
repeated string endpoints = 1;
|
||||
}
|
||||
|
||||
string type = 1;
|
||||
|
||||
Consul consul = 2; // Consul
|
||||
Etcd etcd = 3; // Etcd
|
||||
ZooKeeper zookeeper = 4; // ZooKeeper
|
||||
Nacos nacos = 5; // Nacos
|
||||
Kubernetes kubernetes = 6; // Kubernetes
|
||||
Eureka eureka = 7; // Eureka
|
||||
Polaris polaris = 8; // Polaris
|
||||
Servicecomb servicecomb = 9; // Servicecomb
|
||||
}
|
||||
64
api/conf/v1/server.proto
Normal file
64
api/conf/v1/server.proto
Normal file
@@ -0,0 +1,64 @@
|
||||
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/middleware.proto";
|
||||
|
||||
// 服务器
|
||||
message Server {
|
||||
// REST
|
||||
message REST {
|
||||
message CORS {
|
||||
repeated string headers = 1; //
|
||||
repeated string methods = 2; //
|
||||
repeated string origins = 3; //
|
||||
}
|
||||
|
||||
string network = 1; // 网络
|
||||
string addr = 2; // 服务监听地址
|
||||
google.protobuf.Duration timeout = 3; // 超时时间
|
||||
CORS cors = 4; // 服务监听地址
|
||||
Middleware middleware = 5; // 中间件
|
||||
}
|
||||
|
||||
// gPRC
|
||||
message GRPC {
|
||||
string network = 1; // 网络
|
||||
string addr = 2; // 服务监听地址
|
||||
google.protobuf.Duration timeout = 3; // 超时时间
|
||||
Middleware middleware = 4;
|
||||
}
|
||||
|
||||
// Websocket
|
||||
message Websocket {
|
||||
string network = 1; // 网络样式:http、https
|
||||
string addr = 2; // 服务监听地址
|
||||
string path = 3; // 路径
|
||||
google.protobuf.Duration timeout = 4; // 超时时间
|
||||
}
|
||||
|
||||
// MQTT
|
||||
message Mqtt {
|
||||
string addr = 1; // 对端网络地址
|
||||
}
|
||||
|
||||
// Kafka
|
||||
message Kafka {
|
||||
repeated string addrs = 1; // 对端网络地址
|
||||
}
|
||||
|
||||
// RabbitMQ
|
||||
message RabbitMQ {
|
||||
repeated string addrs = 1; // 对端网络地址
|
||||
}
|
||||
|
||||
REST rest = 1; // REST服务
|
||||
GRPC grpc = 2; // gRPC服务
|
||||
Websocket websocket = 3; // Websocket服务
|
||||
Mqtt mqtt = 4; // MQTT服务
|
||||
Kafka kafka = 5; // Kafka服务
|
||||
RabbitMQ rabbitmq = 6; // RabbitMQ服务
|
||||
}
|
||||
13
api/conf/v1/tracer.proto
Normal file
13
api/conf/v1/tracer.proto
Normal file
@@ -0,0 +1,13 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package conf;
|
||||
|
||||
option go_package = "github.com/tx7do/kratos-bootstrap/gen/api/go/conf/v1;conf";
|
||||
|
||||
// 链路追踪
|
||||
message Tracer {
|
||||
string batcher = 1; // jaeger或者zipkin
|
||||
string endpoint = 2; // 端口
|
||||
double sampler = 3; // 采样率,默认:1.0
|
||||
string env = 4; // 运行环境:dev、debug、product
|
||||
}
|
||||
Reference in New Issue
Block a user