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


Golang Writer.Close方法代码示例

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


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

示例1:

		port := 9800 + config.GinkgoConfig.ParallelNode
		address := net.JoinHostPort("127.0.0.1", strconv.Itoa(port))

		outputURL := &url.URL{Scheme: "syslog", Host: address}
		syslogServerSession = startSyslogServer(address)
		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"))
		})
开发者ID:Jonty,项目名称:loggregator,代码行数:30,代码来源:syslog_writer_test.go

示例2:

			dialer = &net.Dialer{
				Timeout: time.Second,
			}

			var err error
			port := 9900 + config.GinkgoConfig.ParallelNode
			address := net.JoinHostPort("127.0.0.1", strconv.Itoa(port))
			syslogServerSession = startEncryptedTCPServer(address)
			outputURL := &url.URL{Scheme: "syslog-tls", Host: address}
			syslogWriter, err = syslogwriter.NewTlsWriter(outputURL, "appId", skipCertVerify, dialer, ioTimeout)
			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)
开发者ID:lyuyun,项目名称:loggregator,代码行数:30,代码来源:tls_writer_test.go


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