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


Golang networkreader.NetworkReader类代码示例

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


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

示例1:

	"metron/networkreader"
	"metron/writers/mocks"

	"github.com/cloudfoundry/dropsonde/metric_sender/fake"
	"github.com/cloudfoundry/loggregatorlib/loggertesthelper"

	"github.com/cloudfoundry/dropsonde/metricbatcher"
	"github.com/cloudfoundry/dropsonde/metrics"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	"strconv"
	"time"
)

var _ = Describe("NetworkReader", func() {
	var reader *networkreader.NetworkReader
	var readerStopped chan struct{}
	var writer mocks.MockByteArrayWriter
	var port int
	var address string
	var fakeMetricSender *fake.FakeMetricSender

	BeforeEach(func() {
		port = 3456 + GinkgoParallelNode()
		address = net.JoinHostPort("127.0.0.1", strconv.Itoa(port))
		writer = mocks.MockByteArrayWriter{}
		reader = networkreader.New(address, "networkReader", &writer, loggertesthelper.Logger())
		readerStopped = make(chan struct{})
	})

	Context("with a reader running", func() {
开发者ID:jvshahid,项目名称:loggregator,代码行数:31,代码来源:network_reader_test.go

示例2:

import (
	"metron/networkreader"
	"metron/writers/eventunmarshaller"
	"sync/atomic"

	"github.com/apoydence/eachers/testhelpers"
	"github.com/cloudfoundry/loggregatorlib/loggertesthelper"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("Monitor", func() {

	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())
开发者ID:kei-yamazaki,项目名称:loggregator,代码行数:31,代码来源:fd_monitor_linux_test.go

示例3:

import (
	"fmt"
	"net"

	"metron/networkreader"
	"metron/writers/mocks"

	"github.com/cloudfoundry/loggregatorlib/loggertesthelper"

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

var _ = Describe("NetworkReader", func() {
	var reader *networkreader.NetworkReader
	var readerStopped chan struct{}
	var writer mocks.MockByteArrayWriter
	var port int
	var address string

	BeforeEach(func() {
		port = 3456 + GinkgoParallelNode()
		address = net.JoinHostPort("127.0.0.1", strconv.Itoa(port))
		writer = mocks.MockByteArrayWriter{}
		reader = networkreader.New(address, "networkReader", &writer, loggertesthelper.Logger())
		readerStopped = make(chan struct{})
	})

	Context("without a running listener", func() {
		It("Emit returns a context with the given name", func() {
开发者ID:andrew-edgar,项目名称:loggregator,代码行数:31,代码来源:network_reader_test.go

示例4:

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

var _ = Describe("NetworkReader", func() {
	Context("without a running listener", func() {
		It("Emit returns a context with the given name", func() {
			reader := networkreader.New("127.0.0.1:3456", "secretEventOrange", &mocks.MockByteArrayWriter{}, loggertesthelper.Logger())
			context := reader.Emit()

			Expect(context.Name).To(Equal("secretEventOrange"))
		})
	})

	Context("with a reader running", func() {
		var reader *networkreader.NetworkReader
		var writer mocks.MockByteArrayWriter

		BeforeEach(func() {
			writer = mocks.MockByteArrayWriter{}
			reader = networkreader.New("127.0.0.1:3456", "networkReader", &writer, loggertesthelper.Logger())

			loggertesthelper.TestLoggerSink.Clear()
			go reader.Start()

			Eventually(loggertesthelper.TestLoggerSink.LogContents).Should(ContainSubstring("Listening on port 127.0.0.1:3456"))
		})

		AfterEach(func() {
			reader.Stop()
		})
开发者ID:khj0651,项目名称:loggregator,代码行数:31,代码来源:network_reader_test.go


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