probe/client/central/data.go

34 lines
841 B
Go
Raw Normal View History

2018-04-14 08:57:01 +00:00
package central
2018-04-14 11:04:07 +00:00
import (
"fmt"
"net/http"
crc "git.loafle.net/commons/rpc-go/client"
2018-04-17 14:11:13 +00:00
ocpc "git.loafle.net/overflow/commons-go/probe/constants"
2018-04-14 11:04:07 +00:00
"git.loafle.net/overflow/probe/config"
)
func NewData() (*crc.Client, error) {
config := config.GetConfig()
if nil == config {
return nil, fmt.Errorf("Config is not available")
}
2018-04-17 14:11:13 +00:00
connector, err := newConnector("Data", ocpc.HTTPEntry_Data)
2018-04-14 11:04:07 +00:00
if nil != err {
return nil, err
}
connector.RequestHeader = func() http.Header {
header := make(map[string][]string)
2018-04-17 14:11:13 +00:00
header[ocpc.HTTPRequestHeaderKey_Probe_Method] = []string{ocpc.HTTPRequestHeaderValue_Probe_Method_Connect}
header[ocpc.HTTPRequestHeaderKey_Probe_ProbeKey] = []string{*config.Probe.Key}
2018-04-14 11:04:07 +00:00
return header
}
connector.ResponseHandler = func(res *http.Response) {
}
return newClient("Data", connector, nil), nil
}