encoding

package
v1.59.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 10, 2021 License: MIT Imports: 5 Imported by: 18

Documentation

Overview

Package encoding provides APIs for encoding authors.

Index

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

func CallFromContext(ctx context.Context) *Call

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) Caller

func (c *Call) Caller() string

Caller returns the name of the service making this request.

func (*Call) CallerProcedure added in v1.53.0

func (c *Call) CallerProcedure() string

CallerProcedure returns the name of the procedure from the service making this request.

func (*Call) Encoding

func (c *Call) Encoding() transport.Encoding

Encoding returns the encoding for this request.

func (*Call) Header

func (c *Call) Header(k string) string

Header returns the value of the given request header provided with the request.

func (*Call) HeaderNames

func (c *Call) HeaderNames() []string

HeaderNames returns a sorted list of the names of user defined headers provided with this request.

func (*Call) OriginalHeaders added in v1.59.0

func (c *Call) OriginalHeaders() map[string]string

OriginalHeaders returns a copy of the given request headers provided with the request. The header key are not canonicalized and suitable for case-sensitive transport like TChannel.

func (*Call) Procedure

func (c *Call) Procedure() string

Procedure returns the name of the procedure being called.

func (*Call) RoutingDelegate

func (c *Call) RoutingDelegate() string

RoutingDelegate returns the routing delegate for this request.

func (*Call) RoutingKey

func (c *Call) RoutingKey() string

RoutingKey returns the routing key for this request.

func (*Call) Service

func (c *Call) Service() string

Service returns the name of the service being called.

func (*Call) ShardKey

func (c *Call) ShardKey() string

ShardKey returns the shard key for this request.

func (*Call) Transport added in v1.32.0

func (c *Call) Transport() string

Transport returns the name of the transport being called.

func (*Call) WriteResponseHeader

func (c *Call) WriteResponseHeader(k, v string) error

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL