本文整理汇总了Golang中go/uber/org/yarpc.ReqMeta类的典型用法代码示例。如果您正苦于以下问题:Golang ReqMeta类的具体用法?Golang ReqMeta怎么用?Golang ReqMeta使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ReqMeta类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: Handle
func (h *multiHopHandler) Handle(ctx context.Context, reqMeta yarpc.ReqMeta, body interface{}) (interface{}, yarpc.ResMeta, error) {
if h.phoneClient == nil {
panic("call SetClient() and SetTransport() first")
}
assertBaggageMatches(ctx, h.t, h.wantBaggage)
span := opentracing.SpanFromContext(ctx)
for key, value := range h.addBaggage {
span.SetBaggageItem(key, value)
}
ctx = opentracing.ContextWithSpan(ctx, span)
var resp js.RawMessage
phoneResMeta, err := h.phoneClient.Call(
ctx,
yarpc.NewReqMeta().Procedure("phone").Headers(reqMeta.Headers()),
&server.PhoneRequest{
Service: "ctxclient",
Procedure: h.phoneCallTo,
Transport: h.phoneCallTransport,
Body: &js.RawMessage{'{', '}'},
}, &resp)
resMeta := yarpc.NewResMeta().Headers(phoneResMeta.Headers())
return map[string]interface{}{}, resMeta, err
}
开发者ID:yarpc,项目名称:yarpc-go,代码行数:27,代码来源:behavior.go
示例2: Phone
// Phone implements the phone procedure
func Phone(ctx context.Context, reqMeta yarpc.ReqMeta, body *PhoneRequest) (*PhoneResponse, yarpc.ResMeta, error) {
var outbound transport.UnaryOutbound
switch {
case body.Transport.HTTP != nil:
t := body.Transport.HTTP
url := fmt.Sprintf("http://%s:%d", t.Host, t.Port)
outbound = ht.NewOutbound(url)
case body.Transport.TChannel != nil:
t := body.Transport.TChannel
hostport := fmt.Sprintf("%s:%d", t.Host, t.Port)
ch, err := tchannel.NewChannel("yarpc-test-client", nil)
if err != nil {
return nil, nil, fmt.Errorf("failed to build TChannel: %v", err)
}
outbound = tch.NewOutbound(ch, tch.HostPort(hostport))
default:
return nil, nil, fmt.Errorf("unconfigured transport")
}
if err := outbound.Start(transport.NoDeps); err != nil {
return nil, nil, err
}
defer outbound.Stop()
// TODO use reqMeta.Service for caller
client := json.New(channel.MultiOutbound("yarpc-test", body.Service, transport.Outbounds{
Unary: outbound,
}))
resBody := PhoneResponse{
Service: "yarpc-test", // TODO use reqMeta.Service
Procedure: reqMeta.Procedure(),
}
ctx, cancel := context.WithTimeout(ctx, 500*time.Millisecond)
defer cancel()
_, err := client.Call(
ctx,
yarpc.NewReqMeta().Procedure(body.Procedure),
body.Body,
&resBody.Body)
if err != nil {
return nil, nil, err
}
return &resBody, nil, nil
}
开发者ID:yarpc,项目名称:yarpc-go,代码行数:48,代码来源:phone.go
示例3: resMetaFromReqMeta
func resMetaFromReqMeta(reqMeta yarpc.ReqMeta) yarpc.ResMeta {
return yarpc.NewResMeta().Headers(reqMeta.Headers())
}
开发者ID:yarpc,项目名称:yarpc-go,代码行数:3,代码来源:gauntlet.go
示例4: Echo
func (h helloHandler) Echo(ctx context.Context, reqMeta yarpc.ReqMeta, e *echo.EchoRequest) (*echo.EchoResponse, yarpc.ResMeta, error) {
return &echo.EchoResponse{Message: e.Message, Count: e.Count + 1},
yarpc.NewResMeta().Headers(reqMeta.Headers()),
nil
}
开发者ID:yarpc,项目名称:yarpc-go,代码行数:5,代码来源:main.go
示例5: yarpcEcho
func yarpcEcho(ctx context.Context, reqMeta yarpc.ReqMeta, body []byte) ([]byte, yarpc.ResMeta, error) {
return body, yarpc.NewResMeta().Headers(reqMeta.Headers()), nil
}
开发者ID:yarpc,项目名称:yarpc-go,代码行数:3,代码来源:bench_test.go
示例6: Echo
// Echo endpoint for the Echo service.
func (EchoThrift) Echo(ctx context.Context, reqMeta yarpc.ReqMeta, ping *echo.Ping) (*echo.Pong, yarpc.ResMeta, error) {
return &echo.Pong{Boop: ping.Beep}, yarpc.NewResMeta().Headers(reqMeta.Headers()), nil
}
开发者ID:yarpc,项目名称:yarpc-go,代码行数:4,代码来源:echo.go
示例7: EchoJSON
// EchoJSON implements the echo procedure.
func EchoJSON(ctx context.Context, reqMeta yarpc.ReqMeta, body map[string]interface{}) (map[string]interface{}, yarpc.ResMeta, error) {
return body, yarpc.NewResMeta().Headers(reqMeta.Headers()), nil
}
开发者ID:yarpc,项目名称:yarpc-go,代码行数:4,代码来源:echo.go
注:本文中的go/uber/org/yarpc.ReqMeta类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论