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


Golang Writer.Write方法代码示例

本文整理汇总了Golang中doppler/sinks/syslogwriter.Writer.Write方法的典型用法代码示例。如果您正苦于以下问题:Golang Writer.Write方法的具体用法?Golang Writer.Write怎么用?Golang Writer.Write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在doppler/sinks/syslogwriter.Writer的用法示例。


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

示例1: concurrentWriteRequests

func (c *concurrentWriteRequestSimulator) concurrentWriteRequests(count int, writer syslogwriter.Writer) {
	wg := &sync.WaitGroup{}
	wg.Add(count)

	for i := 0; i < count; i++ {
		go func() {
			writer.Write(standardErrorPriority, []byte("Message"), "just a test", "TEST", time.Now().UnixNano())
			wg.Done()
		}()
	}

	wg.Wait()
}
开发者ID:Jonty,项目名称:loggregator,代码行数:13,代码来源:https_writer_test.go

示例2:

		sysLogWriter, _ = syslogwriter.NewSyslogWriter(outputURL, "appId", dialer, 0)

		Eventually(func() error {
			err := sysLogWriter.Connect()
			return err
		}, 5, 1).ShouldNot(HaveOccurred())
	}, 10)

	AfterEach(func() {
		sysLogWriter.Close()
		syslogServerSession.Kill().Wait()
	})

	Context("Message Format", func() {
		It("sends messages in the proper format", func() {
			sysLogWriter.Write(standardOutPriority, []byte("just a test"), "App", "2", time.Now().UnixNano())

			Eventually(syslogServerSession, 5).Should(gbytes.Say(`\d <\d+>1 \d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{1,6}([-+]\d{2}:\d{2}) loggregator appId \[App/2\] - - just a test\n`))
		}, 10)

		It("strips null termination char from message", func() {
			sysLogWriter.Write(standardOutPriority, []byte(string(0)+" hi"), "appId", "", time.Now().UnixNano())

			Expect(syslogServerSession).ToNot(gbytes.Say("\000"))
		})
	})

	Context("won't write to invalid syslog drains", func() {
		It("returns an error when unable to send the log message", func() {
			syslogServerSession.Kill().Wait()
开发者ID:Jonty,项目名称:loggregator,代码行数:30,代码来源:syslog_writer_test.go

示例3:

			Expect(err).ToNot(HaveOccurred())
		}, 5)

		AfterEach(func() {
			syslogServerSession.Terminate().Wait()
			syslogWriter.Close()
		})

		It("connects and writes", func() {
			ts := time.Now().UnixNano()
			Eventually(func() error {
				err := syslogWriter.Connect()
				return err
			}, 5, 1).ShouldNot(HaveOccurred())

			_, err := syslogWriter.Write(standardOutPriority, []byte("just a test"), "test", "", ts)
			Expect(err).ToNot(HaveOccurred())

			Eventually(syslogServerSession, 3).Should(gbytes.Say("just a test"))
		}, 10)

		Context("when an i/o timeout is set", func() {
			BeforeEach(func() {
				// cause an immediate write timeout
				ioTimeout = -1 * time.Second
			})

			It("returns a timeout error", func() {
				Eventually(func() error {
					err := syslogWriter.Connect()
					return err
开发者ID:lyuyun,项目名称:loggregator,代码行数:31,代码来源:tls_writer_test.go


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