本文整理汇总了Golang中github.com/cloudfoundry/noaa/consumer.Consumer类的典型用法代码示例。如果您正苦于以下问题:Golang Consumer类的具体用法?Golang Consumer怎么用?Golang Consumer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Consumer类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1:
"github.com/cloudfoundry/noaa/consumer"
"github.com/cloudfoundry/sonde-go/events"
"github.com/elazarl/goproxy"
"github.com/elazarl/goproxy/ext/auth"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Consumer connecting through a Proxy", func() {
var (
connection *consumer.Consumer
messagesToSend chan []byte
testServer *httptest.Server
endpoint string
proxy func(*http.Request) (*url.URL, error)
testProxyServer *httptest.Server
goProxyHandler *goproxy.ProxyHttpServer
)
BeforeEach(func() {
messagesToSend = make(chan []byte, 256)
testServer = httptest.NewServer(handlers.NewWebsocketHandler(messagesToSend, 100*time.Millisecond, loggertesthelper.Logger()))
endpoint = "ws://" + testServer.Listener.Addr().String()
goProxyHandler = goproxy.NewProxyHttpServer()
goProxyHandler.Logger = log.New(bytes.NewBufferString(""), "", 0)
testProxyServer = httptest.NewServer(goProxyHandler)
proxy = func(*http.Request) (*url.URL, error) {
开发者ID:cloudfoundry,项目名称:v3-cli-plugin,代码行数:31,代码来源:consumer_proxy_test.go
示例2: ServeHTTP
type nullHandler chan struct{}
func (h nullHandler) ServeHTTP(http.ResponseWriter, *http.Request) {
<-h
}
const (
appGuid = "fakeAppGuid"
authToken = "fakeAuthToken"
testTimeout = 1 * time.Second
)
var (
cnsmr *consumer.Consumer
testServer *httptest.Server
fakeHandler nullHandler
)
var _ = Describe("Timeout", func() {
AfterSuite(func() {
if testServer != nil {
testServer.Close()
}
})
BeforeEach(func() {
internal.Timeout = testTimeout
fakeHandler = make(nullHandler, 1)
testServer = httptest.NewServer(fakeHandler)
开发者ID:cloudfoundry,项目名称:v3-cli-plugin,代码行数:30,代码来源:timeout_test.go
示例3:
"github.com/cloudfoundry/noaa/consumer"
"github.com/cloudfoundry/noaa/test_helpers"
"github.com/cloudfoundry/sonde-go/events"
"github.com/gogo/protobuf/proto"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Consumer (Asynchronous)", func() {
var (
cnsmr *consumer.Consumer
trafficControllerURL string
testServer *httptest.Server
fakeHandler *test_helpers.FakeHandler
tlsSettings *tls.Config
appGuid string
authToken string
messagesToSend chan []byte
)
BeforeEach(func() {
trafficControllerURL = ""
testServer = nil
fakeHandler = nil
tlsSettings = nil
appGuid = ""
authToken = ""
messagesToSend = make(chan []byte, 256)
开发者ID:cloudfoundry,项目名称:v3-cli-plugin,代码行数:31,代码来源:async_test.go
示例4:
"time"
"github.com/cloudfoundry/loggregatorlib/loggertesthelper"
"github.com/cloudfoundry/loggregatorlib/server/handlers"
"github.com/cloudfoundry/noaa/consumer"
. "github.com/apoydence/eachers"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("RefreshTokenFrom", func() {
Context("Asynchronous", func() {
var (
cnsmr *consumer.Consumer
testHandler *errorRespondingHandler
tcURL string
refresher *mockTokenRefresher
)
BeforeEach(func() {
testHandler = &errorRespondingHandler{
subHandler: handlers.NewWebsocketHandler(make(chan []byte), 100*time.Millisecond, loggertesthelper.Logger()),
responseStatuses: make(chan int, 10),
}
server := httptest.NewServer(testHandler)
tcURL = "ws://" + server.Listener.Addr().String()
refresher = newMockTokenRefresher()
cnsmr = consumer.New(tcURL, nil, nil)
cnsmr.RefreshTokenFrom(refresher)
开发者ID:cloudfoundry,项目名称:v3-cli-plugin,代码行数:32,代码来源:token_refresher_test.go
示例5:
BeforeEach(func() {
count = 100
})
JustBeforeEach(func() {
for i := 0; i < count; i++ {
time.Sleep(10 * time.Millisecond)
helpers.EmitToMetron(buildValueMetric("mainValue", float64(i)))
}
})
Context("single connection", func() {
var (
reader *consumer.Consumer
msgs <-chan *events.Envelope
errs <-chan error
)
JustBeforeEach(func() {
go emitControlMessages()
waitForControl(msgs)
})
BeforeEach(func() {
reader, _ = helpers.SetUpConsumer()
msgs, errs = reader.Firehose(generateSubID(), "")
go readFromErrors(errs)
})
AfterEach(func() {
开发者ID:kei-yamazaki,项目名称:loggregator,代码行数:30,代码来源:firehose_test.go
示例6:
Expect(err).ToNot(HaveOccurred())
Expect(testFile.Close()).To(Succeed())
testContents = func() string {
contents, err := ioutil.ReadFile(accessLogFile)
Expect(err).ToNot(HaveOccurred())
return string(contents)
}
})
AfterEach(func() {
Expect(os.Remove(accessLogFile)).To(Succeed())
})
Context("with modern endpoints", func() {
var noaaConsumer *consumer.Consumer
JustBeforeEach(func() {
tcURL := fmt.Sprintf("ws://%s:%d", localIPAddress, TRAFFIC_CONTROLLER_DROPSONDE_PORT)
noaaConsumer = consumer.New(tcURL, &tls.Config{}, nil)
})
AfterEach(func() {
noaaConsumer.Close()
})
It("logs stream access", func() {
noaaConsumer.Stream(APP_ID, AUTH_TOKEN)
expected := fmt.Sprintf("CEF:0|cloud_foundry|loggregator_trafficcontroller|1.0|GET /apps/%s/stream|GET /apps/%[1]s/stream|0|", APP_ID)
Eventually(testContents).Should(ContainSubstring(expected))
开发者ID:kei-yamazaki,项目名称:loggregator,代码行数:31,代码来源:accesslog_end_to_end_test.go
示例7:
var dropsondeEndpoint string
BeforeEach(func() {
fakeDoppler = fake_doppler.New()
go fakeDoppler.Start()
dropsondeEndpoint = fmt.Sprintf("ws://%s:%d", localIPAddress, TRAFFIC_CONTROLLER_DROPSONDE_PORT)
})
AfterEach(func() {
fakeDoppler.Stop()
})
Context("Streaming", func() {
var (
client *consumer.Consumer
messages <-chan *events.Envelope
errors <-chan error
)
JustBeforeEach(func() {
client = consumer.New(dropsondeEndpoint, &tls.Config{}, nil)
messages, errors = client.StreamWithoutReconnect(APP_ID, AUTH_TOKEN)
})
It("passes messages through", func() {
var request *http.Request
Eventually(fakeDoppler.TrafficControllerConnected, 10).Should(Receive(&request))
Expect(request.URL.Path).To(Equal("/apps/1234/stream"))
currentTime := time.Now().UnixNano()
dropsondeMessage := makeDropsondeMessage("Hello through NOAA", APP_ID, currentTime)
开发者ID:yingkitw,项目名称:loggregator,代码行数:31,代码来源:dropsonde_end_to_end_test.go
注:本文中的github.com/cloudfoundry/noaa/consumer.Consumer类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论