本文整理汇总了Golang中go/uber/org/yarpc/transport.Request.Procedure方法的典型用法代码示例。如果您正苦于以下问题:Golang Request.Procedure方法的具体用法?Golang Request.Procedure怎么用?Golang Request.Procedure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类go/uber/org/yarpc/transport.Request
的用法示例。
在下文中一共展示了Request.Procedure方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: ToTransportRequest
// ToTransportRequest fills the given transport request with information from
// the given ReqMeta.
func ToTransportRequest(reqMeta yarpc.CallReqMeta, req *transport.Request) {
if reqMeta == nil {
return
}
req.Procedure = reqMeta.GetProcedure()
req.ShardKey = reqMeta.GetShardKey()
req.RoutingKey = reqMeta.GetRoutingKey()
req.RoutingDelegate = reqMeta.GetRoutingDelegate()
req.Headers = transport.Headers(reqMeta.GetHeaders())
}
示例2: buildTransportRequest
func (c thriftClient) buildTransportRequest(
reqMeta yarpc.CallReqMeta,
reqBody envelope.Enveloper,
) (*transport.Request, protocol.Protocol, error) {
proto := c.p
if !c.Enveloping {
proto = disableEnvelopingProtocol{
Protocol: proto,
Type: wire.Reply, // we only decode replies with this instance
}
}
treq := transport.Request{
Caller: c.ch.Caller(),
Service: c.ch.Service(),
Encoding: Encoding,
}
meta.ToTransportRequest(reqMeta, &treq)
// Always override the procedure name to the Thrift procedure name.
treq.Procedure = procedureName(c.thriftService, reqBody.MethodName())
value, err := reqBody.ToWire()
if err != nil {
// ToWire validates the request. If it failed, we should return the error
// as-is because it's not an encoding error.
return nil, nil, err
}
reqEnvelopeType := reqBody.EnvelopeType()
if reqEnvelopeType != wire.Call && reqEnvelopeType != wire.OneWay {
return nil, nil, encoding.RequestBodyEncodeError(
&treq, errUnexpectedEnvelopeType(reqEnvelopeType),
)
}
var buffer bytes.Buffer
err = proto.EncodeEnveloped(wire.Envelope{
Name: reqBody.MethodName(),
Type: reqEnvelopeType,
SeqID: 1, // don't care
Value: value,
}, &buffer)
if err != nil {
return nil, nil, encoding.RequestBodyEncodeError(&treq, err)
}
treq.Body = &buffer
return &treq, proto, nil
}