本文整理汇总了Golang中github.com/juju/juju/rpc.Conn类的典型用法代码示例。如果您正苦于以下问题:Golang Conn类的具体用法?Golang Conn怎么用?Golang Conn使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Conn类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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{}{},
})
}
开发者ID:bac,项目名称:juju,代码行数:47,代码来源:rpc_test.go
示例2: closeClient
func closeClient(c *gc.C, client *rpc.Conn, srvDone <-chan error) {
err := client.Close()
c.Assert(err, jc.ErrorIsNil)
err = chanReadError(c, srvDone, "server done")
c.Assert(err, jc.ErrorIsNil)
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:6,代码来源:rpc_test.go
注:本文中的github.com/juju/juju/rpc.Conn类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论