当前位置: 首页>>代码示例>>Golang>>正文


Golang Request.Procedure方法代码示例

本文整理汇总了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())
}
开发者ID:yarpc,项目名称:yarpc-go,代码行数:12,代码来源:req.go

示例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
}
开发者ID:yarpc,项目名称:yarpc-go,代码行数:50,代码来源:outbound.go


注:本文中的go/uber/org/yarpc/transport.Request.Procedure方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。