Documentation ¶
Overview ¶
Package protobuf implements Protocol Buffers encoding support for YARPC.
Index ¶
- Constants
- func BuildProcedures(serviceName string, methodNameToUnaryHandler map[string]transport.UnaryHandler, ...) []transport.Procedure
- func CastError(expectedType proto.Message, actualType proto.Message) error
- func NewOnewayHandler(handleOneway func(context.Context, proto.Message) error, ...) transport.OnewayHandler
- func NewUnaryHandler(handle func(context.Context, proto.Message) (proto.Message, error), ...) transport.UnaryHandler
- func SetRawResponse(headers transport.Headers) transport.Headers
- type Client
- type ClientOption
Constants ¶
const ( // Encoding is the name of this encoding. Encoding transport.Encoding = "proto" // JSONEncoding is the name of the JSON encoding. // // Protobuf handlers are able to handle both Encoding and JSONEncoding encodings. JSONEncoding transport.Encoding = "json" )
Variables ¶
This section is empty.
Functions ¶
func BuildProcedures ¶
func BuildProcedures( serviceName string, methodNameToUnaryHandler map[string]transport.UnaryHandler, methodNameToOnewayHandler map[string]transport.OnewayHandler, ) []transport.Procedure
BuildProcedures builds the transport.Procedures.
func CastError ¶
CastError returns an error saying that generated code could not properly cast a proto.Message to it's expected type.
func NewOnewayHandler ¶
func NewOnewayHandler( handleOneway func(context.Context, proto.Message) error, newRequest func() proto.Message, ) transport.OnewayHandler
NewOnewayHandler returns a new OnewayHandler.
func NewUnaryHandler ¶
func NewUnaryHandler( handle func(context.Context, proto.Message) (proto.Message, error), newRequest func() proto.Message, ) transport.UnaryHandler
NewUnaryHandler returns a new UnaryHandler.
func SetRawResponse ¶
SetRawResponse will set rawResponseHeaderKey to "true".
rawResponseHeaderKey is a header key attached to either a request or response that signals a UnaryHandler to not encode an application error inside a wirepb.Response object, instead marshalling the actual response.
Note per the documentation on transport.Headers#With, the returned Header may not be the same as the input header, so the caller should always update the header with:
header = protobuf.SetRawResponse(header)
Types ¶
type Client ¶
type Client interface { Call( ctx context.Context, requestMethodName string, request proto.Message, newResponse func() proto.Message, options ...yarpc.CallOption, ) (proto.Message, error) CallOneway( ctx context.Context, requestMethodName string, request proto.Message, options ...yarpc.CallOption, ) (transport.Ack, error) }
Client is a protobuf client.
func NewClient ¶
func NewClient(serviceName string, clientConfig transport.ClientConfig, options ...ClientOption) Client
NewClient creates a new client.
type ClientOption ¶ added in v1.9.0
type ClientOption interface {
// contains filtered or unexported methods
}
ClientOption is an option for a new Client.
var UseJSON ClientOption = useJSON{}
UseJSON says to use the json encoding for client/server communication.
func ClientBuilderOptions ¶ added in v1.9.0
func ClientBuilderOptions(_ transport.ClientConfig, structField reflect.StructField) []ClientOption
ClientBuilderOptions returns ClientOptions that yarpc.InjectClients should use for a specific client given information about the field into which the client is being injected.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
internal
|
|
wirepb
Package wirepb is a generated protocol buffer package.
|
Package wirepb is a generated protocol buffer package. |
Package main provides a protoc plugin that generates code for the protobuf encoding for YARPC.
|
Package main provides a protoc plugin that generates code for the protobuf encoding for YARPC. |
internal/lib
Package lib contains the library code for protoc-gen-yarpc-go.
|
Package lib contains the library code for protoc-gen-yarpc-go. |
internal/testing
Package testing is a generated protocol buffer package.
|
Package testing is a generated protocol buffer package. |