34 lines
846 B
Go
34 lines
846 B
Go
package central
|
|
|
|
import (
|
|
"fmt"
|
|
"net/http"
|
|
|
|
crc "git.loafle.net/commons/rpc-go/client"
|
|
ocnpc "git.loafle.net/overflow/commons-go/probe/constants"
|
|
"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")
|
|
}
|
|
|
|
connector, err := newConnector("Data", ocnpc.HTTPEntry_Data)
|
|
if nil != err {
|
|
return nil, err
|
|
}
|
|
|
|
connector.RequestHeader = func() http.Header {
|
|
header := make(map[string][]string)
|
|
header[ocnpc.HTTPRequestHeaderKey_Probe_Method] = []string{ocnpc.HTTPRequestHeaderValue_Probe_Method_Connect}
|
|
header[ocnpc.HTTPRequestHeaderKey_Probe_ProbeKey] = []string{*config.Probe.Key}
|
|
return header
|
|
}
|
|
connector.ResponseHandler = func(res *http.Response) {
|
|
}
|
|
|
|
return newClient("Data", connector, nil), nil
|
|
}
|