本文整理汇总了Golang中github.com/apoydence/talaria/messages.Client.GetFetchFile方法的典型用法代码示例。如果您正苦于以下问题:Golang Client.GetFetchFile方法的具体用法?Golang Client.GetFetchFile怎么用?Golang Client.GetFetchFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/apoydence/talaria/messages.Client
的用法示例。
在下文中一共展示了Client.GetFetchFile方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: fetchFile
func (b *Broker) fetchFile(controller Controller, message *messages.Client, conn *websocket.Conn) {
fetchFile := message.GetFetchFile()
err := controller.FetchFile(fetchFile.GetFileId(), fetchFile.GetName())
if err != nil && err.Uri == "" {
b.writeError(err.Error(), message, conn)
return
}
b.writeFileLocation(err, message, conn)
}
示例2:
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))
Expect(msg.GetFetchFile().GetName()).To(Equal("some-file-1"))