本文整理汇总了Golang中github.com/cloudfoundry/dropsonde.InitializeWithEmitter函数的典型用法代码示例。如果您正苦于以下问题:Golang InitializeWithEmitter函数的具体用法?Golang InitializeWithEmitter怎么用?Golang InitializeWithEmitter使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了InitializeWithEmitter函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
}
}
示例2:
import (
"net/http"
"reflect"
"github.com/cloudfoundry/dropsonde"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Autowire", func() {
Describe("Initialize", func() {
It("resets the HTTP default transport to be instrumented", func() {
dropsonde.InitializeWithEmitter(&dropsonde.NullEventEmitter{})
Expect(reflect.TypeOf(http.DefaultTransport).Elem().Name()).To(Equal("instrumentedCancelableRoundTripper"))
})
})
Describe("CreateDefaultEmitter", func() {
Context("with origin missing", func() {
It("returns a NullEventEmitter", func() {
err := dropsonde.Initialize("localhost:2343", "")
Expect(err).To(HaveOccurred())
emitter := dropsonde.AutowiredEmitter()
Expect(emitter).ToNot(BeNil())
nullEmitter := &dropsonde.NullEventEmitter{}
Expect(emitter).To(BeAssignableToTypeOf(nullEmitter))
})