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


Golang NATSConn.PublishRequest方法代码示例

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


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

示例1:

		if router != nil {
			router.Stop()
		}
	})

	Context("NATS", func() {
		Context("Router Greetings", func() {
			It("RouterGreets", func() {
				response := make(chan []byte)

				mbusClient.Subscribe("router.greet.test.response", func(msg *nats.Msg) {
					response <- msg.Data
				})

				mbusClient.PublishRequest("router.greet", "router.greet.test.response", []byte{})

				var msg []byte
				Eventually(response).Should(Receive(&msg))

				var message vcap.RouterStart
				err := json.Unmarshal(msg, &message)

				Expect(err).NotTo(HaveOccurred())
				Expect(message.MinimumRegisterIntervalInSeconds).To(Equal(5))
				Expect(message.PruneThresholdInSeconds).To(Equal(120))
			})

			It("handles a empty reply on greet", func() {
				err := mbusClient.PublishRequest("router.greet", "", []byte{})
				Expect(err).NotTo(HaveOccurred())
开发者ID:shashankmjain,项目名称:gorouter,代码行数:30,代码来源:router_test.go

示例2:

			_, err = mbusClient.Subscribe("subject", func(msg *nats.Msg) {
				defer GinkgoRecover()
				data := make(map[string]interface{})
				err := json.Unmarshal(msg.Data, &data)
				Expect(err).ToNot(HaveOccurred())

				for _, key := range members {
					_, ok := data[key]
					Expect(ok).To(BeTrue())
				}

				close(done)
			})
			Expect(err).ToNot(HaveOccurred())

			err = mbusClient.PublishRequest("vcap.component.discover", "subject", []byte(""))
			Expect(err).ToNot(HaveOccurred())

			Eventually(done).Should(BeClosed())
		})

		It("publishes to vcap.component.announce on start-up", func() {
			done := make(chan struct{})
			members := []string{
				"type",
				"index",
				"host",
				"credentials",
				"start",
				"uuid",
				"uptime",
开发者ID:idouba,项目名称:gorouter,代码行数:31,代码来源:component_test.go


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