本文整理匯總了Golang中trafficcontroller/doppler_endpoint.DopplerEndpoint類的典型用法代碼示例。如果您正苦於以下問題:Golang DopplerEndpoint類的具體用法?Golang DopplerEndpoint怎麽用?Golang DopplerEndpoint使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了DopplerEndpoint類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: serveWithDoppler
func (proxy *Proxy) serveWithDoppler(writer http.ResponseWriter, request *http.Request, dopplerEndpoint doppler_endpoint.DopplerEndpoint) {
messagesChan := make(chan []byte, 100)
stopChan := make(chan struct{})
defer close(stopChan)
go proxy.connector.Connect(dopplerEndpoint, messagesChan, stopChan)
handler := dopplerEndpoint.HProvider(messagesChan, proxy.logger)
handler.ServeHTTP(writer, request)
}
示例2: connectToServer
func (c *ChannelGroupConnector) connectToServer(serverAddress string, dopplerEndpoint doppler_endpoint.DopplerEndpoint, messagesChan chan<- []byte, stopChan <-chan struct{}) {
l := c.listenerConstructor(dopplerEndpoint.Timeout, c.batcher, c.logger)
serverUrl := fmt.Sprintf("ws://%s%s", serverAddress, dopplerEndpoint.GetPath())
c.logger.Infof("proxy: connecting to doppler at %s", serverUrl)
appId := dopplerEndpoint.StreamId
err := l.Start(serverUrl, appId, messagesChan, stopChan)
if err != nil {
errorMsg := fmt.Sprintf("proxy: error connecting to %s: %s", serverAddress, err.Error())
messagesChan <- c.generateLogMessage(errorMsg, appId)
c.logger.Errorf("proxy: error connecting %s %s %s", appId, dopplerEndpoint.Endpoint, err.Error())
}
}