本文整理汇总了Golang中metron/networkreader.NetworkReader.Stop方法的典型用法代码示例。如果您正苦于以下问题:Golang NetworkReader.Stop方法的具体用法?Golang NetworkReader.Stop怎么用?Golang NetworkReader.Stop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类metron/networkreader.NetworkReader
的用法示例。
在下文中一共展示了NetworkReader.Stop方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1:
loggertesthelper.TestLoggerSink.Clear()
fakeMetricSender = fake.NewFakeMetricSender()
metricBatcher := metricbatcher.New(fakeMetricSender, time.Millisecond)
metrics.Initialize(fakeMetricSender, metricBatcher)
go func() {
reader.Start()
close(readerStopped)
}()
expectedLog := fmt.Sprintf("Listening on port %s", address)
Eventually(loggertesthelper.TestLoggerSink.LogContents).Should(ContainSubstring(expectedLog))
})
AfterEach(func() {
reader.Stop()
<-readerStopped
})
It("sends data recieved on UDP socket to its writer", func() {
expectedData := "Some Data"
otherData := "More stuff"
connection, err := net.Dial("udp", address)
_, err = connection.Write([]byte(expectedData))
Expect(err).NotTo(HaveOccurred())
Eventually(writer.Data).Should(HaveLen(1))
data := string(writer.Data()[0])
Expect(data).To(Equal(expectedData))
示例2:
var (
writer *fakeWriter
dropsondeReader *networkreader.NetworkReader
)
BeforeEach(func() {
logger := loggertesthelper.Logger()
writer = &fakeWriter{}
mockBatcher := newMockEventBatcher()
mockChainer := newMockBatchCounterChainer()
testhelpers.AlwaysReturn(mockBatcher.BatchCounterOutput, mockChainer)
testhelpers.AlwaysReturn(mockChainer.SetTagOutput, mockChainer)
var err error
dropsondeUnmarshaller := eventunmarshaller.New(writer, mockBatcher, logger)
dropsondeReader, err = networkreader.New("127.0.0.1:37474", "dropsondeAgentListener", dropsondeUnmarshaller, logger)
Expect(err).NotTo(HaveOccurred())
})
Context("LinuxFileDescriptor", func() {
It("sends open file descriptor metrics", func() {
defer dropsondeReader.Stop()
go dropsondeReader.Start()
Eventually(func() uint64 { return atomic.LoadUint64(&writer.openFileDescriptors) }, 3).Should(BeNumerically("~", 15, 3))
})
})
})