Пример #1
0
func (handler *HTTPHandler) init() {
	if handler.URL == "" {
		klog.KFatal("meter.http.init.error", "no URL configured")
	}

	if handler.Method == "" {
		klog.KFatal("meter.http.init.error", "no HTTP method configured")
	}

	if _, err := url.Parse(handler.URL); err != nil {
		klog.KFatalf("meter.http.init.error", "invalid URL '%s': %s", handler.URL, err)
	}

	if handler.HTTPClient == nil {
		handler.HTTPClient = http.DefaultClient
	}

	handler.client = &rest.Client{
		Client: handler.HTTPClient,
		Root:   handler.URL,
	}
}
Пример #2
0
func (carbon *CarbonHandler) init() {
	if len(carbon.URLs) == 0 {
		klog.KFatal("meter.carbon.init.error", "no URL configured")
	}

	carbon.connC = make(chan msgConn)
	carbon.valuesC = make(chan map[string]float64)

	carbon.conns = make(map[string]net.Conn)
	for _, URL := range carbon.URLs {
		carbon.connect(URL)
	}

	go carbon.run()
}