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


Golang fake.NewFakeEventEmitter函数代码示例

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


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

示例1:

		var answer string
		Eventually(done).Should(Receive(&answer))
		Expect(answer).To(Equal("https"))

		conn.ReadResponse()
	})

	It("emits HTTP startstop events", func() {
		ln := registerHandlerWithInstanceId(r, "app", "", func(conn *test_util.HttpConn) {
		}, "fake-instance-id")
		defer ln.Close()

		conn := dialProxy(proxyServer)

		fakeEmitter := fake.NewFakeEventEmitter("fake")
		dropsonde.InitializeWithEmitter(fakeEmitter)

		req := test_util.NewRequest("GET", "app", "/", nil)
		requestId, err := uuid.NewV4()
		Expect(err).NotTo(HaveOccurred())
		req.Header.Set("X-Vcap-Request-Id", requestId.String())
		conn.WriteRequest(req)

		findStartStopEvent := func() *events.HttpStartStop {
			for _, event := range fakeEmitter.GetEvents() {
				startStopEvent, ok := event.(*events.HttpStartStop)
				if ok {
					return startStopEvent
				}
			}
开发者ID:sunatthegilddotcom,项目名称:gorouter,代码行数:30,代码来源:proxy_test.go

示例2:

	"github.com/cloudfoundry/sonde-go/events"
	uuid "github.com/nu7hatch/gouuid"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("InstrumentedHandler", func() {
	var fakeEmitter *fake.FakeEventEmitter
	var h http.Handler
	var req *http.Request

	var origin = "testHandler/41"

	BeforeEach(func() {
		fakeEmitter = fake.NewFakeEventEmitter(origin)

		var err error
		fh := fakeHandler{}
		h = instrumented_handler.InstrumentedHandler(fh, fakeEmitter)
		req, err = http.NewRequest("GET", "http://foo.example.com/", nil)
		Expect(err).ToNot(HaveOccurred())
		req.RemoteAddr = "127.0.0.1"
		req.Header.Set("User-Agent", "our-testing-client")
	})

	AfterEach(func() {
		instrumented_handler.GenerateUuid = uuid.NewV4
	})

	Describe("request ID", func() {
开发者ID:davidwadden,项目名称:lattice-release,代码行数:31,代码来源:instrumented_handler_test.go

示例3:

	. "github.com/onsi/gomega"
	"time"
)

var (
	fakeEventEmitter *fake.FakeEventEmitter
	uptimeMonitor    monitor.Monitor
)

const (
	interval = 100 * time.Millisecond
)

var _ = Describe("UptimeMonitor", func() {
	BeforeEach(func() {
		fakeEventEmitter = fake.NewFakeEventEmitter("MonitorTest")
		sender := metric_sender.NewMetricSender(fakeEventEmitter)
		batcher := metricbatcher.New(sender, 100*time.Millisecond)

		metrics.Initialize(sender, batcher)

		uptimeMonitor = monitor.NewUptimeMonitor(interval)
		go uptimeMonitor.Start()
	})

	AfterEach(func() {
		fakeEventEmitter.Close()
	})

	Context("stops automatically", func() {
开发者ID:lyuyun,项目名称:loggregator,代码行数:30,代码来源:uptime_monitor_test.go

示例4:

			readMessage := <-buffer.GetOutputChannel()
			Expect(readMessage.GetLogMessage().GetMessage()).To(ContainSubstring("message 1"))

			sendLogMessages("message 2", inMessageChan)

			readMessage2 := <-buffer.GetOutputChannel()
			Expect(readMessage2.GetLogMessage().GetMessage()).To(ContainSubstring("message 2"))

		})

		Context("tracking dropped messages", func() {
			var fakeEventEmitter *fake.FakeEventEmitter

			BeforeEach(func() {
				fakeEventEmitter = fake.NewFakeEventEmitter("doppler")
				sender := metric_sender.NewMetricSender(fakeEventEmitter)
				batcher := metricbatcher.New(sender, 100*time.Millisecond)

				metrics.Initialize(sender, batcher)
				fakeEventEmitter.Reset()
			})

			tracksDroppedMessages := func(delta, total int) {
				It("logs the dropped messages", func() {
					logMessageNotification := <-buffer.GetOutputChannel()
					Expect(logMessageNotification.GetEventType()).To(Equal(events.Envelope_LogMessage))
					Expect(logMessageNotification.GetLogMessage().GetMessage()).To(ContainSubstring(fmt.Sprintf("Log message output is too high. %d messages dropped (Total %d messages dropped) to test-sink-name.", delta, total)))

					counterEventNotification := <-buffer.GetOutputChannel()
					Expect(counterEventNotification.GetEventType()).To(Equal(events.Envelope_CounterEvent))
开发者ID:Amit-PivotalLabs,项目名称:loggregator,代码行数:30,代码来源:truncating_buffer_test.go

示例5:

	"github.com/cloudfoundry/dropsonde/emitter/fake"
	"github.com/cloudfoundry/sonde-go/events"
	"github.com/gogo/protobuf/proto"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("RuntimeStats", func() {
	var (
		fakeEventEmitter  *fake.FakeEventEmitter
		runtimeStats      *runtime_stats.RuntimeStats
		stopChan, runDone chan struct{}
	)

	BeforeEach(func() {
		fakeEventEmitter = fake.NewFakeEventEmitter("fake-origin")
		runtimeStats = runtime_stats.NewRuntimeStats(fakeEventEmitter, 10*time.Millisecond)
		stopChan = make(chan struct{})
		runDone = make(chan struct{})
	})

	AfterEach(func() {
		close(stopChan)
		Eventually(runDone).Should(BeClosed())
	})

	var perform = func() {
		go func() {
			runtimeStats.Run(stopChan)
			close(runDone)
		}()
开发者ID:davidwadden,项目名称:lattice-release,代码行数:31,代码来源:runtime_stats_test.go

示例6:

	"github.com/cloudfoundry/dropsonde/log_sender"
	"github.com/cloudfoundry/loggregatorlib/loggertesthelper"
	"io"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("LogSender", func() {
	var (
		emitter *fake.FakeEventEmitter
		sender  log_sender.LogSender
	)

	BeforeEach(func() {
		emitter = fake.NewFakeEventEmitter("origin")
		sender = log_sender.NewLogSender(emitter, nil)
	})

	Describe("SendAppLog", func() {
		It("sends a log message event to its emitter", func() {
			err := sender.SendAppLog("app-id", "custom-log-message", "App", "0")
			Expect(err).NotTo(HaveOccurred())

			Expect(emitter.Messages).To(HaveLen(1))
			log := emitter.Messages[0].Event.(*events.LogMessage)
			Expect(log.GetMessageType()).To(Equal(events.LogMessage_OUT))
			Expect(log.GetMessage()).To(BeEquivalentTo("custom-log-message"))
			Expect(log.GetAppId()).To(Equal("app-id"))
			Expect(log.GetSourceType()).To(Equal("App"))
			Expect(log.GetSourceInstance()).To(Equal("0"))
开发者ID:johannespetzold,项目名称:gorouter,代码行数:31,代码来源:log_sender_test.go


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