本文整理汇总了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
}
}
开发者ID:sunatthegilddotcom,项目名称:gorouter,代码行数:30,代码来源:proxy_test.go
示例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))
})
开发者ID:benlaplanche,项目名称:emitter,代码行数:30,代码来源:dropsonde_test.go
注:本文中的github.com/cloudfoundry/dropsonde.InitializeWithEmitter函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论