当前位置: 首页>>代码示例>>Golang>>正文


Golang listener.NewWebsocket函数代码示例

本文整理汇总了Golang中trafficcontroller/listener.NewWebsocket函数的典型用法代码示例。如果您正苦于以下问题:Golang NewWebsocket函数的具体用法?Golang NewWebsocket怎么用?Golang NewWebsocket使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了NewWebsocket函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: newLegacyWebsocketListener

func newLegacyWebsocketListener(timeout time.Duration, logger *gosteno.Logger) listener.Listener {
	return listener.NewWebsocket(marshaller.LoggregatorLogMessage, marshaller.TranslateDropsondeToLegacyLogMessage, timeout, logger)
}
开发者ID:rakutentech,项目名称:loggregator,代码行数:3,代码来源:main.go

示例2: newDropsondeWebsocketListener

func newDropsondeWebsocketListener(timeout time.Duration, logger *gosteno.Logger) listener.Listener {
	messageConverter := func(message []byte) ([]byte, error) {
		return message, nil
	}
	return listener.NewWebsocket(marshaller.DropsondeLogMessage, messageConverter, timeout, logger)
}
开发者ID:rakutentech,项目名称:loggregator,代码行数:6,代码来源:main.go

示例3:

		testhelpers.AlwaysReturn(mockBatcher.BatchCounterOutput, mockChainer)
		testhelpers.AlwaysReturn(mockChainer.SetTagOutput, mockChainer)

		messageChan = make(chan []byte)
		outputChan = make(chan []byte, 10)
		stopChan = make(chan struct{})
		fh = &fakeHandler{messages: messageChan}
		ts = httptest.NewUnstartedServer(fh)
		converter = func(d []byte) ([]byte, error) { return d, nil }
	})

	JustBeforeEach(func() {
		l = listener.NewWebsocket(
			marshaller.LoggregatorLogMessage,
			converter,
			readTimeout,
			handshakeTimeout,
			mockBatcher,
			loggertesthelper.Logger(),
		)
	})

	AfterEach(func() {
		select {
		case <-messageChan:
			// already closed
		default:
			close(messageChan)
		}
		ts.Close()
	})
开发者ID:kei-yamazaki,项目名称:loggregator,代码行数:31,代码来源:websocket_listener_test.go

示例4:

var _ = Describe("WebsocketListener", func() {
	var ts *httptest.Server
	var messageChan, outputChan chan []byte
	var stopChan chan struct{}
	var l listener.Listener
	var fh *fakeHandler

	BeforeEach(func() {
		messageChan = make(chan []byte)
		outputChan = make(chan []byte, 10)
		stopChan = make(chan struct{})
		fh = &fakeHandler{messages: messageChan}
		ts = httptest.NewUnstartedServer(fh)
		converter := func(d []byte) ([]byte, error) { return d, nil }
		l = listener.NewWebsocket(marshaller.LoggregatorLogMessage, converter, 500*time.Millisecond, loggertesthelper.Logger())
	})

	AfterEach(func() {
		select {
		case <-messageChan:
			// already closed
		default:
			close(messageChan)
		}
		ts.Close()
	})

	Context("when the server is not running", func() {
		It("should error when connecting", func(done Done) {
			err := l.Start("ws://localhost:1234", "myApp", outputChan, stopChan)
开发者ID:lyuyun,项目名称:loggregator,代码行数:30,代码来源:websocket_listener_test.go


注:本文中的trafficcontroller/listener.NewWebsocket函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。