func newLegacyWebsocketListener(timeout time.Duration, logger *gosteno.Logger) listener.Listener { return listener.NewWebsocket(marshaller.LoggregatorLogMessage, marshaller.TranslateDropsondeToLegacyLogMessage, timeout, logger) }
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) }
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() })
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) l = listener.NewWebsocket() }) 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)
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)
} type WebsocketHandler interface { HandleWebSocket(string, string, []hasher.Hasher) } var NewWebsocketHandlerProvider = func(messages <-chan []byte) http.Handler { return handlers.NewWebsocketHandler(messages, 30*time.Second) } var NewHttpHandlerProvider = func(messages <-chan []byte) http.Handler { return handlers.NewHttpHandler(messages) } var NewWebsocketListener = func() listener.Listener { return listener.NewWebsocket() } func NewProxy(hashers []hasher.Hasher, authorizer authorization.LogAccessAuthorizer, logger *gosteno.Logger) *Proxy { return &Proxy{hashers: hashers, authorize: authorizer, logger: logger} } func (proxy *Proxy) isAuthorized(appId, authToken string, clientAddress string) (bool, *logmessage.LogMessage) { newLogMessage := func(message []byte) *logmessage.LogMessage { currentTime := time.Now() messageType := logmessage.LogMessage_ERR return &logmessage.LogMessage{ Message: message, AppId: proto.String(appId), MessageType: &messageType,