优化源站调度

This commit is contained in:
GoEdgeLab
2021-08-01 21:56:15 +08:00
parent fc9e967278
commit 34dcca675d
9 changed files with 203 additions and 82 deletions

View File

@@ -48,6 +48,9 @@ type NodeConfig struct {
// metrics // metrics
hasHTTPConnectionMetrics bool hasHTTPConnectionMetrics bool
// 源站集合
originMap map[int64]*serverconfigs.OriginConfig
} }
// SharedNodeConfig 取得当前节点配置单例 // SharedNodeConfig 取得当前节点配置单例
@@ -130,6 +133,9 @@ func (this *NodeConfig) Init() error {
} }
} }
// 源站
this.originMap = map[int64]*serverconfigs.OriginConfig{}
// 查找FirewallPolicy // 查找FirewallPolicy
this.firewallPolicies = []*firewallconfigs.HTTPFirewallPolicy{} this.firewallPolicies = []*firewallconfigs.HTTPFirewallPolicy{}
for _, policy := range this.HTTPFirewallPolicies { for _, policy := range this.HTTPFirewallPolicies {
@@ -161,6 +167,20 @@ func (this *NodeConfig) Init() error {
} }
} }
// 源站
if server.ReverseProxyRef != nil && server.ReverseProxyRef.IsOn && server.ReverseProxy != nil && server.ReverseProxy.IsOn {
for _, origin := range server.ReverseProxy.PrimaryOrigins {
if origin.IsOn {
this.originMap[origin.Id] = origin
}
}
for _, origin := range server.ReverseProxy.BackupOrigins {
if origin.IsOn {
this.originMap[origin.Id] = origin
}
}
}
if server.Web != nil { if server.Web != nil {
this.lookupWeb(server, server.Web) this.lookupWeb(server, server.Web)
} }
@@ -242,6 +262,18 @@ func (this *NodeConfig) HasHTTPConnectionMetrics() bool {
return this.hasHTTPConnectionMetrics return this.hasHTTPConnectionMetrics
} }
// FindOrigin 读取源站配置
func (this *NodeConfig) FindOrigin(originId int64) *serverconfigs.OriginConfig {
if this.originMap == nil {
return nil
}
config, ok := this.originMap[originId]
if ok {
return config
}
return nil
}
// 搜索WAF策略 // 搜索WAF策略
func (this *NodeConfig) lookupWeb(server *serverconfigs.ServerConfig, web *serverconfigs.HTTPWebConfig) { func (this *NodeConfig) lookupWeb(server *serverconfigs.ServerConfig, web *serverconfigs.HTTPWebConfig) {
if web == nil || !web.IsOn { if web == nil || !web.IsOn {
@@ -256,6 +288,21 @@ func (this *NodeConfig) lookupWeb(server *serverconfigs.ServerConfig, web *serve
} }
if len(web.Locations) > 0 { if len(web.Locations) > 0 {
for _, location := range web.Locations { for _, location := range web.Locations {
// 源站
if location.IsOn && location.ReverseProxyRef != nil && location.ReverseProxyRef.IsOn && location.ReverseProxy != nil && location.ReverseProxy.IsOn {
for _, origin := range location.ReverseProxy.PrimaryOrigins {
if origin.IsOn {
this.originMap[origin.Id] = origin
}
}
for _, origin := range location.ReverseProxy.BackupOrigins {
if origin.IsOn {
this.originMap[origin.Id] = origin
}
}
}
// Web
if location.Web != nil && location.Web.IsOn { if location.Web != nil && location.Web.IsOn {
this.lookupWeb(server, location.Web) this.lookupWeb(server, location.Web)
} }

View File

@@ -40,6 +40,7 @@ type NodeLog struct {
Count int32 `protobuf:"varint,8,opt,name=count,proto3" json:"count,omitempty"` Count int32 `protobuf:"varint,8,opt,name=count,proto3" json:"count,omitempty"`
ServerId int64 `protobuf:"varint,9,opt,name=serverId,proto3" json:"serverId,omitempty"` ServerId int64 `protobuf:"varint,9,opt,name=serverId,proto3" json:"serverId,omitempty"`
IsFixed bool `protobuf:"varint,10,opt,name=isFixed,proto3" json:"isFixed,omitempty"` IsFixed bool `protobuf:"varint,10,opt,name=isFixed,proto3" json:"isFixed,omitempty"`
OriginId int64 `protobuf:"varint,11,opt,name=originId,proto3" json:"originId,omitempty"`
} }
func (x *NodeLog) Reset() { func (x *NodeLog) Reset() {
@@ -144,12 +145,19 @@ func (x *NodeLog) GetIsFixed() bool {
return false return false
} }
func (x *NodeLog) GetOriginId() int64 {
if x != nil {
return x.OriginId
}
return 0
}
var File_models_model_node_log_proto protoreflect.FileDescriptor var File_models_model_node_log_proto protoreflect.FileDescriptor
var file_models_model_node_log_proto_rawDesc = []byte{ var file_models_model_node_log_proto_rawDesc = []byte{
0x0a, 0x1b, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x73, 0x2f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x5f, 0x6e, 0x0a, 0x1b, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x73, 0x2f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x5f, 0x6e,
0x6f, 0x64, 0x65, 0x5f, 0x6c, 0x6f, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x02, 0x70, 0x6f, 0x64, 0x65, 0x5f, 0x6c, 0x6f, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x02, 0x70,
0x62, 0x22, 0xf9, 0x01, 0x0a, 0x07, 0x4e, 0x6f, 0x64, 0x65, 0x4c, 0x6f, 0x67, 0x12, 0x0e, 0x0a, 0x62, 0x22, 0x95, 0x02, 0x0a, 0x07, 0x4e, 0x6f, 0x64, 0x65, 0x4c, 0x6f, 0x67, 0x12, 0x0e, 0x0a,
0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a,
0x04, 0x72, 0x6f, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x72, 0x6f, 0x6c, 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x72, 0x6f, 0x6c,
0x65, 0x12, 0x10, 0x0a, 0x03, 0x74, 0x61, 0x67, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x74, 0x61, 0x67, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03,
@@ -164,8 +172,10 @@ var file_models_model_node_log_proto_rawDesc = []byte{
0x52, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x65, 0x72, 0x76, 0x65, 0x52, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x65, 0x72, 0x76, 0x65,
0x72, 0x49, 0x64, 0x18, 0x09, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x49, 0x64, 0x18, 0x09, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x73, 0x65, 0x72, 0x76, 0x65,
0x72, 0x49, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x69, 0x73, 0x46, 0x69, 0x78, 0x65, 0x64, 0x18, 0x0a, 0x72, 0x49, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x69, 0x73, 0x46, 0x69, 0x78, 0x65, 0x64, 0x18, 0x0a,
0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x69, 0x73, 0x46, 0x69, 0x78, 0x65, 0x64, 0x42, 0x06, 0x5a, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x69, 0x73, 0x46, 0x69, 0x78, 0x65, 0x64, 0x12, 0x1a, 0x0a,
0x04, 0x2e, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 0x08, 0x6f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x49, 0x64, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x03, 0x52,
0x08, 0x6f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x49, 0x64, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x2f, 0x70,
0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
} }
var ( var (

View File

@@ -128,6 +128,7 @@ type CountNodeLogsRequest struct {
Keyword string `protobuf:"bytes,5,opt,name=keyword,proto3" json:"keyword,omitempty"` Keyword string `protobuf:"bytes,5,opt,name=keyword,proto3" json:"keyword,omitempty"`
Level string `protobuf:"bytes,6,opt,name=level,proto3" json:"level,omitempty"` Level string `protobuf:"bytes,6,opt,name=level,proto3" json:"level,omitempty"`
ServerId int64 `protobuf:"varint,7,opt,name=serverId,proto3" json:"serverId,omitempty"` ServerId int64 `protobuf:"varint,7,opt,name=serverId,proto3" json:"serverId,omitempty"`
OriginId int64 `protobuf:"varint,8,opt,name=originId,proto3" json:"originId,omitempty"`
} }
func (x *CountNodeLogsRequest) Reset() { func (x *CountNodeLogsRequest) Reset() {
@@ -211,6 +212,13 @@ func (x *CountNodeLogsRequest) GetServerId() int64 {
return 0 return 0
} }
func (x *CountNodeLogsRequest) GetOriginId() int64 {
if x != nil {
return x.OriginId
}
return 0
}
// 列出单页日志 // 列出单页日志
type ListNodeLogsRequest struct { type ListNodeLogsRequest struct {
state protoimpl.MessageState state protoimpl.MessageState
@@ -228,6 +236,7 @@ type ListNodeLogsRequest struct {
ServerId int64 `protobuf:"varint,9,opt,name=serverId,proto3" json:"serverId,omitempty"` ServerId int64 `protobuf:"varint,9,opt,name=serverId,proto3" json:"serverId,omitempty"`
FixedState int32 `protobuf:"varint,10,opt,name=fixedState,proto3" json:"fixedState,omitempty"` FixedState int32 `protobuf:"varint,10,opt,name=fixedState,proto3" json:"fixedState,omitempty"`
AllServers bool `protobuf:"varint,11,opt,name=allServers,proto3" json:"allServers,omitempty"` // 是否获取所有服务相关的日志 AllServers bool `protobuf:"varint,11,opt,name=allServers,proto3" json:"allServers,omitempty"` // 是否获取所有服务相关的日志
OriginId int64 `protobuf:"varint,12,opt,name=originId,proto3" json:"originId,omitempty"`
} }
func (x *ListNodeLogsRequest) Reset() { func (x *ListNodeLogsRequest) Reset() {
@@ -339,6 +348,13 @@ func (x *ListNodeLogsRequest) GetAllServers() bool {
return false return false
} }
func (x *ListNodeLogsRequest) GetOriginId() int64 {
if x != nil {
return x.OriginId
}
return 0
}
type ListNodeLogsResponse struct { type ListNodeLogsResponse struct {
state protoimpl.MessageState state protoimpl.MessageState
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
@@ -448,7 +464,7 @@ var file_service_node_log_proto_rawDesc = []byte{
0x0b, 0x2e, 0x70, 0x62, 0x2e, 0x4e, 0x6f, 0x64, 0x65, 0x4c, 0x6f, 0x67, 0x52, 0x08, 0x6e, 0x6f, 0x0b, 0x2e, 0x70, 0x62, 0x2e, 0x4e, 0x6f, 0x64, 0x65, 0x4c, 0x6f, 0x67, 0x52, 0x08, 0x6e, 0x6f,
0x64, 0x65, 0x4c, 0x6f, 0x67, 0x73, 0x22, 0x18, 0x0a, 0x16, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x65, 0x4c, 0x6f, 0x67, 0x73, 0x22, 0x18, 0x0a, 0x16, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65,
0x4e, 0x6f, 0x64, 0x65, 0x4c, 0x6f, 0x67, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x4c, 0x6f, 0x67, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
0x22, 0xbe, 0x01, 0x0a, 0x14, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x4e, 0x6f, 0x64, 0x65, 0x4c, 0x6f, 0x22, 0xda, 0x01, 0x0a, 0x14, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x4e, 0x6f, 0x64, 0x65, 0x4c, 0x6f,
0x67, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x6e, 0x6f, 0x64, 0x67, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x6e, 0x6f, 0x64,
0x65, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x6e, 0x6f, 0x64, 0x65, 0x49, 0x65, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x6e, 0x6f, 0x64, 0x65, 0x49,
0x64, 0x12, 0x12, 0x0a, 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52,
@@ -460,51 +476,54 @@ var file_service_node_log_proto_rawDesc = []byte{
0x14, 0x0a, 0x05, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x14, 0x0a, 0x05, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05,
0x6c, 0x65, 0x76, 0x65, 0x6c, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x49, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x49,
0x64, 0x18, 0x07, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x49, 0x64, 0x18, 0x07, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x49,
0x64, 0x22, 0xa9, 0x02, 0x0a, 0x13, 0x4c, 0x69, 0x73, 0x74, 0x4e, 0x6f, 0x64, 0x65, 0x4c, 0x6f, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x6f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x49, 0x64, 0x18, 0x08, 0x20,
0x67, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x6e, 0x6f, 0x64, 0x01, 0x28, 0x03, 0x52, 0x08, 0x6f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x49, 0x64, 0x22, 0xc5, 0x02,
0x65, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x6e, 0x6f, 0x64, 0x65, 0x49, 0x0a, 0x13, 0x4c, 0x69, 0x73, 0x74, 0x4e, 0x6f, 0x64, 0x65, 0x4c, 0x6f, 0x67, 0x73, 0x52, 0x65,
0x64, 0x12, 0x12, 0x0a, 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x6e, 0x6f, 0x64, 0x65, 0x49, 0x64, 0x18,
0x04, 0x72, 0x6f, 0x6c, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x6e, 0x6f, 0x64, 0x65, 0x49, 0x64, 0x12, 0x12, 0x0a,
0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x72, 0x6f, 0x6c,
0x04, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28,
0x65, 0x12, 0x18, 0x0a, 0x07, 0x64, 0x61, 0x79, 0x46, 0x72, 0x6f, 0x6d, 0x18, 0x05, 0x20, 0x01, 0x03, 0x52, 0x06, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x69, 0x7a,
0x28, 0x09, 0x52, 0x07, 0x64, 0x61, 0x79, 0x46, 0x72, 0x6f, 0x6d, 0x12, 0x14, 0x0a, 0x05, 0x64, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x12, 0x18, 0x0a,
0x61, 0x79, 0x54, 0x6f, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x64, 0x61, 0x79, 0x54, 0x07, 0x64, 0x61, 0x79, 0x46, 0x72, 0x6f, 0x6d, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07,
0x6f, 0x12, 0x18, 0x0a, 0x07, 0x6b, 0x65, 0x79, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x07, 0x20, 0x01, 0x64, 0x61, 0x79, 0x46, 0x72, 0x6f, 0x6d, 0x12, 0x14, 0x0a, 0x05, 0x64, 0x61, 0x79, 0x54, 0x6f,
0x28, 0x09, 0x52, 0x07, 0x6b, 0x65, 0x79, 0x77, 0x6f, 0x72, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x64, 0x61, 0x79, 0x54, 0x6f, 0x12, 0x18, 0x0a,
0x65, 0x76, 0x65, 0x6c, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6c, 0x65, 0x76, 0x65, 0x07, 0x6b, 0x65, 0x79, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07,
0x6c, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x49, 0x64, 0x18, 0x09, 0x20, 0x6b, 0x65, 0x79, 0x77, 0x6f, 0x72, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x65, 0x76, 0x65, 0x6c,
0x01, 0x28, 0x03, 0x52, 0x08, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x49, 0x64, 0x12, 0x1e, 0x0a, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x12, 0x1a, 0x0a,
0x0a, 0x66, 0x69, 0x78, 0x65, 0x64, 0x53, 0x74, 0x61, 0x74, 0x65, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x08, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x49, 0x64, 0x18, 0x09, 0x20, 0x01, 0x28, 0x03, 0x52,
0x05, 0x52, 0x0a, 0x66, 0x69, 0x78, 0x65, 0x64, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x1e, 0x0a, 0x08, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x49, 0x64, 0x12, 0x1e, 0x0a, 0x0a, 0x66, 0x69, 0x78,
0x0a, 0x61, 0x6c, 0x6c, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x73, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x65, 0x64, 0x53, 0x74, 0x61, 0x74, 0x65, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x66,
0x08, 0x52, 0x0a, 0x61, 0x6c, 0x6c, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x73, 0x22, 0x3f, 0x0a, 0x69, 0x78, 0x65, 0x64, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x61, 0x6c, 0x6c,
0x14, 0x4c, 0x69, 0x73, 0x74, 0x4e, 0x6f, 0x64, 0x65, 0x4c, 0x6f, 0x67, 0x73, 0x52, 0x65, 0x73, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x73, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x61,
0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x27, 0x0a, 0x08, 0x6e, 0x6f, 0x64, 0x65, 0x4c, 0x6f, 0x67, 0x6c, 0x6c, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x6f, 0x72, 0x69,
0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x70, 0x62, 0x2e, 0x4e, 0x6f, 0x64, 0x67, 0x69, 0x6e, 0x49, 0x64, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x6f, 0x72, 0x69,
0x65, 0x4c, 0x6f, 0x67, 0x52, 0x08, 0x6e, 0x6f, 0x64, 0x65, 0x4c, 0x6f, 0x67, 0x73, 0x22, 0x31, 0x67, 0x69, 0x6e, 0x49, 0x64, 0x22, 0x3f, 0x0a, 0x14, 0x4c, 0x69, 0x73, 0x74, 0x4e, 0x6f, 0x64,
0x0a, 0x11, 0x46, 0x69, 0x78, 0x4e, 0x6f, 0x64, 0x65, 0x4c, 0x6f, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x4c, 0x6f, 0x67, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x27, 0x0a,
0x65, 0x73, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x6e, 0x6f, 0x64, 0x65, 0x4c, 0x6f, 0x67, 0x49, 0x64, 0x08, 0x6e, 0x6f, 0x64, 0x65, 0x4c, 0x6f, 0x67, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32,
0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x6e, 0x6f, 0x64, 0x65, 0x4c, 0x6f, 0x67, 0x49, 0x0b, 0x2e, 0x70, 0x62, 0x2e, 0x4e, 0x6f, 0x64, 0x65, 0x4c, 0x6f, 0x67, 0x52, 0x08, 0x6e, 0x6f,
0x64, 0x32, 0x92, 0x02, 0x0a, 0x0e, 0x4e, 0x6f, 0x64, 0x65, 0x4c, 0x6f, 0x67, 0x53, 0x65, 0x72, 0x64, 0x65, 0x4c, 0x6f, 0x67, 0x73, 0x22, 0x31, 0x0a, 0x11, 0x46, 0x69, 0x78, 0x4e, 0x6f, 0x64,
0x76, 0x69, 0x63, 0x65, 0x12, 0x47, 0x0a, 0x0e, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4e, 0x6f, 0x65, 0x4c, 0x6f, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x6e,
0x64, 0x65, 0x4c, 0x6f, 0x67, 0x73, 0x12, 0x19, 0x2e, 0x70, 0x62, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x6f, 0x64, 0x65, 0x4c, 0x6f, 0x67, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09,
0x74, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x4c, 0x6f, 0x67, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x6e, 0x6f, 0x64, 0x65, 0x4c, 0x6f, 0x67, 0x49, 0x64, 0x32, 0x92, 0x02, 0x0a, 0x0e, 0x4e, 0x6f,
0x74, 0x1a, 0x1a, 0x2e, 0x70, 0x62, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4e, 0x6f, 0x64, 0x64, 0x65, 0x4c, 0x6f, 0x67, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x47, 0x0a, 0x0e,
0x65, 0x4c, 0x6f, 0x67, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3f, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x4c, 0x6f, 0x67, 0x73, 0x12, 0x19,
0x0d, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x4e, 0x6f, 0x64, 0x65, 0x4c, 0x6f, 0x67, 0x73, 0x12, 0x18, 0x2e, 0x70, 0x62, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x4c, 0x6f,
0x2e, 0x70, 0x62, 0x2e, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x4e, 0x6f, 0x64, 0x65, 0x4c, 0x6f, 0x67, 0x67, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x70, 0x62, 0x2e, 0x43,
0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x70, 0x62, 0x2e, 0x52, 0x50, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x4c, 0x6f, 0x67, 0x73, 0x52, 0x65, 0x73,
0x43, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x41, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3f, 0x0a, 0x0d, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x4e, 0x6f,
0x0a, 0x0c, 0x6c, 0x69, 0x73, 0x74, 0x4e, 0x6f, 0x64, 0x65, 0x4c, 0x6f, 0x67, 0x73, 0x12, 0x17, 0x64, 0x65, 0x4c, 0x6f, 0x67, 0x73, 0x12, 0x18, 0x2e, 0x70, 0x62, 0x2e, 0x43, 0x6f, 0x75, 0x6e,
0x2e, 0x70, 0x62, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x4e, 0x6f, 0x64, 0x65, 0x4c, 0x6f, 0x67, 0x73, 0x74, 0x4e, 0x6f, 0x64, 0x65, 0x4c, 0x6f, 0x67, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x70, 0x62, 0x2e, 0x4c, 0x69, 0x73, 0x1a, 0x14, 0x2e, 0x70, 0x62, 0x2e, 0x52, 0x50, 0x43, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x65,
0x74, 0x4e, 0x6f, 0x64, 0x65, 0x4c, 0x6f, 0x67, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x41, 0x0a, 0x0c, 0x6c, 0x69, 0x73, 0x74, 0x4e, 0x6f,
0x65, 0x12, 0x33, 0x0a, 0x0a, 0x66, 0x69, 0x78, 0x4e, 0x6f, 0x64, 0x65, 0x4c, 0x6f, 0x67, 0x12, 0x64, 0x65, 0x4c, 0x6f, 0x67, 0x73, 0x12, 0x17, 0x2e, 0x70, 0x62, 0x2e, 0x4c, 0x69, 0x73, 0x74,
0x15, 0x2e, 0x70, 0x62, 0x2e, 0x46, 0x69, 0x78, 0x4e, 0x6f, 0x64, 0x65, 0x4c, 0x6f, 0x67, 0x52, 0x4e, 0x6f, 0x64, 0x65, 0x4c, 0x6f, 0x67, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a,
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0e, 0x2e, 0x70, 0x62, 0x2e, 0x52, 0x50, 0x43, 0x53, 0x18, 0x2e, 0x70, 0x62, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x4e, 0x6f, 0x64, 0x65, 0x4c, 0x6f, 0x67,
0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x33, 0x0a, 0x0a, 0x66, 0x69, 0x78,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 0x4e, 0x6f, 0x64, 0x65, 0x4c, 0x6f, 0x67, 0x12, 0x15, 0x2e, 0x70, 0x62, 0x2e, 0x46, 0x69, 0x78,
0x4e, 0x6f, 0x64, 0x65, 0x4c, 0x6f, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0e,
0x2e, 0x70, 0x62, 0x2e, 0x52, 0x50, 0x43, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x42, 0x06,
0x5a, 0x04, 0x2e, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
} }
var ( var (

View File

@@ -14,4 +14,5 @@ message NodeLog {
int32 count = 8; int32 count = 8;
int64 serverId = 9; int64 serverId = 9;
bool isFixed = 10; bool isFixed = 10;
int64 originId = 11;
} }

View File

@@ -39,6 +39,7 @@ message CountNodeLogsRequest {
string keyword = 5; string keyword = 5;
string level = 6; string level = 6;
int64 serverId = 7; int64 serverId = 7;
int64 originId = 8;
} }
// 列出单页日志 // 列出单页日志
@@ -55,6 +56,7 @@ message ListNodeLogsRequest {
int64 serverId = 9; int64 serverId = 9;
int32 fixedState = 10; int32 fixedState = 10;
bool allServers = 11; // 是否获取所有服务相关的日志 bool allServers = 11; // 是否获取所有服务相关的日志
int64 originId = 12;
} }
message ListNodeLogsResponse { message ListNodeLogsResponse {

View File

@@ -10,7 +10,7 @@ import (
"time" "time"
) )
// 源站服务配置 // OriginConfig 源站服务配置
type OriginConfig struct { type OriginConfig struct {
Id int64 `yaml:"id" json:"id"` // ID Id int64 `yaml:"id" json:"id"` // ID
IsOn bool `yaml:"isOn" json:"isOn"` // 是否启用 IsOn bool `yaml:"isOn" json:"isOn"` // 是否启用
@@ -48,6 +48,8 @@ type OriginConfig struct {
FTPServerRef *FTPServerRef `yaml:"ftpServerRef" json:"ftpServerRef"` // TODO FTPServerRef *FTPServerRef `yaml:"ftpServerRef" json:"ftpServerRef"` // TODO
FTPServer *FTPServerConfig `yaml:"ftpServer" json:"ftpServer"` // TODO FTPServer *FTPServerConfig `yaml:"ftpServer" json:"ftpServer"` // TODO
IsOk bool `yaml:"isOk" json:"isOk"` // 是否可以正常访问
connTimeoutDuration time.Duration connTimeoutDuration time.Duration
readTimeoutDuration time.Duration readTimeoutDuration time.Duration
idleTimeoutDuration time.Duration idleTimeoutDuration time.Duration
@@ -65,8 +67,10 @@ type OriginConfig struct {
requestURIHasVariables bool requestURIHasVariables bool
} }
// 校验 // Init 校验
func (this *OriginConfig) Init() error { func (this *OriginConfig) Init() error {
this.IsOk = true
// URL // URL
this.requestHostHasVariables = configutils.HasVariables(this.RequestHost) this.requestHostHasVariables = configutils.HasVariables(this.RequestHost)
this.requestURIHasVariables = configutils.HasVariables(this.RequestURI) this.requestURIHasVariables = configutils.HasVariables(this.RequestURI)
@@ -157,7 +161,7 @@ func (this *OriginConfig) Init() error {
return nil return nil
} }
// 候选对象代号 // CandidateCodes 候选对象代号
func (this *OriginConfig) CandidateCodes() []string { func (this *OriginConfig) CandidateCodes() []string {
codes := []string{strconv.FormatInt(this.Id, 10)} codes := []string{strconv.FormatInt(this.Id, 10)}
if len(this.Code) > 0 { if len(this.Code) > 0 {
@@ -166,37 +170,37 @@ func (this *OriginConfig) CandidateCodes() []string {
return codes return codes
} }
// 候选对象权重 // CandidateWeight 候选对象权重
func (this *OriginConfig) CandidateWeight() uint { func (this *OriginConfig) CandidateWeight() uint {
return this.Weight return this.Weight
} }
// 连接超时时间 // ConnTimeoutDuration 连接超时时间
func (this *OriginConfig) ConnTimeoutDuration() time.Duration { func (this *OriginConfig) ConnTimeoutDuration() time.Duration {
return this.connTimeoutDuration return this.connTimeoutDuration
} }
// 读取超时时间 // ReadTimeoutDuration 读取超时时间
func (this *OriginConfig) ReadTimeoutDuration() time.Duration { func (this *OriginConfig) ReadTimeoutDuration() time.Duration {
return this.readTimeoutDuration return this.readTimeoutDuration
} }
// 休眠超时时间 // IdleTimeoutDuration 休眠超时时间
func (this *OriginConfig) IdleTimeoutDuration() time.Duration { func (this *OriginConfig) IdleTimeoutDuration() time.Duration {
return this.idleTimeoutDuration return this.idleTimeoutDuration
} }
// 判断RequestHost是否有变量 // RequestHostHasVariables 判断RequestHost是否有变量
func (this *OriginConfig) RequestHostHasVariables() bool { func (this *OriginConfig) RequestHostHasVariables() bool {
return this.requestHostHasVariables return this.requestHostHasVariables
} }
// 判断RequestURI是否有变量 // RequestURIHasVariables 判断RequestURI是否有变量
func (this *OriginConfig) RequestURIHasVariables() bool { func (this *OriginConfig) RequestURIHasVariables() bool {
return this.requestURIHasVariables return this.requestURIHasVariables
} }
// 唯一Key // UniqueKey 唯一Key
func (this *OriginConfig) UniqueKey() string { func (this *OriginConfig) UniqueKey() string {
return this.uniqueKey return this.uniqueKey
} }

View File

@@ -16,7 +16,7 @@ const (
RequestHostTypeCustomized RequestHostType = 2 RequestHostTypeCustomized RequestHostType = 2
) )
// 反向代理设置 // ReverseProxyConfig 反向代理设置
type ReverseProxyConfig struct { type ReverseProxyConfig struct {
Id int64 `yaml:"id" json:"id"` // ID Id int64 `yaml:"id" json:"id"` // ID
IsOn bool `yaml:"isOn" json:"isOn"` // 是否启用 IsOn bool `yaml:"isOn" json:"isOn"` // 是否启用
@@ -59,7 +59,7 @@ type ReverseProxyConfig struct {
addXForwardedProtoHeader bool addXForwardedProtoHeader bool
} }
// 初始化 // Init 初始化
func (this *ReverseProxyConfig) Init() error { func (this *ReverseProxyConfig) Init() error {
this.requestHostHasVariables = configutils.HasVariables(this.RequestHost) this.requestHostHasVariables = configutils.HasVariables(this.RequestHost)
this.requestURIHasVariables = configutils.HasVariables(this.RequestURI) this.requestURIHasVariables = configutils.HasVariables(this.RequestURI)
@@ -98,7 +98,7 @@ func (this *ReverseProxyConfig) Init() error {
} }
// scheduling // scheduling
this.SetupScheduling(false) this.SetupScheduling(false, false, true)
// Header // Header
if len(this.AddHeaders) == 0 { if len(this.AddHeaders) == 0 {
@@ -119,17 +119,17 @@ func (this *ReverseProxyConfig) Init() error {
return nil return nil
} }
// 添加主源站配置 // AddPrimaryOrigin 添加主源站配置
func (this *ReverseProxyConfig) AddPrimaryOrigin(origin *OriginConfig) { func (this *ReverseProxyConfig) AddPrimaryOrigin(origin *OriginConfig) {
this.PrimaryOrigins = append(this.PrimaryOrigins, origin) this.PrimaryOrigins = append(this.PrimaryOrigins, origin)
} }
// 添加备用源站配置 // AddBackupOrigin 添加备用源站配置
func (this *ReverseProxyConfig) AddBackupOrigin(origin *OriginConfig) { func (this *ReverseProxyConfig) AddBackupOrigin(origin *OriginConfig) {
this.BackupOrigins = append(this.BackupOrigins, origin) this.BackupOrigins = append(this.BackupOrigins, origin)
} }
// 取得下一个可用的后端服务 // NextOrigin 取得下一个可用的后端服务
func (this *ReverseProxyConfig) NextOrigin(call *shared.RequestCall) *OriginConfig { func (this *ReverseProxyConfig) NextOrigin(call *shared.RequestCall) *OriginConfig {
this.schedulingLocker.Lock() this.schedulingLocker.Lock()
defer this.schedulingLocker.Unlock() defer this.schedulingLocker.Unlock()
@@ -145,16 +145,33 @@ func (this *ReverseProxyConfig) NextOrigin(call *shared.RequestCall) *OriginConf
} }
candidate := this.schedulingObject.Next(call) candidate := this.schedulingObject.Next(call)
// 末了重置状态
defer func() {
if candidate == nil {
this.schedulingIsBackup = false
}
}()
if candidate == nil { if candidate == nil {
// 启用备用服务器 // 启用备用服务器
if !this.schedulingIsBackup { if !this.schedulingIsBackup {
this.SetupScheduling(true) this.SetupScheduling(true, true, false)
candidate = this.schedulingObject.Next(call)
if candidate == nil {
// 不检查主要源站
this.SetupScheduling(false, false, false)
candidate = this.schedulingObject.Next(call)
if candidate == nil {
// 不检查备用源站
this.SetupScheduling(true, false, false)
candidate = this.schedulingObject.Next(call) candidate = this.schedulingObject.Next(call)
if candidate == nil { if candidate == nil {
return nil return nil
} }
} }
}
}
if candidate == nil { if candidate == nil {
return nil return nil
@@ -164,12 +181,13 @@ func (this *ReverseProxyConfig) NextOrigin(call *shared.RequestCall) *OriginConf
return candidate.(*OriginConfig) return candidate.(*OriginConfig)
} }
// 设置调度算法 // SetupScheduling 设置调度算法
func (this *ReverseProxyConfig) SetupScheduling(isBackup bool) { func (this *ReverseProxyConfig) SetupScheduling(isBackup bool, checkOk bool, lock bool) {
if !isBackup { if lock {
this.schedulingLocker.Lock() this.schedulingLocker.Lock()
defer this.schedulingLocker.Unlock() defer this.schedulingLocker.Unlock()
} }
this.schedulingIsBackup = isBackup this.schedulingIsBackup = isBackup
if this.Scheduling == nil { if this.Scheduling == nil {
@@ -187,22 +205,26 @@ func (this *ReverseProxyConfig) SetupScheduling(isBackup bool) {
if !isBackup { if !isBackup {
for _, origin := range this.PrimaryOrigins { for _, origin := range this.PrimaryOrigins {
if origin.IsOn { if origin.IsOn && (origin.IsOk || !checkOk) {
this.schedulingObject.Add(origin) this.schedulingObject.Add(origin)
} }
} }
} else { } else {
for _, origin := range this.BackupOrigins { for _, origin := range this.BackupOrigins {
if origin.IsOn { if origin.IsOn && (origin.IsOk || !checkOk) {
this.schedulingObject.Add(origin) this.schedulingObject.Add(origin)
} }
} }
} }
if !this.schedulingObject.HasCandidates() {
return
}
this.schedulingObject.Start() this.schedulingObject.Start()
} }
// 获取调度配置对象 // FindSchedulingConfig 获取调度配置对象
func (this *ReverseProxyConfig) FindSchedulingConfig() *SchedulingConfig { func (this *ReverseProxyConfig) FindSchedulingConfig() *SchedulingConfig {
if this.Scheduling == nil { if this.Scheduling == nil {
this.Scheduling = &SchedulingConfig{Code: "random"} this.Scheduling = &SchedulingConfig{Code: "random"}
@@ -210,37 +232,42 @@ func (this *ReverseProxyConfig) FindSchedulingConfig() *SchedulingConfig {
return this.Scheduling return this.Scheduling
} }
// 判断RequestHost是否有变量 // RequestHostHasVariables 判断RequestHost是否有变量
func (this *ReverseProxyConfig) RequestHostHasVariables() bool { func (this *ReverseProxyConfig) RequestHostHasVariables() bool {
return this.requestHostHasVariables return this.requestHostHasVariables
} }
// 判断RequestURI是否有变量 // RequestURIHasVariables 判断RequestURI是否有变量
func (this *ReverseProxyConfig) RequestURIHasVariables() bool { func (this *ReverseProxyConfig) RequestURIHasVariables() bool {
return this.requestURIHasVariables return this.requestURIHasVariables
} }
// 是否添加X-Real-IP // ShouldAddXRealIPHeader 是否添加X-Real-IP
func (this *ReverseProxyConfig) ShouldAddXRealIPHeader() bool { func (this *ReverseProxyConfig) ShouldAddXRealIPHeader() bool {
return this.addXRealIPHeader return this.addXRealIPHeader
} }
// 是否添加X-Forwarded-For // ShouldAddXForwardedForHeader 是否添加X-Forwarded-For
func (this *ReverseProxyConfig) ShouldAddXForwardedForHeader() bool { func (this *ReverseProxyConfig) ShouldAddXForwardedForHeader() bool {
return this.addXForwardedForHeader return this.addXForwardedForHeader
} }
// 是否添加X-Forwarded-By // ShouldAddXForwardedByHeader 是否添加X-Forwarded-By
func (this *ReverseProxyConfig) ShouldAddXForwardedByHeader() bool { func (this *ReverseProxyConfig) ShouldAddXForwardedByHeader() bool {
return this.addXForwardedByHeader return this.addXForwardedByHeader
} }
// 是否添加X-Forwarded-Host // ShouldAddXForwardedHostHeader 是否添加X-Forwarded-Host
func (this *ReverseProxyConfig) ShouldAddXForwardedHostHeader() bool { func (this *ReverseProxyConfig) ShouldAddXForwardedHostHeader() bool {
return this.addXForwardedHostHeader return this.addXForwardedHostHeader
} }
// 是否添加X-Forwarded-Proto // ShouldAddXForwardedProtoHeader 是否添加X-Forwarded-Proto
func (this *ReverseProxyConfig) ShouldAddXForwardedProtoHeader() bool { func (this *ReverseProxyConfig) ShouldAddXForwardedProtoHeader() bool {
return this.addXForwardedProtoHeader return this.addXForwardedProtoHeader
} }
// ResetScheduling 重置调度算法
func (this *ReverseProxyConfig) ResetScheduling() {
this.SetupScheduling(false, true, true)
}

View File

@@ -2,7 +2,7 @@ package schedulingconfigs
import "github.com/iwind/TeaGo/maps" import "github.com/iwind/TeaGo/maps"
// 所有请求类型 // AllSchedulingTypes 所有请求类型
func AllSchedulingTypes() []maps.Map { func AllSchedulingTypes() []maps.Map {
types := []maps.Map{} types := []maps.Map{}
for _, s := range []SchedulingInterface{ for _, s := range []SchedulingInterface{

View File

@@ -0,0 +1,11 @@
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
package schedulingconfigs
import "testing"
func TestFindSchedulingType(t *testing.T) {
t.Logf("%p", FindSchedulingType("roundRobin"))
t.Logf("%p", FindSchedulingType("roundRobin"))
t.Logf("%p", FindSchedulingType("roundRobin"))
}