Documentation ¶
Overview ¶
Package thrift implements Thrift encoding support for YARPC.
To use this package, you must install ThriftRW 0.2.0 or newer.
go get github.com/thriftrw/thriftrw-go
You must also install the ThriftRW plugin for YARPC.
go get github.com/yarpc/yarpc-go/encoding/thrift/thriftrw-plugin-yarpc
To generate YARPC compatible code from a Thrift file, use the command,
thriftrw-go --plugin yarpc myservice.thrift
In addition to generating code for types specified in your THrift file, this will generate two packages for each service in the file: a client package and a server package.
myservice |- yarpc |- myserviceclient |- myserviceserver
The client package allows sending requests through a YARPC channel.
client := myserviceclient.New(dispatcher.Channel("myservice"))
The server package facilitates registration of service implementations with a YARPC dispatcher.
handler := myHandler{} thrift.Register(dispatcher, myserviceserver.New(handler))
Index ¶
Constants ¶
const Encoding transport.Encoding = "thrift"
Encoding is the name of this encoding.
Variables ¶
var DisableEnvelopingForTransport transport.Options
DisableEnvelopingForTransport allows a transport to disable Thrift request and response enveloping.
Use this from a transport implementation that wishes to disable Thrift enveloping.
func (myOutbound) Options() transport.Options { return otherOptions.Merge(thrift.DisableEnvelopingForTransport) }
Functions ¶
Types ¶
type Client ¶
type Client interface { // Call the given Thrift method. Call(ctx context.Context, reqMeta yarpc.CallReqMeta, reqBody envelope.Enveloper) (wire.Value, yarpc.CallResMeta, error) }
Client is a generic Thrift client. It speaks in raw Thrift payloads.
Users should use the client generated by the code generator rather than using this directly.
type ClientOption ¶
type ClientOption interface {
// contains filtered or unexported methods
}
ClientOption customizes the behavior of a Thrift client.
var Multiplexed ClientOption = multiplexedOption{}
Multiplexed is an option that specifies that requests from a client should use Thrift multiplexing. This option should be used if the remote server is using Thrift's TMultiplexedProtocol. It includes the name of the service in the envelope name for all outbound requests.
Specify this option when constructing the Thrift client.
client := myserviceclient.New(channel, thrift.Multiplexed)
type Config ¶
type Config struct { // Name of the Thrift service. This is the name used in the Thrift file // with the 'service' keyword. Service string // Channel through which requests will be sent. Required. Channel transport.Channel // Thrift encoding protocol. Defaults to Binary if nil. Protocol protocol.Protocol }
Config contains the configuration for the Client.
type Handler ¶
type Handler interface {
Handle(ctx context.Context, reqMeta yarpc.ReqMeta, body wire.Value) (Response, error)
}
Handler represents a Thrift request handler. It speaks in raw Thrift payloads.
Users should use the server package generated by the code generator rather than using this directly.
type HandlerFunc ¶
HandlerFunc is a convenience type alias for functions that act as Handlers.
type Option ¶
type Option interface { ClientOption RegisterOption }
Option unifies options that apply to both, Thrift clients and handlers.
var DisableEnveloping Option = disableEnvelopingOption{}
DisableEnveloping is an option that disables enveloping of Thrift requests and responses.
It may be specified on the client side when the client is constructed.
client := myserviceclient.New(channel, thrift.DisableEnveloping)
It may be specified on the server side when the handler is registered.
thrift.Register(dispatch, myserviceserver.New(handler), thrift.DisableEnveloping)
type RegisterOption ¶
type RegisterOption interface {
// contains filtered or unexported methods
}
RegisterOption customizes the behavior of a Thrift handler during registration.
type Service ¶
type Service interface { // Name of the Thrift service. Name() string // Protocol to use for requests and responses of this service. Protocol() protocol.Protocol // Map of method name to Handler for all methods of this service. Handlers() map[string]Handler }
Service represents a Thrift service implementation.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
thriftrw-plugin-yarpc implements a plugin for ThriftRW that generates code compatible with YARPC.
|
thriftrw-plugin-yarpc implements a plugin for ThriftRW that generates code compatible with YARPC. |