當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Client.GetMessageType方法代碼示例

本文整理匯總了Golang中github.com/apoydence/talaria/messages.Client.GetMessageType方法的典型用法代碼示例。如果您正苦於以下問題:Golang Client.GetMessageType方法的具體用法?Golang Client.GetMessageType怎麽用?Golang Client.GetMessageType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/apoydence/talaria/messages.Client的用法示例。


在下文中一共展示了Client.GetMessageType方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1:

		It("returns an error", func(done Done) {
			defer close(done)

			mockServer.serverCh <- buildError(99, "some-error")

			go func() {
				defer GinkgoRecover()
				err := connection.FetchFile(9, "some-file")
				Expect(err).ToNot(BeNil())
				Expect(err.Error()).To(Equal("some-error"))
			}()

			var clientMsg *messages.Client
			Eventually(mockServer.clientCh).Should(Receive(&clientMsg))
			Expect(clientMsg.GetMessageType()).To(Equal(messages.Client_FetchFile))
			Expect(clientMsg.FetchFile.GetName()).To(Equal("some-file"))
			Expect(clientMsg.FetchFile.GetFileId()).To(BeEquivalentTo(9))
		})

		It("returns the file ID", func(done Done) {
			defer close(done)

			mockServer.serverCh <- buildFileLocation(99)

			go func() {
				defer GinkgoRecover()
				err := connection.FetchFile(9, "some-file")
				Expect(err).To(BeNil())
			}()
開發者ID:jmptrader,項目名稱:talaria,代碼行數:29,代碼來源:connection_test.go

示例2:

			var wg sync.WaitGroup
			defer wg.Wait()
			wg.Add(len(mockServers))
			for i := range mockServers {
				go func(iter int) {
					defer GinkgoRecover()
					defer wg.Done()
					_, err := client.FetchFile(fmt.Sprintf("some-file-%d", iter))
					Expect(err).ToNot(HaveOccurred())
				}(i)
			}

			for i, server := range mockServers {
				var msg *messages.Client
				Eventually(server.clientCh).Should(Receive(&msg))
				Expect(msg.GetMessageType()).To(Equal(messages.Client_FetchFile))
				Expect(msg.GetFetchFile().GetName()).To(Equal(fmt.Sprintf("some-file-%d", i)))
			}
		}, 5)

		It("re-fetches a file if it is redirected", func(done Done) {
			defer close(done)
			mockServers[0].serverCh <- buildRemoteFileLocation(1, servers[1].URL)
			mockServers[1].serverCh <- buildFileLocation(1)

			_, err := client.FetchFile("some-file-1")
			Expect(err).ToNot(HaveOccurred())

			var msg *messages.Client
			Eventually(mockServers[1].clientCh).Should(Receive(&msg))
			Expect(msg.GetMessageType()).To(Equal(messages.Client_FetchFile))
開發者ID:jmptrader,項目名稱:talaria,代碼行數:31,代碼來源:client_test.go


注:本文中的github.com/apoydence/talaria/messages.Client.GetMessageType方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。