internal

package
Version: v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyPerRPCCreds

func ApplyPerRPCCreds(ctx context.Context, copts *CallOptions, uri string, isChannelSecure bool) (context.Context, error)

ApplyPerRPCCreds applies any per-RPC credentials in the given call options and returns a new context with the additional metadata. It will return an error if isChannelSecure is false but the per-RPC credentials require a secure channel.

func ClearMessage

func ClearMessage(m interface{}) error

ClearMessage resets the given value to its zero-value state. It returns an error if the given out value is not settable.

func CloneMessage

func CloneMessage(m interface{}) (interface{}, error)

CloneMessage returns a copy of the given value.

func CopyMessage

func CopyMessage(out, in interface{}) error

CopyMessage copies data from the given in value to the given out value. It returns an error if the two values do not have the same type or if the given out value is not settable.

func FindStreamingMethod

func FindStreamingMethod(methodName string, methods []grpc.StreamDesc) *grpc.StreamDesc

FindStreamingMethod returns the stream descriptor for the named method. If the method is not found in the given slice of descriptors, nil is returned.

func FindUnaryMethod

func FindUnaryMethod(methodName string, methods []grpc.MethodDesc) *grpc.MethodDesc

FindUnaryMethod returns the method descriptor for the named method. If the method is not found in the given slice of descriptors, nil is returned.

func TranslateContextError

func TranslateContextError(err error) error

TranslateContextError converts the given error to a gRPC status error if it is a context error. If it is context.DeadlineExceeded, it is converted to an error with a status code of DeadlineExceeded. If it is context.Canceled, it is converted to an error with a status code of Canceled. If it is not a context error, it is returned without any conversion.

Types

type CallOptions

type CallOptions struct {
	// Headers is a slice of metadata pointers which should all be set when
	// response header metadata is received.
	Headers []*metadata.MD
	// Trailers is a slice of metadata pointers which should all be set when
	// response trailer metadata is received.
	Trailers []*metadata.MD
	// Peer is a slice of peer pointers which should all be set when the
	// remote peer is known.
	Peer []*peer.Peer
	// Creds are per-RPC credentials to use for a call.
	Creds credentials.PerRPCCredentials
	// MaxRecv is the maximum number of bytes to receive for a single message
	// in a call.
	MaxRecv int
	// MaxSend is the maximum number of bytes to send for a single message in
	// a call.
	MaxSend int
}

CallOptions represents the state of in-effect grpc.CallOptions.

func GetCallOptions

func GetCallOptions(opts []grpc.CallOption) *CallOptions

GetCallOptions converts the given slice of grpc.CallOptions into a CallOptions struct.

func (*CallOptions) SetHeaders

func (co *CallOptions) SetHeaders(md metadata.MD)

SetHeaders sets all accumulated header addresses to the given metadata. This satisfies grpc.Header call options.

func (*CallOptions) SetPeer

func (co *CallOptions) SetPeer(p *peer.Peer)

SetPeer sets all accumulated peer addresses to the given peer. This satisfies grpc.Peer call options.

func (*CallOptions) SetTrailers

func (co *CallOptions) SetTrailers(md metadata.MD)

SetTrailers sets all accumulated trailer addresses to the given metadata. This satisfies grpc.Trailer call options.

type ServerTransportStream

type ServerTransportStream struct {
	// Name is the full method name in "/service/method" format.
	Name string
	// Stream is the underlying stream to which header and trailer calls are
	// delegated.
	Stream grpc.ServerStream
}

ServerTransportStream implements grpc.ServerTransportStream and wraps a grpc.ServerStream, delegating most calls to it.

func (*ServerTransportStream) Method

func (sts *ServerTransportStream) Method() string

Method satisfies the grpc.ServerTransportStream, returning the full path of the method invocation that the stream represents.

func (*ServerTransportStream) SendHeader

func (sts *ServerTransportStream) SendHeader(md metadata.MD) error

SendHeader satisfies the grpc.ServerTransportStream and delegates to the underlying grpc.ServerStream.

func (*ServerTransportStream) SetHeader

func (sts *ServerTransportStream) SetHeader(md metadata.MD) error

SetHeader satisfies the grpc.ServerTransportStream and delegates to the underlying grpc.ServerStream.

func (*ServerTransportStream) SetTrailer

func (sts *ServerTransportStream) SetTrailer(md metadata.MD) error

SetTrailer satisfies the grpc.ServerTransportStream and delegates to the underlying grpc.ServerStream. If the underlying stream provides a TrySetTrailer(metadata.MD) error method, it will be used to set trailers. Otherwise, the normal SetTrailer(metadata.MD) method will be used and a nil error will always be returned.

type UnaryServerTransportStream

type UnaryServerTransportStream struct {
	// Name is the full method name in "/service/method" format.
	Name string
	// contains filtered or unexported fields
}

UnaryServerTransportStream implements grpc.ServerTransportStream and can be used by unary calls to collect headers and trailers from a handler.

func (*UnaryServerTransportStream) Finish

func (sts *UnaryServerTransportStream) Finish()

Finish marks headers and trailers as sent, so that subsequent calls to SetHeader, SendHeader, or SetTrailer will fail.

func (*UnaryServerTransportStream) GetHeaders

func (sts *UnaryServerTransportStream) GetHeaders() metadata.MD

GetHeaders returns the cumulative set of headers set by calls to SetHeader and SendHeader. This is used by a server to gather the headers that must actually be sent to a client.

func (*UnaryServerTransportStream) GetTrailers

func (sts *UnaryServerTransportStream) GetTrailers() metadata.MD

GetTrailers returns the cumulative set of trailers set by calls to SetTrailer. This is used by a server to gather the headers that must actually be sent to a client.

func (*UnaryServerTransportStream) Method

func (sts *UnaryServerTransportStream) Method() string

Method satisfies the grpc.ServerTransportStream, returning the full path of the method invocation that the stream represents.

func (*UnaryServerTransportStream) SendHeader

func (sts *UnaryServerTransportStream) SendHeader(md metadata.MD) error

SendHeader satisfies the grpc.ServerTransportStream, adding the given metadata to the set of response headers. This implementation does not actually send the headers but rather marks the headers as sent so that future calls to SetHeader or SendHeader will return an error.

func (*UnaryServerTransportStream) SetHeader

func (sts *UnaryServerTransportStream) SetHeader(md metadata.MD) error

SetHeader satisfies the grpc.ServerTransportStream, adding the given metadata to the set of response headers that will be sent to the client.

func (*UnaryServerTransportStream) SetTrailer

func (sts *UnaryServerTransportStream) SetTrailer(md metadata.MD) error

SetTrailer satisfies the grpc.ServerTransportStream, adding the given metadata to the set of response trailers that will be sent to the client.

Jump to

Keyboard shortcuts

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