mirror of
https://github.com/TeaOSLab/EdgeCommon.git
synced 2025-11-09 16:50:25 +08:00
实现基本的访问日志策略
This commit is contained in:
@@ -36,6 +36,7 @@ type HTTPAccessLogPolicy struct {
|
|||||||
Type string `protobuf:"bytes,4,opt,name=type,proto3" json:"type,omitempty"`
|
Type string `protobuf:"bytes,4,opt,name=type,proto3" json:"type,omitempty"`
|
||||||
OptionsJSON []byte `protobuf:"bytes,5,opt,name=optionsJSON,proto3" json:"optionsJSON,omitempty"`
|
OptionsJSON []byte `protobuf:"bytes,5,opt,name=optionsJSON,proto3" json:"optionsJSON,omitempty"`
|
||||||
CondsJSON []byte `protobuf:"bytes,6,opt,name=condsJSON,proto3" json:"condsJSON,omitempty"`
|
CondsJSON []byte `protobuf:"bytes,6,opt,name=condsJSON,proto3" json:"condsJSON,omitempty"`
|
||||||
|
IsPublic bool `protobuf:"varint,7,opt,name=isPublic,proto3" json:"isPublic,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *HTTPAccessLogPolicy) Reset() {
|
func (x *HTTPAccessLogPolicy) Reset() {
|
||||||
@@ -112,13 +113,20 @@ func (x *HTTPAccessLogPolicy) GetCondsJSON() []byte {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (x *HTTPAccessLogPolicy) GetIsPublic() bool {
|
||||||
|
if x != nil {
|
||||||
|
return x.IsPublic
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
var File_models_model_http_access_log_policy_proto protoreflect.FileDescriptor
|
var File_models_model_http_access_log_policy_proto protoreflect.FileDescriptor
|
||||||
|
|
||||||
var file_models_model_http_access_log_policy_proto_rawDesc = []byte{
|
var file_models_model_http_access_log_policy_proto_rawDesc = []byte{
|
||||||
0x0a, 0x29, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x73, 0x2f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x5f, 0x68,
|
0x0a, 0x29, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x73, 0x2f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x5f, 0x68,
|
||||||
0x74, 0x74, 0x70, 0x5f, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x5f, 0x6c, 0x6f, 0x67, 0x5f, 0x70,
|
0x74, 0x74, 0x70, 0x5f, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x5f, 0x6c, 0x6f, 0x67, 0x5f, 0x70,
|
||||||
0x6f, 0x6c, 0x69, 0x63, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x02, 0x70, 0x62, 0x22,
|
0x6f, 0x6c, 0x69, 0x63, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x02, 0x70, 0x62, 0x22,
|
||||||
0xa1, 0x01, 0x0a, 0x13, 0x48, 0x54, 0x54, 0x50, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x4c, 0x6f,
|
0xbd, 0x01, 0x0a, 0x13, 0x48, 0x54, 0x54, 0x50, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x4c, 0x6f,
|
||||||
0x67, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20,
|
0x67, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20,
|
||||||
0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18,
|
0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18,
|
||||||
0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x69,
|
0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x69,
|
||||||
@@ -128,8 +136,9 @@ var file_models_model_http_access_log_policy_proto_rawDesc = []byte{
|
|||||||
0x4f, 0x4e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0b, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e,
|
0x4f, 0x4e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0b, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e,
|
||||||
0x73, 0x4a, 0x53, 0x4f, 0x4e, 0x12, 0x1c, 0x0a, 0x09, 0x63, 0x6f, 0x6e, 0x64, 0x73, 0x4a, 0x53,
|
0x73, 0x4a, 0x53, 0x4f, 0x4e, 0x12, 0x1c, 0x0a, 0x09, 0x63, 0x6f, 0x6e, 0x64, 0x73, 0x4a, 0x53,
|
||||||
0x4f, 0x4e, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x63, 0x6f, 0x6e, 0x64, 0x73, 0x4a,
|
0x4f, 0x4e, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x63, 0x6f, 0x6e, 0x64, 0x73, 0x4a,
|
||||||
0x53, 0x4f, 0x4e, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f,
|
0x53, 0x4f, 0x4e, 0x12, 0x1a, 0x0a, 0x08, 0x69, 0x73, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x18,
|
||||||
0x74, 0x6f, 0x33,
|
0x07, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x69, 0x73, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x42,
|
||||||
|
0x06, 0x5a, 0x04, 0x2e, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -10,4 +10,5 @@ message HTTPAccessLogPolicy {
|
|||||||
string type = 4;
|
string type = 4;
|
||||||
bytes optionsJSON = 5;
|
bytes optionsJSON = 5;
|
||||||
bytes condsJSON = 6;
|
bytes condsJSON = 6;
|
||||||
|
bool isPublic = 7;
|
||||||
}
|
}
|
||||||
@@ -4,18 +4,86 @@ option go_package = "./pb";
|
|||||||
package pb;
|
package pb;
|
||||||
|
|
||||||
import "models/model_http_access_log_policy.proto";
|
import "models/model_http_access_log_policy.proto";
|
||||||
|
import "models/rpc_messages.proto";
|
||||||
|
import "models/model_http_access_log.proto";
|
||||||
|
|
||||||
service HTTPAccessLogPolicyService {
|
service HTTPAccessLogPolicyService {
|
||||||
// 获取所有可用策略
|
// 计算访问日志策略数量
|
||||||
rpc findAllEnabledHTTPAccessLogPolicies (FindAllEnabledHTTPAccessLogPoliciesRequest) returns (FindAllEnabledHTTPAccessLogPoliciesResponse);
|
rpc countAllEnabledHTTPAccessLogPolicies (CountAllEnabledHTTPAccessLogPoliciesRequest) returns (RPCCountResponse);
|
||||||
|
|
||||||
|
// 列出单页访问日志策略
|
||||||
|
rpc listEnabledHTTPAccessLogPolicies (ListEnabledHTTPAccessLogPoliciesRequest) returns (ListEnabledHTTPAccessLogPoliciesResponse);
|
||||||
|
|
||||||
|
// 创建访问日志策略
|
||||||
|
rpc createHTTPAccessLogPolicy (CreateHTTPAccessLogPolicyRequest) returns (CreateHTTPAccessLogPolicyResponse);
|
||||||
|
|
||||||
|
// 修改访问日志策略
|
||||||
|
rpc updateHTTPAccessLogPolicy (UpdateHTTPAccessLogPolicyRequest) returns (RPCSuccess);
|
||||||
|
|
||||||
|
// 查找单个访问日志策略
|
||||||
|
rpc findEnabledHTTPAccessLogPolicy (FindEnabledHTTPAccessLogPolicyRequest) returns (FindEnabledHTTPAccessLogPolicyResponse);
|
||||||
|
|
||||||
|
// 删除访问日志策略
|
||||||
|
rpc deleteHTTPAccessLogPolicy (DeleteHTTPAccessLogPolicyRequest) returns (RPCSuccess);
|
||||||
|
|
||||||
|
// 测试写入某个访问日志策略
|
||||||
|
rpc writeHTTPAccessLogPolicy (WriteHTTPAccessLogPolicyRequest) returns (RPCSuccess);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取所有可用策略
|
// 计算访问日志策略数量
|
||||||
message FindAllEnabledHTTPAccessLogPoliciesRequest {
|
message CountAllEnabledHTTPAccessLogPoliciesRequest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
message FindAllEnabledHTTPAccessLogPoliciesResponse {
|
// 列出单页访问日志策略
|
||||||
repeated HTTPAccessLogPolicy accessLogPolicies = 1;
|
message ListEnabledHTTPAccessLogPoliciesRequest {
|
||||||
|
int64 offset = 1;
|
||||||
|
int64 size = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message ListEnabledHTTPAccessLogPoliciesResponse {
|
||||||
|
repeated HTTPAccessLogPolicy httpAccessLogPolicies = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 创建访问日志策略
|
||||||
|
message CreateHTTPAccessLogPolicyRequest {
|
||||||
|
string name = 1;
|
||||||
|
string type = 2;
|
||||||
|
bytes optionsJSON = 3;
|
||||||
|
bytes condsJSON = 4;
|
||||||
|
bool isPublic = 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
message CreateHTTPAccessLogPolicyResponse {
|
||||||
|
int64 httpAccessLogPolicyId = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 修改访问日志策略
|
||||||
|
message UpdateHTTPAccessLogPolicyRequest {
|
||||||
|
int64 httpAccessLogPolicyId = 1;
|
||||||
|
string name = 2;
|
||||||
|
bool isOn = 3;
|
||||||
|
bytes optionsJSON = 4;
|
||||||
|
bytes condsJSON = 5;
|
||||||
|
bool isPublic = 6;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查找单个访问日志策略
|
||||||
|
message FindEnabledHTTPAccessLogPolicyRequest {
|
||||||
|
int64 httpAccessLogPolicyId = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message FindEnabledHTTPAccessLogPolicyResponse {
|
||||||
|
HTTPAccessLogPolicy httpAccessLogPolicy = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除策略
|
||||||
|
message DeleteHTTPAccessLogPolicyRequest {
|
||||||
|
int64 httpAccessLogPolicyId = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 测试写入某个访问日志策略
|
||||||
|
message WriteHTTPAccessLogPolicyRequest {
|
||||||
|
int64 httpAccessLogPolicyId = 1;
|
||||||
|
HTTPAccessLog httpAccessLog = 2;
|
||||||
|
}
|
||||||
10
pkg/serverconfigs/access_log_storage_command.go
Normal file
10
pkg/serverconfigs/access_log_storage_command.go
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
|
||||||
|
|
||||||
|
package serverconfigs
|
||||||
|
|
||||||
|
// AccessLogCommandStorageConfig 通过命令行存储
|
||||||
|
type AccessLogCommandStorageConfig struct {
|
||||||
|
Command string `yaml:"command" json:"command"`
|
||||||
|
Args []string `yaml:"args" json:"args"`
|
||||||
|
Dir string `yaml:"dir" json:"dir"`
|
||||||
|
}
|
||||||
12
pkg/serverconfigs/access_log_storage_es.go
Normal file
12
pkg/serverconfigs/access_log_storage_es.go
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
|
||||||
|
|
||||||
|
package serverconfigs
|
||||||
|
|
||||||
|
// AccessLogESStorageConfig ElasticSearch存储策略
|
||||||
|
type AccessLogESStorageConfig struct {
|
||||||
|
Endpoint string `yaml:"endpoint" json:"endpoint"`
|
||||||
|
Index string `yaml:"index" json:"index"`
|
||||||
|
MappingType string `yaml:"mappingType" json:"mappingType"`
|
||||||
|
Username string `yaml:"username" json:"username"`
|
||||||
|
Password string `yaml:"password" json:"password"`
|
||||||
|
}
|
||||||
9
pkg/serverconfigs/access_log_storage_file.go
Normal file
9
pkg/serverconfigs/access_log_storage_file.go
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
|
||||||
|
|
||||||
|
package serverconfigs
|
||||||
|
|
||||||
|
// AccessLogFileStorageConfig 文件存储配置
|
||||||
|
type AccessLogFileStorageConfig struct {
|
||||||
|
Path string `yaml:"path" json:"path"` // 文件路径,支持变量:${year|month|week|day|hour|minute|second}
|
||||||
|
AutoCreate bool `yaml:"autoCreate" json:"autoCreate"` // 是否自动创建目录
|
||||||
|
}
|
||||||
85
pkg/serverconfigs/access_log_storage_syslog.go
Normal file
85
pkg/serverconfigs/access_log_storage_syslog.go
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
|
||||||
|
|
||||||
|
package serverconfigs
|
||||||
|
|
||||||
|
import "github.com/iwind/TeaGo/maps"
|
||||||
|
|
||||||
|
type AccessLogSyslogStorageProtocol = string
|
||||||
|
|
||||||
|
const (
|
||||||
|
AccessLogSyslogStorageProtocolTCP AccessLogSyslogStorageProtocol = "tcp"
|
||||||
|
AccessLogSyslogStorageProtocolUDP AccessLogSyslogStorageProtocol = "udp"
|
||||||
|
AccessLogSyslogStorageProtocolNone AccessLogSyslogStorageProtocol = "none"
|
||||||
|
AccessLogSyslogStorageProtocolSocket AccessLogSyslogStorageProtocol = "socket"
|
||||||
|
)
|
||||||
|
|
||||||
|
type AccessLogSyslogStoragePriority = int
|
||||||
|
|
||||||
|
const (
|
||||||
|
AccessLogSyslogStoragePriorityEmerg AccessLogSyslogStoragePriority = iota
|
||||||
|
AccessLogSyslogStoragePriorityAlert
|
||||||
|
AccessLogSyslogStoragePriorityCrit
|
||||||
|
AccessLogSyslogStoragePriorityErr
|
||||||
|
AccessLogSyslogStoragePriorityWarning
|
||||||
|
AccessLogSyslogStoragePriorityNotice
|
||||||
|
AccessLogSyslogStoragePriorityInfo
|
||||||
|
AccessLogSyslogStoragePriorityDebug
|
||||||
|
)
|
||||||
|
|
||||||
|
var AccessLogSyslogStoragePriorities = []maps.Map{
|
||||||
|
{
|
||||||
|
"name": "[无]",
|
||||||
|
"value": -1,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "EMERG",
|
||||||
|
"value": AccessLogSyslogStoragePriorityEmerg,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "ALERT",
|
||||||
|
"value": AccessLogSyslogStoragePriorityAlert,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "CRIT",
|
||||||
|
"value": AccessLogSyslogStoragePriorityCrit,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "ERR",
|
||||||
|
"value": AccessLogSyslogStoragePriorityErr,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "WARNING",
|
||||||
|
"value": AccessLogSyslogStoragePriorityWarning,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "NOTICE",
|
||||||
|
"value": AccessLogSyslogStoragePriorityNotice,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "INFO",
|
||||||
|
"value": AccessLogSyslogStoragePriorityInfo,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "DEBUG",
|
||||||
|
"value": AccessLogSyslogStoragePriorityDebug,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// AccessLogSyslogStorageConfig syslog存储策略
|
||||||
|
type AccessLogSyslogStorageConfig struct {
|
||||||
|
Protocol string `yaml:"protocol" json:"protocol"` // SysLogStorageProtocol*
|
||||||
|
ServerAddr string `yaml:"serverAddr" json:"serverAddr"`
|
||||||
|
ServerPort int `yaml:"serverPort" json:"serverPort"`
|
||||||
|
Socket string `yaml:"socket" json:"socket"` // sock file
|
||||||
|
Tag string `yaml:"tag" json:"tag"`
|
||||||
|
Priority AccessLogSyslogStoragePriority `yaml:"priority" json:"priority"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func FindAccessLogSyslogStoragePriorityName(priority AccessLogSyslogStoragePriority) string {
|
||||||
|
for _, p := range AccessLogSyslogStoragePriorities {
|
||||||
|
if p.GetInt("value") == priority {
|
||||||
|
return p.GetString("name")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
9
pkg/serverconfigs/access_log_storage_tcp.go
Normal file
9
pkg/serverconfigs/access_log_storage_tcp.go
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
|
||||||
|
|
||||||
|
package serverconfigs
|
||||||
|
|
||||||
|
// AccessLogTCPStorageConfig TCP存储策略
|
||||||
|
type AccessLogTCPStorageConfig struct {
|
||||||
|
Network string `yaml:"network" json:"network"` // tcp, unix
|
||||||
|
Addr string `yaml:"addr" json:"addr"`
|
||||||
|
}
|
||||||
57
pkg/serverconfigs/access_log_storages.go
Normal file
57
pkg/serverconfigs/access_log_storages.go
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
package serverconfigs
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AccessLogStorageType 访问日志存储类型
|
||||||
|
type AccessLogStorageType = string
|
||||||
|
|
||||||
|
const (
|
||||||
|
AccessLogStorageTypeFile AccessLogStorageType = "file"
|
||||||
|
AccessLogStorageTypeES AccessLogStorageType = "es"
|
||||||
|
AccessLogStorageTypeTCP AccessLogStorageType = "tcp"
|
||||||
|
AccessLogStorageTypeSyslog AccessLogStorageType = "syslog"
|
||||||
|
AccessLogStorageTypeCommand AccessLogStorageType = "command"
|
||||||
|
)
|
||||||
|
|
||||||
|
// FindAllAccessLogStorageTypes 所有存储引擎列表
|
||||||
|
func FindAllAccessLogStorageTypes() []*shared.Definition {
|
||||||
|
return []*shared.Definition{
|
||||||
|
{
|
||||||
|
Name: "文件",
|
||||||
|
Code: AccessLogStorageTypeFile,
|
||||||
|
Description: "将日志存储在磁盘文件中",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "ElasticSearch",
|
||||||
|
Code: AccessLogStorageTypeES,
|
||||||
|
Description: "将日志存储在ElasticSearch中",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "TCP Socket",
|
||||||
|
Code: AccessLogStorageTypeTCP,
|
||||||
|
Description: "将日志通过TCP套接字输出",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "Syslog",
|
||||||
|
Code: AccessLogStorageTypeSyslog,
|
||||||
|
Description: "将日志通过syslog输出,仅支持Linux",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "命令行输入流",
|
||||||
|
Code: AccessLogStorageTypeCommand,
|
||||||
|
Description: "启动一个命令通过读取stdin接收日志信息",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// FindAccessLogStorageTypeName 根据类型查找名称
|
||||||
|
func FindAccessLogStorageTypeName(storageType string) string {
|
||||||
|
for _, m := range FindAllAccessLogStorageTypes() {
|
||||||
|
if m.Code == storageType {
|
||||||
|
return m.Name
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
package serverconfigs
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/configutils"
|
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared"
|
|
||||||
"github.com/iwind/TeaGo/maps"
|
|
||||||
)
|
|
||||||
|
|
||||||
// 日志存储策略
|
|
||||||
type HTTPAccessLogStoragePolicy struct {
|
|
||||||
Id int64 `yaml:"id" json:"id"`
|
|
||||||
Name string `yaml:"name" json:"name"`
|
|
||||||
IsOn bool `yaml:"isOn" json:"isOn"`
|
|
||||||
Type string `yaml:"type" json:"type"` // 存储类型
|
|
||||||
Options maps.Map `yaml:"options" json:"options"` // 存储选项
|
|
||||||
Conds *shared.HTTPRequestCondsConfig `yaml:"conds" json:"conds"` // 请求条件
|
|
||||||
}
|
|
||||||
|
|
||||||
// 校验
|
|
||||||
func (this *HTTPAccessLogStoragePolicy) Init() error {
|
|
||||||
// cond
|
|
||||||
if this.Conds != nil {
|
|
||||||
err := this.Conds.Init()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// 匹配关键词
|
|
||||||
func (this *HTTPAccessLogStoragePolicy) MatchKeyword(keyword string) (matched bool, name string, tags []string) {
|
|
||||||
if configutils.MatchKeyword(this.Name, keyword) || configutils.MatchKeyword(this.Type, keyword) {
|
|
||||||
matched = true
|
|
||||||
name = this.Name
|
|
||||||
if len(this.Type) > 0 {
|
|
||||||
tags = []string{"类型:" + this.Type}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user