thrift

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2016 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package thrift implements Thrift encoding support for YARPC.

Usually, end users will not consume this package directly. It will be used by code generated by TODO, and the generated code will be consumed by end users.

Index

Constants

View Source
const Encoding transport.Encoding = "thrift"

Encoding is the name of this encoding.

Variables

View Source
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

func Register

func Register(registry transport.Registry, service Service, opts ...RegisterOption)

Register registers the handlers for the methods of the given service with the given Registry.

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. The code generator is responsible for putting a pretty interface in front of it.

func New

func New(c Config, opts ...ClientOption) Client

New creates a new Thrift client.

type ClientOption

type ClientOption interface {
	// contains filtered or unexported methods
}

ClientOption customizes the behavior of a Thrift client.

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.

type HandlerFunc

type HandlerFunc func(context.Context, yarpc.ReqMeta, wire.Value) (Response, error)

HandlerFunc is a convenience type alias for functions that implement that act as Handlers.

func (HandlerFunc) Handle

func (f HandlerFunc) Handle(ctx context.Context, reqMeta yarpc.ReqMeta, body wire.Value) (Response, error)

Handle forwards the request to the underlying function.

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 Response

type Response struct {
	Body envelope.Enveloper
	Meta yarpc.ResMeta

	IsApplicationError bool
}

Response contains the response from a generated Thrift handler.

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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