Пример #1
0
		It("sends to all known sinks", func() {
			sink1 := &channelSink{appId: "myApp",
				identifier: "myAppChan1",
				done:       make(chan struct{}),
			}
			sink2 := &channelSink{appId: "myApp",
				identifier: "myAppChan2",
				done:       make(chan struct{}),
			}

			sinkManager.RegisterSink(sink1)
			sinkManager.RegisterSink(sink2)

			expectedMessageString := "Some Data"
			expectedMessage, _ := emitter.Wrap(factories.NewLogMessage(events.LogMessage_OUT, expectedMessageString, "myApp", "App"), "origin")
			go sinkManager.SendTo("myApp", expectedMessage)

			Eventually(sink1.Received).Should(HaveLen(1))
			Eventually(sink2.Received).Should(HaveLen(1))
			Expect(sink1.Received()[0]).To(Equal(expectedMessage))
			Expect(sink2.Received()[0]).To(Equal(expectedMessage))
		})

		It("only sends to sinks that match the appID", func(done Done) {
			sink1 := &channelSink{appId: "myApp1",
				identifier: "myAppChan1",
				done:       make(chan struct{}),
			}
			sink2 := &channelSink{appId: "myApp2",
				identifier: "myAppChan2",
				done:       make(chan struct{}),
Пример #2
0
			m.RegisterStream(&req, firstSender)

			secondSender := newMockGRPCSender()
			close(secondSender.SendOutput.Err)
			m.RegisterStream(&req, secondSender)

			env := &events.Envelope{
				EventType: events.Envelope_LogMessage.Enum(),
				Origin:    proto.String("origin"),
				LogMessage: &events.LogMessage{
					Message:     []byte("I am a MESSAGE!"),
					MessageType: events.LogMessage_OUT.Enum(),
					Timestamp:   proto.Int64(time.Now().UnixNano()),
				},
			}
			m.SendTo("app", env)

			payload, err := proto.Marshal(env)
			Expect(err).ToNot(HaveOccurred())

			expected := &plumbing.Response{
				Payload: payload,
			}
			Eventually(firstSender.SendInput.Resp).Should(BeCalled(
				With(expected),
			))
			Eventually(secondSender.SendInput.Resp).Should(BeCalled(
				With(expected),
			))
		})