本文整理汇总了Golang中github.com/juju/juju/rpc.Conn.ClientRequestID方法的典型用法代码示例。如果您正苦于以下问题:Golang Conn.ClientRequestID方法的具体用法?Golang Conn.ClientRequestID怎么用?Golang Conn.ClientRequestID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/juju/juju/rpc.Conn
的用法示例。
在下文中一共展示了Conn.ClientRequestID方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: testBadCall
func testBadCall(
c *gc.C,
client *rpc.Conn,
serverNotifier *notifier,
req rpc.Request,
expectedErr string,
expectedErrCode string,
requestKnown bool,
) {
serverNotifier.reset()
err := client.Call(req, nil, nil)
msg := expectedErr
if expectedErrCode != "" {
msg += " (" + expectedErrCode + ")"
}
c.Assert(err, gc.ErrorMatches, regexp.QuoteMeta(msg))
// From docs on ServerRequest:
// If the request was not recognized or there was
// an error reading the body, body will be nil.
var expectBody interface{}
if requestKnown {
expectBody = struct{}{}
}
c.Assert(serverNotifier.serverRequests[0], gc.DeepEquals, requestEvent{
hdr: rpc.Header{
RequestId: client.ClientRequestID(),
Request: req,
Version: 1,
},
body: expectBody,
})
// Test that there was a notification for the server reply.
c.Assert(serverNotifier.serverReplies, gc.HasLen, 1)
serverReply := serverNotifier.serverReplies[0]
c.Assert(serverReply, gc.DeepEquals, replyEvent{
hdr: rpc.Header{
RequestId: client.ClientRequestID(),
Error: expectedErr,
ErrorCode: expectedErrCode,
Version: 1,
},
req: req,
body: struct{}{},
})
}