grpcheader

package
v1.12.0 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2017 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package grpcheader provides the headers functionality for gRPC.

This is separated from the main grpc package so that it can be used with grpc-go clients without needing to import so many yarpc packages, as well as for future cross-package yarpc work.

Index

Constants

View Source
const (
	// CallerHeader is the header key for the name of the service sending the
	// request. This corresponds to the Request.Caller attribute.
	// This header is required.
	CallerHeader = "rpc-caller"
	// ServiceHeader is the header key for the name of the service to which
	// the request is being sent. This corresponds to the Request.Service attribute.
	// This header is required.
	ServiceHeader = "rpc-service"
	// ShardKeyHeader is the header key for the shard key used by the destined service
	// to shard the request. This corresponds to the Request.ShardKey attribute.
	// This header is optional.
	ShardKeyHeader = "rpc-shard-key"
	// RoutingKeyHeader is the header key for the traffic group responsible for
	// handling the request. This corresponds to the Request.RoutingKey attribute.
	// This header is optional.
	RoutingKeyHeader = "rpc-routing-key"
	// RoutingDelegateHeader is the header key for a service that can proxy the
	// destined service. This corresponds to the Request.RoutingDelegate attribute.
	// This header is optional.
	RoutingDelegateHeader = "rpc-routing-delegate"
	// EncodingHeader is the header key for the encoding used for the request body.
	// This corresponds to the Request.Encoding attribute.
	// If this is not set, content-type will attempt to be read for the encoding per
	// the gRPC wire format http://www.grpc.io/docs/guides/wire.html
	// For example, a content-type of "application/grpc+proto" will be intepreted
	// as the proto encoding.
	// This header is required unless content-type is set properly.
	EncodingHeader = "rpc-encoding"
	// ErrorNameHeader is the header key for the error name.
	ErrorNameHeader = "rpc-error-name"
)

Variables

This section is empty.

Functions

func IsReserved

func IsReserved(header string) bool

IsReserved returns true if the header is reserved.

Types

type ContextWrapper

type ContextWrapper struct {
	// contains filtered or unexported fields
}

ContextWrapper wraps a context for grpc-go with the required headers for yarpc.

This is a convenience object for use when using grpc-go clients. You must set certain yarpc-specific headers when using native grpc-go clients calling into yarpc servers, and this object makes that simpler.

func NewContextWrapper

func NewContextWrapper() *ContextWrapper

NewContextWrapper returns a new ContextWrapper.

The only fields that a grpc-go client needs to set are caller and service. Encoding is also required if content-type is not set properly. See the documention on EncodingHeader.

func (*ContextWrapper) WithCaller

func (c *ContextWrapper) WithCaller(caller string) *ContextWrapper

WithCaller returns a new ContextWrapper with the given caller.

func (*ContextWrapper) WithEncoding

func (c *ContextWrapper) WithEncoding(encoding string) *ContextWrapper

WithEncoding returns a new ContextWrapper with the given encoding.

func (*ContextWrapper) WithRoutingDelegate

func (c *ContextWrapper) WithRoutingDelegate(routingDelegate string) *ContextWrapper

WithRoutingDelegate returns a new ContextWrapper with the given routing delegate.

func (*ContextWrapper) WithRoutingKey

func (c *ContextWrapper) WithRoutingKey(routingKey string) *ContextWrapper

WithRoutingKey returns a new ContextWrapper with the given routing key.

func (*ContextWrapper) WithService

func (c *ContextWrapper) WithService(service string) *ContextWrapper

WithService returns a new ContextWrapper with the given service.

func (*ContextWrapper) WithShardKey

func (c *ContextWrapper) WithShardKey(shardKey string) *ContextWrapper

WithShardKey returns a new ContextWrapper with the given shard key.

func (*ContextWrapper) Wrap

Wrap wraps the given context with the headers.

Jump to

Keyboard shortcuts

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