Esempio n. 1
0
func (w *WebsocketServer) streamLogs(appId string, websocketConnection *gorilla.Conn) {
	w.logger.Debugf("WebsocketServer: Requesting a wss sink for app %s", appId)
	websocketSink := websocket.NewWebsocketSink(
		appId,
		w.logger,
		websocketConnection,
		w.bufferSize,
		w.writeTimeout,
		w.dropsondeOrigin,
	)

	w.streamWebsocket(websocketSink, websocketConnection, w.sinkManager.RegisterSink, w.sinkManager.UnregisterSink)
}
func (w *WebsocketServer) streamWebsocket(appId string, websocketConnection *gorilla.Conn, register func(sinks.Sink) bool, unregister func(sinks.Sink)) {
	websocketSink := websocket.NewWebsocketSink(
		appId,
		w.logger,
		websocketConnection,
		w.bufferSize,
		w.dropsondeOrigin,
	)

	register(websocketSink)
	defer unregister(websocketSink)

	go websocketConnection.ReadMessage()
	server.NewKeepAlive(websocketConnection, w.keepAliveInterval).Run()
}
Esempio n. 3
0
func (w *WebsocketServer) streamFirehose(subscriptionId string, websocketConnection *gorilla.Conn) {
	w.logger.Debugf("WebsocketServer: Requesting firehose wss sink")
	websocketSink := websocket.NewWebsocketSink(
		subscriptionId,
		w.logger,
		websocketConnection,
		w.bufferSize,
		w.writeTimeout,
		w.dropsondeOrigin,
	)

	firehoseCounter := newFirehoseCounter(subscriptionId)
	websocketSink.SetCounter(firehoseCounter)

	w.streamWebsocket(websocketSink, websocketConnection, w.sinkManager.RegisterFirehoseSink, w.sinkManager.UnregisterFirehoseSink)
}
}

var _ = Describe("WebsocketSink", func() {

	var (
		logger        *gosteno.Logger
		websocketSink *websocket.WebsocketSink
		fakeWebsocket *fakeMessageWriter
		writeTimeout  time.Duration
	)

	BeforeEach(func() {
		logger = loggertesthelper.Logger()
		fakeWebsocket = &fakeMessageWriter{}
		writeTimeout = 5 * time.Second
		websocketSink = websocket.NewWebsocketSink("appId", logger, fakeWebsocket, 10, writeTimeout, "dropsonde-origin")
	})

	Describe("Identifier", func() {
		It("returns the remote address", func() {
			Expect(websocketSink.Identifier()).To(Equal("client-address"))
		})
	})

	Describe("StreamId", func() {
		It("returns the application id", func() {
			Expect(websocketSink.AppID()).To(Equal("appId"))
		})
	})

	Describe("ShouldReceiveErrors", func() {
Esempio n. 5
0
}

var _ = Describe("WebsocketSink", func() {

	var (
		logger           *gosteno.Logger
		websocketSink    *websocket.WebsocketSink
		fakeWebsocket    *fakeMessageWriter
		updateMetricChan chan int64
	)

	BeforeEach(func() {
		logger = loggertesthelper.Logger()
		fakeWebsocket = &fakeMessageWriter{}
		updateMetricChan = make(chan int64, 1)
		websocketSink = websocket.NewWebsocketSink("appId", logger, fakeWebsocket, 10, "dropsonde-origin", updateMetricChan)
	})

	Describe("Identifier", func() {
		It("returns the remote address", func() {
			Expect(websocketSink.Identifier()).To(Equal("client-address"))
		})
	})

	Describe("StreamId", func() {
		It("returns the application id", func() {
			Expect(websocketSink.StreamId()).To(Equal("appId"))
		})
	})

	Describe("ShouldReceiveErrors", func() {