feat: notify config, refactor config load.

This commit is contained in:
tx7do
2023-10-26 16:46:14 +08:00
parent 6d18bc0ffe
commit e7883775ed
24 changed files with 1907 additions and 1177 deletions

View File

@@ -1,6 +1,6 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.30.0
// protoc-gen-go v1.31.0
// protoc (unknown)
// source: conf/v1/server.proto
@@ -33,6 +33,8 @@ type Server struct {
Mqtt *Server_Mqtt `protobuf:"bytes,4,opt,name=mqtt,proto3" json:"mqtt,omitempty"` // MQTT服务
Kafka *Server_Kafka `protobuf:"bytes,5,opt,name=kafka,proto3" json:"kafka,omitempty"` // Kafka服务
Rabbitmq *Server_RabbitMQ `protobuf:"bytes,6,opt,name=rabbitmq,proto3" json:"rabbitmq,omitempty"` // RabbitMQ服务
Asynq *Server_Asynq `protobuf:"bytes,7,opt,name=asynq,proto3" json:"asynq,omitempty"` // Asynq服务
Machinery *Server_Machinery `protobuf:"bytes,8,opt,name=machinery,proto3" json:"machinery,omitempty"` // Machinery服务
}
func (x *Server) Reset() {
@@ -109,6 +111,20 @@ func (x *Server) GetRabbitmq() *Server_RabbitMQ {
return nil
}
func (x *Server) GetAsynq() *Server_Asynq {
if x != nil {
return x.Asynq
}
return nil
}
func (x *Server) GetMachinery() *Server_Machinery {
if x != nil {
return x.Machinery
}
return nil
}
// REST
type Server_REST struct {
state protoimpl.MessageState
@@ -477,6 +493,126 @@ func (x *Server_RabbitMQ) GetAddrs() []string {
return nil
}
// Asynq
type Server_Asynq struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Endpoint string `protobuf:"bytes,1,opt,name=endpoint,proto3" json:"endpoint,omitempty"` // 对端网络地址
Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"` // redis登录密码
Db int32 `protobuf:"varint,3,opt,name=db,proto3" json:"db,omitempty"` // 数据库索引
}
func (x *Server_Asynq) Reset() {
*x = Server_Asynq{}
if protoimpl.UnsafeEnabled {
mi := &file_conf_v1_server_proto_msgTypes[7]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Server_Asynq) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Server_Asynq) ProtoMessage() {}
func (x *Server_Asynq) ProtoReflect() protoreflect.Message {
mi := &file_conf_v1_server_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 Server_Asynq.ProtoReflect.Descriptor instead.
func (*Server_Asynq) Descriptor() ([]byte, []int) {
return file_conf_v1_server_proto_rawDescGZIP(), []int{0, 6}
}
func (x *Server_Asynq) GetEndpoint() string {
if x != nil {
return x.Endpoint
}
return ""
}
func (x *Server_Asynq) GetPassword() string {
if x != nil {
return x.Password
}
return ""
}
func (x *Server_Asynq) GetDb() int32 {
if x != nil {
return x.Db
}
return 0
}
// Machinery
type Server_Machinery struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Brokers []string `protobuf:"bytes,1,rep,name=brokers,proto3" json:"brokers,omitempty"` // broker的地址可以根据实际使用的存储介质分别指定Redis、AMQP或AWS SQS
Backends []string `protobuf:"bytes,2,rep,name=backends,proto3" json:"backends,omitempty"` // backend配置用来指定存放结果的介质的配置。可以根据需求分别指定为Redis、memcached或mongodb等
}
func (x *Server_Machinery) Reset() {
*x = Server_Machinery{}
if protoimpl.UnsafeEnabled {
mi := &file_conf_v1_server_proto_msgTypes[8]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Server_Machinery) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Server_Machinery) ProtoMessage() {}
func (x *Server_Machinery) ProtoReflect() protoreflect.Message {
mi := &file_conf_v1_server_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 Server_Machinery.ProtoReflect.Descriptor instead.
func (*Server_Machinery) Descriptor() ([]byte, []int) {
return file_conf_v1_server_proto_rawDescGZIP(), []int{0, 7}
}
func (x *Server_Machinery) GetBrokers() []string {
if x != nil {
return x.Brokers
}
return nil
}
func (x *Server_Machinery) GetBackends() []string {
if x != nil {
return x.Backends
}
return nil
}
type Server_REST_CORS struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
@@ -490,7 +626,7 @@ type Server_REST_CORS struct {
func (x *Server_REST_CORS) Reset() {
*x = Server_REST_CORS{}
if protoimpl.UnsafeEnabled {
mi := &file_conf_v1_server_proto_msgTypes[7]
mi := &file_conf_v1_server_proto_msgTypes[9]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -503,7 +639,7 @@ func (x *Server_REST_CORS) String() string {
func (*Server_REST_CORS) ProtoMessage() {}
func (x *Server_REST_CORS) ProtoReflect() protoreflect.Message {
mi := &file_conf_v1_server_proto_msgTypes[7]
mi := &file_conf_v1_server_proto_msgTypes[9]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -548,7 +684,7 @@ var file_conf_v1_server_proto_rawDesc = []byte{
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, 0x1a, 0x18, 0x63, 0x6f,
0x6e, 0x66, 0x2f, 0x76, 0x31, 0x2f, 0x6d, 0x69, 0x64, 0x64, 0x6c, 0x65, 0x77, 0x61, 0x72, 0x65,
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xb0, 0x07, 0x0a, 0x06, 0x53, 0x65, 0x72, 0x76, 0x65,
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xa4, 0x09, 0x0a, 0x06, 0x53, 0x65, 0x72, 0x76, 0x65,
0x72, 0x12, 0x25, 0x0a, 0x04, 0x72, 0x65, 0x73, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32,
0x11, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x52, 0x45,
0x53, 0x54, 0x52, 0x04, 0x72, 0x65, 0x73, 0x74, 0x12, 0x25, 0x0a, 0x04, 0x67, 0x72, 0x70, 0x63,
@@ -565,7 +701,13 @@ var file_conf_v1_server_proto_rawDesc = []byte{
0x05, 0x6b, 0x61, 0x66, 0x6b, 0x61, 0x12, 0x31, 0x0a, 0x08, 0x72, 0x61, 0x62, 0x62, 0x69, 0x74,
0x6d, 0x71, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x2e,
0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x52, 0x61, 0x62, 0x62, 0x69, 0x74, 0x4d, 0x51, 0x52,
0x08, 0x72, 0x61, 0x62, 0x62, 0x69, 0x74, 0x6d, 0x71, 0x1a, 0x9d, 0x02, 0x0a, 0x04, 0x52, 0x45,
0x08, 0x72, 0x61, 0x62, 0x62, 0x69, 0x74, 0x6d, 0x71, 0x12, 0x28, 0x0a, 0x05, 0x61, 0x73, 0x79,
0x6e, 0x71, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x2e,
0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x41, 0x73, 0x79, 0x6e, 0x71, 0x52, 0x05, 0x61, 0x73,
0x79, 0x6e, 0x71, 0x12, 0x34, 0x0a, 0x09, 0x6d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x72, 0x79,
0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x2e, 0x53, 0x65,
0x72, 0x76, 0x65, 0x72, 0x2e, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x72, 0x79, 0x52, 0x09,
0x6d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x72, 0x79, 0x1a, 0x9d, 0x02, 0x0a, 0x04, 0x52, 0x45,
0x53, 0x54, 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,
@@ -607,10 +749,21 @@ var file_conf_v1_server_proto_rawDesc = []byte{
0x61, 0x12, 0x14, 0x0a, 0x05, 0x61, 0x64, 0x64, 0x72, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09,
0x52, 0x05, 0x61, 0x64, 0x64, 0x72, 0x73, 0x1a, 0x20, 0x0a, 0x08, 0x52, 0x61, 0x62, 0x62, 0x69,
0x74, 0x4d, 0x51, 0x12, 0x14, 0x0a, 0x05, 0x61, 0x64, 0x64, 0x72, 0x73, 0x18, 0x01, 0x20, 0x03,
0x28, 0x09, 0x52, 0x05, 0x61, 0x64, 0x64, 0x72, 0x73, 0x42, 0x23, 0x5a, 0x21, 0x6b, 0x72, 0x61,
0x74, 0x6f, 0x73, 0x2d, 0x62, 0x69, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x67,
0x6f, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x2f, 0x76, 0x31, 0x3b, 0x63, 0x6f, 0x6e, 0x66, 0x62, 0x06,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x28, 0x09, 0x52, 0x05, 0x61, 0x64, 0x64, 0x72, 0x73, 0x1a, 0x4f, 0x0a, 0x05, 0x41, 0x73, 0x79,
0x6e, 0x71, 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, 0x1a,
0x0a, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09,
0x52, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x12, 0x0e, 0x0a, 0x02, 0x64, 0x62,
0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x64, 0x62, 0x1a, 0x41, 0x0a, 0x09, 0x4d, 0x61,
0x63, 0x68, 0x69, 0x6e, 0x65, 0x72, 0x79, 0x12, 0x18, 0x0a, 0x07, 0x62, 0x72, 0x6f, 0x6b, 0x65,
0x72, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x07, 0x62, 0x72, 0x6f, 0x6b, 0x65, 0x72,
0x73, 0x12, 0x1a, 0x0a, 0x08, 0x62, 0x61, 0x63, 0x6b, 0x65, 0x6e, 0x64, 0x73, 0x18, 0x02, 0x20,
0x03, 0x28, 0x09, 0x52, 0x08, 0x62, 0x61, 0x63, 0x6b, 0x65, 0x6e, 0x64, 0x73, 0x42, 0x3b, 0x5a,
0x39, 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, 0x3b, 0x63, 0x6f, 0x6e, 0x66, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x33,
}
var (
@@ -625,7 +778,7 @@ func file_conf_v1_server_proto_rawDescGZIP() []byte {
return file_conf_v1_server_proto_rawDescData
}
var file_conf_v1_server_proto_msgTypes = make([]protoimpl.MessageInfo, 8)
var file_conf_v1_server_proto_msgTypes = make([]protoimpl.MessageInfo, 10)
var file_conf_v1_server_proto_goTypes = []interface{}{
(*Server)(nil), // 0: conf.Server
(*Server_REST)(nil), // 1: conf.Server.REST
@@ -634,9 +787,11 @@ var file_conf_v1_server_proto_goTypes = []interface{}{
(*Server_Mqtt)(nil), // 4: conf.Server.Mqtt
(*Server_Kafka)(nil), // 5: conf.Server.Kafka
(*Server_RabbitMQ)(nil), // 6: conf.Server.RabbitMQ
(*Server_REST_CORS)(nil), // 7: conf.Server.REST.CORS
(*durationpb.Duration)(nil), // 8: google.protobuf.Duration
(*Middleware)(nil), // 9: conf.Middleware
(*Server_Asynq)(nil), // 7: conf.Server.Asynq
(*Server_Machinery)(nil), // 8: conf.Server.Machinery
(*Server_REST_CORS)(nil), // 9: conf.Server.REST.CORS
(*durationpb.Duration)(nil), // 10: google.protobuf.Duration
(*Middleware)(nil), // 11: conf.Middleware
}
var file_conf_v1_server_proto_depIdxs = []int32{
1, // 0: conf.Server.rest:type_name -> conf.Server.REST
@@ -645,17 +800,19 @@ var file_conf_v1_server_proto_depIdxs = []int32{
4, // 3: conf.Server.mqtt:type_name -> conf.Server.Mqtt
5, // 4: conf.Server.kafka:type_name -> conf.Server.Kafka
6, // 5: conf.Server.rabbitmq:type_name -> conf.Server.RabbitMQ
8, // 6: conf.Server.REST.timeout:type_name -> google.protobuf.Duration
7, // 7: conf.Server.REST.cors:type_name -> conf.Server.REST.CORS
9, // 8: conf.Server.REST.middleware:type_name -> conf.Middleware
8, // 9: conf.Server.GRPC.timeout:type_name -> google.protobuf.Duration
9, // 10: conf.Server.GRPC.middleware:type_name -> conf.Middleware
8, // 11: conf.Server.Websocket.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
7, // 6: conf.Server.asynq:type_name -> conf.Server.Asynq
8, // 7: conf.Server.machinery:type_name -> conf.Server.Machinery
10, // 8: conf.Server.REST.timeout:type_name -> google.protobuf.Duration
9, // 9: conf.Server.REST.cors:type_name -> conf.Server.REST.CORS
11, // 10: conf.Server.REST.middleware:type_name -> conf.Middleware
10, // 11: conf.Server.GRPC.timeout:type_name -> google.protobuf.Duration
11, // 12: conf.Server.GRPC.middleware:type_name -> conf.Middleware
10, // 13: conf.Server.Websocket.timeout:type_name -> google.protobuf.Duration
14, // [14:14] is the sub-list for method output_type
14, // [14:14] is the sub-list for method input_type
14, // [14:14] is the sub-list for extension type_name
14, // [14:14] is the sub-list for extension extendee
0, // [0:14] is the sub-list for field type_name
}
func init() { file_conf_v1_server_proto_init() }
@@ -750,6 +907,30 @@ func file_conf_v1_server_proto_init() {
}
}
file_conf_v1_server_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Server_Asynq); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_conf_v1_server_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Server_Machinery); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_conf_v1_server_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Server_REST_CORS); i {
case 0:
return &v.state
@@ -768,7 +949,7 @@ func file_conf_v1_server_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_conf_v1_server_proto_rawDesc,
NumEnums: 0,
NumMessages: 8,
NumMessages: 10,
NumExtensions: 0,
NumServices: 0,
},