Documentation
¶
Overview ¶
Package dialtesting defined dialtesting tasks and task implements.
Index ¶
- Constants
- Variables
- func IsEnabledTraceroute(enabled bool) bool
- func Setup(c *TaskConfig)
- type ConfigVar
- type DialResult
- type GRPCAdvanceOption
- type GRPCHealthCheckDiscovery
- type GRPCOptCertificate
- type GRPCOptRequest
- type GRPCProtoFilesDiscovery
- type GRPCReflectionDiscovery
- type GRPCSecret
- type GRPCSuccess
- type GRPCTask
- type HTTPAdvanceOption
- type HTTPOptAuth
- type HTTPOptBody
- type HTTPOptBodyFile
- type HTTPOptCertificate
- type HTTPOptProxy
- type HTTPOptRequest
- type HTTPSecret
- type HTTPSuccess
- type HTTPTask
- type ICMP
- type ICMPSuccess
- type ICMPTask
- type ITask
- type MultiExtractedVar
- type MultiStep
- type MultiStepRetry
- type MultiTask
- type Packet
- type Response
- type ResponseTimeSucess
- type Route
- type RouteItem
- type ScriptGRPCMessage
- type ScriptGRPCRequestResponse
- type ScriptHTTPMessage
- type ScriptHTTPRequestResponse
- type ScriptHTTPResult
- type ScriptResult
- type SuccessOption
- type TCPResponseTime
- type TCPSuccess
- type TCPTask
- type Task
- func (t *Task) AccessKey() string
- func (t *Task) AddExtractedVar(v *ConfigVar)
- func (t *Task) Check() error
- func (t *Task) CheckResult() ([]string, bool)
- func (t *Task) CheckTask() error
- func (t *Task) Class() string
- func (t *Task) Clear()
- func (t *Task) GetCrontab() string
- func (t *Task) GetDFLabel() string
- func (t *Task) GetExternalID() string
- func (t *Task) GetFrequency() string
- func (t *Task) GetGlobalVars() []string
- func (t *Task) GetHostName() ([]string, error)
- func (t *Task) GetIsTemplate() bool
- func (t *Task) GetLineData() string
- func (t *Task) GetOption() map[string]string
- func (t *Task) GetOwnerExternalID() string
- func (t *Task) GetParsedString(text string, fm template.FuncMap) (string, error)
- func (t *Task) GetPostScriptVars() Vars
- func (t *Task) GetResults() (tags map[string]string, fields map[string]interface{})
- func (t *Task) GetScheduleType() string
- func (t *Task) GetTaskJSONString() string
- func (t *Task) GetVariableValue(variable Variable) (string, error)
- func (t *Task) GetWorkspaceLanguage() string
- func (t *Task) ID() string
- func (t *Task) Init() error
- func (t *Task) MetricName() string
- func (t *Task) NewRawTask(child TaskChild) error
- func (t *Task) PostURLStr() string
- func (t *Task) RegionName() string
- func (t *Task) RenderTemplateAndInit(globalVariables map[string]Variable) error
- func (t *Task) Run() error
- func (t *Task) SetAk(ak string)
- func (t *Task) SetBeforeRun(beforeRun func(*Task) error)
- func (t *Task) SetChild(child TaskChild)
- func (t *Task) SetCustomVars(vars []*ConfigVar)
- func (t *Task) SetDisabled(disabled uint8)
- func (t *Task) SetIsTemplate(isTemplate bool)
- func (t *Task) SetOption(opt map[string]string)
- func (t *Task) SetOwnerExternalID(exid string)
- func (t *Task) SetRegionID(regionID string)
- func (t *Task) SetStatus(status string)
- func (t *Task) SetTaskJSONString(s string)
- func (t *Task) SetUpdateTime(ts int64)
- func (t *Task) Status() string
- func (t *Task) Stop()
- func (t *Task) String() string
- func (t *Task) UpdateTimeUs() int64
- type TaskChild
- type TaskConfig
- type Traceroute
- type TracerouteOption
- type ValueSuccess
- type Variable
- type Vars
- type WebsocketAdvanceOption
- type WebsocketOptAuth
- type WebsocketOptRequest
- type WebsocketResponseTime
- type WebsocketSuccess
- type WebsocketTask
Constants ¶
View Source
const ( DefaultGRPCTimeout = 30 * time.Second HealthCheckServiceName = "grpc.health.v1.Health" HealthCheckMethodName = "Check" )
View Source
const ( MaxBodySize = 10 * 1024 DefaultHTTPTimeout = 60 * time.Second )
View Source
const ( PingTimeout = 3 * time.Second DefaultICMPTTL = 64 )
View Source
const ( StatusStop = "stop" ClassHTTP = "HTTP" ClassTCP = "TCP" ClassWebsocket = "WEBSOCKET" ClassICMP = "ICMP" ClassGRPC = "GRPC" ClassDNS = "DNS" ClassHeadless = "BROWSER" ClassOther = "OTHER" ClassWait = "WAIT" ClassMulti = "MULTI" ScheduleTypeCron = "crontab" ScheduleTypeFrequency = "frequency" )
View Source
const ( MaxTimeout = 10 * time.Second MaxHops = 60 MaxRetry = 3 )
View Source
const MaxErrorMessageSize = 1024
Variables ¶
View Source
var ( MaxMsgSize = 100 * 1024 ICMPConcurrentCh chan struct{} )
View Source
var TypeVariableGlobal = "global"
Functions ¶
func IsEnabledTraceroute ¶
IsEnabledTraceroute return true when traceroute enabled and not windows.
func Setup ¶
func Setup(c *TaskConfig)
Types ¶
type DialResult ¶
type GRPCAdvanceOption ¶
type GRPCAdvanceOption struct {
RequestOptions *GRPCOptRequest `json:"request_options,omitempty"`
Certificate *GRPCOptCertificate `json:"certificate,omitempty"`
Secret *GRPCSecret `json:"secret,omitempty"`
}
type GRPCHealthCheckDiscovery ¶
type GRPCHealthCheckDiscovery struct {
Service string `json:"service,omitempty"`
}
type GRPCOptCertificate ¶
type GRPCOptRequest ¶
type GRPCOptRequest struct {
Metadata map[string]string `json:"metadata,omitempty"`
RequestTimeout string `json:"request_timeout,omitempty"`
ProtoFiles *GRPCProtoFilesDiscovery `json:"proto_files,omitempty"`
Reflection *GRPCReflectionDiscovery `json:"reflection,omitempty"`
HealthCheck *GRPCHealthCheckDiscovery `json:"health_check,omitempty"`
}
type GRPCProtoFilesDiscovery ¶
type GRPCReflectionDiscovery ¶
type GRPCSecret ¶
type GRPCSecret struct {
NoSaveResponseBody bool `json:"not_save,omitempty"`
}
type GRPCSuccess ¶
type GRPCSuccess struct {
Body []*SuccessOption `json:"body,omitempty"`
ResponseTime string `json:"response_time,omitempty"`
// contains filtered or unexported fields
}
type GRPCTask ¶
type GRPCTask struct {
*Task
Server string `json:"server"`
PostScript string `json:"post_script,omitempty"`
SuccessWhenLogic string `json:"success_when_logic"`
SuccessWhen []*GRPCSuccess `json:"success_when"`
AdvanceOptions *GRPCAdvanceOption `json:"advance_options,omitempty"`
// contains filtered or unexported fields
}
type HTTPAdvanceOption ¶
type HTTPAdvanceOption struct {
RequestOptions *HTTPOptRequest `json:"request_options,omitempty"`
RequestBody *HTTPOptBody `json:"request_body,omitempty"`
Certificate *HTTPOptCertificate `json:"certificate,omitempty"`
Proxy *HTTPOptProxy `json:"proxy,omitempty"`
Secret *HTTPSecret `json:"secret,omitempty"`
RequestTimeout string `json:"request_timeout,omitempty"`
}
type HTTPOptAuth ¶
type HTTPOptBody ¶
type HTTPOptBody struct {
BodyType string `json:"body_type,omitempty"`
Body string `json:"body,omitempty"`
Files []HTTPOptBodyFile `json:"files,omitempty"`
Form map[string]string `json:"form,omitempty"`
// contains filtered or unexported fields
}
type HTTPOptBodyFile ¶
type HTTPOptBodyFile struct {
Name string `json:"name"` // field name
Content string `json:"content"` // file content in base64
Type string `json:"type"` // file type, e.g. image/jpeg
Size int64 `json:"size"` // Content size
Encoding string `json:"encoding"` // Content encoding, base64 only
OriginalFileName string `json:"original_file_name"` // Original file name
FilePath string `json:"file_path,omitempty"` // file path in storage
Hash string `json:"_"`
}
type HTTPOptCertificate ¶
type HTTPOptProxy ¶
type HTTPOptRequest ¶
type HTTPOptRequest struct {
FollowRedirect bool `json:"follow_redirect,omitempty"`
Headers map[string]string `json:"headers,omitempty"`
Cookies string `json:"cookies,omitempty"`
Auth *HTTPOptAuth `json:"auth,omitempty"`
}
type HTTPSecret ¶
type HTTPSecret struct {
NoSaveResponseBody bool `json:"not_save,omitempty"`
}
type HTTPSuccess ¶
type HTTPSuccess struct {
Body []*SuccessOption `json:"body,omitempty"`
ResponseTime string `json:"response_time,omitempty"`
Header map[string][]*SuccessOption `json:"header,omitempty"`
StatusCode []*SuccessOption `json:"status_code,omitempty"`
// contains filtered or unexported fields
}
type HTTPTask ¶
type HTTPTask struct {
*Task
URL string `json:"url"`
Method string `json:"method"`
PostScript string `json:"post_script,omitempty"`
SuccessWhenLogic string `json:"success_when_logic"`
SuccessWhen []*HTTPSuccess `json:"success_when"`
AdvanceOptions *HTTPAdvanceOption `json:"advance_options,omitempty"`
// contains filtered or unexported fields
}
type ICMPSuccess ¶
type ICMPSuccess struct {
PacketLossPercent []*ValueSuccess `json:"packet_loss_percent,omitempty"`
ResponseTime []*ResponseTimeSucess `json:"response_time,omitempty"`
Hops []*ValueSuccess `json:"hops,omitempty"`
Packets []*ValueSuccess `json:"packets,omitempty"`
}
type ICMPTask ¶
type ICMPTask struct {
*Task
Host string `json:"host"`
PacketCount int `json:"packet_count"`
Timeout string `json:"timeout"`
EnableTraceroute bool `json:"enable_traceroute"`
TracerouteConfig *TracerouteOption `json:"traceroute_config"`
SuccessWhen []*ICMPSuccess `json:"success_when"`
SuccessWhenLogic string `json:"success_when_logic"`
// contains filtered or unexported fields
}
type ITask ¶
type ITask interface {
ID() string
Status() string
Run() error
Clear()
CheckResult() ([]string, bool)
Class() string
GetResults() (map[string]string, map[string]interface{})
PostURLStr() string
MetricName() string
Stop()
RegionName() string
AccessKey() string
Check() error
CheckTask() error
UpdateTimeUs() int64
GetFrequency() string
GetOwnerExternalID() string
GetExternalID() string
SetOwnerExternalID(string)
GetLineData() string
GetHostName() ([]string, error)
GetWorkspaceLanguage() string
GetDFLabel() string
GetScheduleType() string
GetCrontab() string
SetOption(map[string]string)
GetOption() map[string]string
SetRegionID(string)
SetAk(string)
SetStatus(string)
SetUpdateTime(int64)
SetChild(TaskChild)
SetTaskJSONString(string)
GetTaskJSONString() string
SetDisabled(uint8)
GetVariableValue(Variable) (string, error)
GetGlobalVars() []string
RenderTemplateAndInit(globalVariables map[string]Variable) error
AddExtractedVar(*ConfigVar)
SetCustomVars([]*ConfigVar)
GetPostScriptVars() Vars
GetIsTemplate() bool
SetIsTemplate(bool)
SetBeforeRun(func(*Task) error)
String() string
}
type MultiExtractedVar ¶
type MultiStep ¶
type MultiStep struct {
Type string `json:"type"` // http or wait
Name string `json:"name"` // name
AllowFailure bool `json:"allow_failure"`
Retry *MultiStepRetry `json:"retry"`
TaskString string `json:"task,omitempty"`
Value int `json:"value,omitempty"` // wait seconds for wait task
ExtractedVars []MultiExtractedVar `json:"extracted_vars,omitempty"`
// contains filtered or unexported fields
}
type MultiStepRetry ¶
type Response ¶
type Response struct {
From net.IP
ResponseTime time.Duration
// contains filtered or unexported fields
}
Response for sent packet, may be failed response when timeout.
type ResponseTimeSucess ¶
type Route ¶
type Route struct {
Total int `json:"total"`
Failed int `json:"failed"`
Loss float64 `json:"loss"`
AvgCost float64 `json:"avg_cost"`
MinCost float64 `json:"min_cost"`
MaxCost float64 `json:"max_cost"`
StdCost float64 `json:"std_cost"`
Items []*RouteItem `json:"items"`
}
Route is summary for each hop.
func TracerouteIP ¶
func TracerouteIP(ip string, opt *TracerouteOption) (routes []*Route, err error)
type ScriptGRPCMessage ¶
type ScriptGRPCMessage struct {
Response *ScriptGRPCRequestResponse `json:"response"`
Vars *Vars `json:"vars"`
}
type ScriptGRPCRequestResponse ¶
type ScriptGRPCRequestResponse struct {
Body string `json:"body"`
}
func (*ScriptGRPCRequestResponse) String ¶
func (h *ScriptGRPCRequestResponse) String() (string, error)
type ScriptHTTPMessage ¶
type ScriptHTTPMessage struct {
Response *ScriptHTTPRequestResponse `json:"response"`
Vars *Vars `json:"vars"`
}
func (*ScriptHTTPMessage) String ¶
func (m *ScriptHTTPMessage) String() (string, error)
type ScriptHTTPRequestResponse ¶
type ScriptHTTPRequestResponse struct {
Header http.Header `json:"header"`
Body string `json:"body"`
StatusCode int `json:"status_code"`
}
func (*ScriptHTTPRequestResponse) String ¶
func (h *ScriptHTTPRequestResponse) String() (string, error)
type ScriptHTTPResult ¶
type ScriptResult ¶
type ScriptResult struct {
Result ScriptHTTPResult `json:"result"`
Vars Vars `json:"vars"`
}
type SuccessOption ¶
type SuccessOption struct {
Is string `json:"is,omitempty"`
IsNot string `json:"is_not,omitempty"`
MatchRegex string `json:"match_regex,omitempty"`
NotMatchRegex string `json:"not_match_regex,omitempty"`
Contains string `json:"contains,omitempty"`
NotContains string `json:"not_contains,omitempty"`
// contains filtered or unexported fields
}
type TCPResponseTime ¶
type TCPSuccess ¶
type TCPSuccess struct {
ResponseTime []*TCPResponseTime `json:"response_time,omitempty"`
Hops []*ValueSuccess `json:"hops,omitempty"`
ResponseMessage []*SuccessOption `json:"response_message,omitempty"`
}
type TCPTask ¶
type TCPTask struct {
*Task
Host string `json:"host"`
Port string `json:"port"`
Message string `json:"message"`
Timeout string `json:"timeout"`
EnableTraceroute bool `json:"enable_traceroute"`
TracerouteConfig *TracerouteOption `json:"traceroute_config"`
SuccessWhen []*TCPSuccess `json:"success_when"`
SuccessWhenLogic string `json:"success_when_logic"`
// contains filtered or unexported fields
}
type Task ¶
type Task struct {
ExternalID string `json:"external_id"`
Name string `json:"name"`
AK string `json:"access_key"`
PostURL string `json:"post_url"`
CurStatus string `json:"status"`
Frequency string `json:"frequency"`
Region string `json:"region"`
OwnerExternalID string `json:"owner_external_id"`
WorkspaceLanguage string `json:"workspace_language,omitempty"`
TagsInfo string `json:"tags_info,omitempty"` // deprecated
DFLabel string `json:"df_label,omitempty"`
ScheduleType string `json:"schedule_type,omitempty"` // "frequency" or "crontab"
Crontab string `json:"crontab,omitempty"` // crontab expression like "0 0 * * *"
Tags map[string]string `json:"tags,omitempty"`
Labels []string `json:"labels,omitempty"`
UpdateTime int64 `json:"update_time,omitempty"`
ConfigVars []*ConfigVar `json:"config_vars,omitempty"`
ExtractedVars []*ConfigVar
CustomVars []*ConfigVar
Disabled uint8 `json:"disabled"`
// contains filtered or unexported fields
}
func (*Task) AddExtractedVar ¶
func (*Task) CheckResult ¶
func (*Task) GetCrontab ¶
func (*Task) GetDFLabel ¶
func (*Task) GetExternalID ¶
func (*Task) GetFrequency ¶
func (*Task) GetGlobalVars ¶
func (*Task) GetHostName ¶
func (*Task) GetIsTemplate ¶
func (*Task) GetLineData ¶
func (*Task) GetOwnerExternalID ¶
func (*Task) GetParsedString ¶
func (*Task) GetPostScriptVars ¶
func (*Task) GetResults ¶
func (*Task) GetScheduleType ¶
func (*Task) GetTaskJSONString ¶
func (*Task) GetWorkspaceLanguage ¶
func (*Task) MetricName ¶
func (*Task) NewRawTask ¶
func (*Task) PostURLStr ¶
func (*Task) RegionName ¶
func (*Task) RenderTemplateAndInit ¶
RenderTemplateAndInit render template and init task.
func (*Task) SetBeforeRun ¶
func (*Task) SetCustomVars ¶
func (*Task) SetDisabled ¶
func (*Task) SetIsTemplate ¶
func (*Task) SetOwnerExternalID ¶
func (*Task) SetRegionID ¶
func (*Task) SetTaskJSONString ¶
func (*Task) SetUpdateTime ¶
func (*Task) UpdateTimeUs ¶
type TaskChild ¶
type TaskChild interface {
ITask
// contains filtered or unexported methods
}
func CreateTaskChild ¶
type TaskConfig ¶
type Traceroute ¶
type Traceroute struct {
Host string
Hops int
Retry int
Timeout time.Duration
// contains filtered or unexported fields
}
Traceroute specified host with max hops and timeout.
func (*Traceroute) Run ¶
func (t *Traceroute) Run() error
type TracerouteOption ¶
type TracerouteOption struct {
Hops int
Retry int
Timeout string
// contains filtered or unexported fields
}
TracerouteOption represent traceroute option.
type ValueSuccess ¶
type Variable ¶
type Variable struct {
ID int `json:"id,omitempty"`
Name string `json:"name,omitempty"`
UUID string `json:"uuid,omitempty"`
TaskID string `json:"task_id,omitempty"`
TaskVarName string `json:"task_var_name,omitempty"`
Value string `json:"value,omitempty"`
Secure bool `json:"secure,omitempty"`
PostScript string `json:"post_script,omitempty"`
UpdatedAt int64 `json:"updated_at,omitempty"` // update time
ValueUpdatedAt int64 `json:"value_updated_at,omitempty"` // update value time
FailCount int `json:"fail_count,omitempty"` // update fail count
DeletedAt int64 `json:"deleted_at,omitempty"`
OwnerExternalID string `json:"owner_external_id,omitempty"`
CreatedAt int64 `json:"-"`
}
type WebsocketAdvanceOption ¶
type WebsocketAdvanceOption struct {
RequestOptions *WebsocketOptRequest `json:"request_options,omitempty"`
Auth *WebsocketOptAuth `json:"auth,omitempty"`
}
type WebsocketOptAuth ¶
type WebsocketOptRequest ¶
type WebsocketResponseTime ¶
type WebsocketSuccess ¶
type WebsocketSuccess struct {
ResponseTime []*WebsocketResponseTime `json:"response_time,omitempty"`
ResponseMessage []*SuccessOption `json:"response_message,omitempty"`
Header map[string][]*SuccessOption `json:"header,omitempty"`
}
type WebsocketTask ¶
type WebsocketTask struct {
*Task
URL string `json:"url"`
Message string `json:"message"`
SuccessWhen []*WebsocketSuccess `json:"success_when"`
AdvanceOptions *WebsocketAdvanceOption `json:"advance_options,omitempty"`
SuccessWhenLogic string `json:"success_when_logic"`
// contains filtered or unexported fields
}
Click to show internal directories.
Click to hide internal directories.