本文整理匯總了Golang中github.com/eluleci/dock/messages.RequestWrapper.Res方法的典型用法代碼示例。如果您正苦於以下問題:Golang RequestWrapper.Res方法的具體用法?Golang RequestWrapper.Res怎麽用?Golang RequestWrapper.Res使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/eluleci/dock/messages.RequestWrapper
的用法示例。
在下文中一共展示了RequestWrapper.Res方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: TestInbox
func TestInbox(t *testing.T) {
Convey("Should call actor.handleRequest", t, func() {
var called bool
handleRequest = func(a *Actor, requestWrapper messages.RequestWrapper) (response messages.Message) {
called = true
return
}
var requestWrapper messages.RequestWrapper
requestWrapper.Res = "/"
responseChannel := make(chan messages.Message)
requestWrapper.Listener = responseChannel
var actor Actor
actor.class = "someclass"
actor.res = "/"
actor.Inbox = make(chan messages.RequestWrapper)
go actor.Run()
actor.Inbox <- requestWrapper
response := <-responseChannel
So(response, ShouldNotBeNil)
So(called, ShouldBeTrue)
})
Convey("Should forward message to a child actor", t, func() {
parentRes := "/users"
childRes := "/users/123"
var calledOnParent bool
var calledOnChild bool
handleRequest = func(a *Actor, requestWrapper messages.RequestWrapper) (response messages.Message) {
if strings.EqualFold(a.res, parentRes) {
calledOnParent = true
}
if strings.EqualFold(a.res, childRes) {
calledOnChild = true
}
return
}
var requestWrapper messages.RequestWrapper
requestWrapper.Res = childRes
responseChannel := make(chan messages.Message)
requestWrapper.Listener = responseChannel
CreateActor = func(res string, level int, parentInbox chan messages.RequestWrapper) (a Actor) {
a.res = childRes
a.level = 2
a.Inbox = make(chan messages.RequestWrapper)
return
}
var actor Actor
actor.res = parentRes
actor.level = 1
actor.children = make(map[string]Actor)
actor.Inbox = make(chan messages.RequestWrapper)
go actor.Run()
actor.Inbox <- requestWrapper
response := <-responseChannel
So(response, ShouldNotBeNil)
So(calledOnParent, ShouldBeFalse)
So(calledOnChild, ShouldBeTrue)
})
}