Documentation ¶
Overview ¶
Package encoding provides APIs for encoding authors.
Index ¶
- type Call
- func (c *Call) Caller() string
- func (c *Call) Encoding() transport.Encoding
- func (c *Call) Header(k string) string
- func (c *Call) HeaderNames() []string
- func (c *Call) Procedure() string
- func (c *Call) RoutingDelegate() string
- func (c *Call) RoutingKey() string
- func (c *Call) Service() string
- func (c *Call) ShardKey() string
- func (c *Call) Transport() string
- func (c *Call) WriteResponseHeader(k, v string) error
- type CallOption
- type InboundCall
- type InboundCallOption
- type OutboundCall
- func (c *OutboundCall) ReadFromResponse(ctx context.Context, res *transport.Response) (context.Context, error)
- func (c *OutboundCall) WriteToRequest(ctx context.Context, req *transport.Request) (context.Context, error)
- func (c *OutboundCall) WriteToRequestMeta(ctx context.Context, reqMeta *transport.RequestMeta) (context.Context, error)
- type StreamOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Call ¶
type Call struct {
// contains filtered or unexported fields
}
Call provides information about the current request inside handlers.
func CallFromContext ¶
CallFromContext retrieves information about the current incoming request from the given context. Returns nil if the context is not a valid request context.
The object is valid only as long as the request is ongoing.
func (*Call) Header ¶
Header returns the value of the given request header provided with the request.
func (*Call) HeaderNames ¶
HeaderNames returns a sorted list of the names of user defined headers provided with this request.
func (*Call) RoutingDelegate ¶
RoutingDelegate returns the routing delegate for this request.
func (*Call) RoutingKey ¶
RoutingKey returns the routing key for this request.
func (*Call) WriteResponseHeader ¶
WriteResponseHeader writes headers to the response of this call.
type CallOption ¶
type CallOption struct {
// contains filtered or unexported fields
}
CallOption defines options that may be passed in at call sites to other services.
Encoding authors should accept yarpc.CallOptions and convert them to encoding.CallOptions to use with NewOutboundCall. This will keep the API for service authors simple.
func ResponseHeaders ¶
func ResponseHeaders(h *map[string]string) CallOption
ResponseHeaders specifies that headers received in response to this request should replace the given map.
func WithHeader ¶
func WithHeader(k, v string) CallOption
WithHeader adds a new header to the request.
func WithRoutingDelegate ¶
func WithRoutingDelegate(rd string) CallOption
WithRoutingDelegate sets the routing delegate for the request.
func WithRoutingKey ¶
func WithRoutingKey(rk string) CallOption
WithRoutingKey sets the routing key for the request.
func WithShardKey ¶
func WithShardKey(sk string) CallOption
WithShardKey sets the shard key for the request.
type InboundCall ¶
type InboundCall struct {
// contains filtered or unexported fields
}
InboundCall holds information about the inbound call and its response.
Encoding authors may use InboundCall to provide information about the incoming request on the Context and send response headers through WriteResponseHeader.
func NewInboundCall ¶
func NewInboundCall(ctx context.Context) (context.Context, *InboundCall)
NewInboundCall builds a new InboundCall with the given context.
A request context is returned and must be used in place of the original.
func NewInboundCallWithOptions ¶ added in v1.27.0
func NewInboundCallWithOptions(ctx context.Context, opts ...InboundCallOption) (context.Context, *InboundCall)
NewInboundCallWithOptions builds a new InboundCall with the given context and options.
A request context is returned and must be used in place of the original.
func (*InboundCall) ReadFromRequest ¶
func (ic *InboundCall) ReadFromRequest(req *transport.Request) error
ReadFromRequest reads information from the given request.
This information may be queried on the context using functions like Caller, Service, Procedure, etc.
func (*InboundCall) ReadFromRequestMeta ¶ added in v1.27.0
func (ic *InboundCall) ReadFromRequestMeta(reqMeta *transport.RequestMeta) error
ReadFromRequestMeta reads information from the given request.
This information may be queried on the context using functions like Caller, Service, Procedure, etc.
func (*InboundCall) WriteToResponse ¶
func (ic *InboundCall) WriteToResponse(resw transport.ResponseWriter) error
WriteToResponse writes response information from the InboundCall onto the given ResponseWriter.
If used, this must be called before writing the response body to the ResponseWriter.
type InboundCallOption ¶ added in v1.27.0
type InboundCallOption interface {
// contains filtered or unexported methods
}
InboundCallOption is an option for configuring an InboundCall.
func DisableResponseHeaders ¶ added in v1.27.0
func DisableResponseHeaders() InboundCallOption
DisableResponseHeaders disables response headers for inbound calls.
type OutboundCall ¶
type OutboundCall struct {
// contains filtered or unexported fields
}
OutboundCall is an outgoing call. It holds per-call options for a request.
Encoding authors may use OutboundCall to provide a CallOption-based request customization mechanism, including returning response headers through ResponseHeaders.
func NewOutboundCall ¶
func NewOutboundCall(options ...CallOption) *OutboundCall
NewOutboundCall constructs a new OutboundCall with the given options.
func NewStreamOutboundCall ¶ added in v1.27.0
func NewStreamOutboundCall(options ...CallOption) (*OutboundCall, error)
NewStreamOutboundCall constructs a new OutboundCall with the given options and enforces the OutboundCall is valid for streams.
func (*OutboundCall) ReadFromResponse ¶
func (c *OutboundCall) ReadFromResponse(ctx context.Context, res *transport.Response) (context.Context, error)
ReadFromResponse reads information from the response for this call.
This should be called only if the request is unary.
func (*OutboundCall) WriteToRequest ¶
func (c *OutboundCall) WriteToRequest(ctx context.Context, req *transport.Request) (context.Context, error)
WriteToRequest fills the given request with request-specific options from the call.
The context MAY be replaced by the OutboundCall.
func (*OutboundCall) WriteToRequestMeta ¶ added in v1.27.0
func (c *OutboundCall) WriteToRequestMeta(ctx context.Context, reqMeta *transport.RequestMeta) (context.Context, error)
WriteToRequestMeta fills the given request with request-specific options from the call.
The context MAY be replaced by the OutboundCall.
type StreamOption ¶ added in v1.27.0
type StreamOption interface {
// contains filtered or unexported methods
}
StreamOption is an option that may be passed in at streaming function call sites.