Documentation ¶
Index ¶
- Constants
- func CanonicalizeHeaderKey(k string) string
- func InjectClients(src transport.ClientConfigProvider, dest interface{})
- func OnewayInboundMiddleware(mw ...middleware.OnewayInboundMiddleware) middleware.OnewayInboundMiddleware
- func OnewayOutboundMiddleware(mw ...middleware.OnewayOutboundMiddleware) middleware.OnewayOutboundMiddleware
- func RegisterClientBuilder(f interface{}) (forget func())
- func UnaryInboundMiddleware(mw ...middleware.UnaryInboundMiddleware) middleware.UnaryInboundMiddleware
- func UnaryOutboundMiddleware(mw ...middleware.UnaryOutboundMiddleware) middleware.UnaryOutboundMiddleware
- type CallReqMeta
- type CallResMeta
- type Config
- type Dispatcher
- type Headers
- type InboundMiddleware
- type Inbounds
- type MapRegistry
- func (m MapRegistry) Choose(ctx context.Context, req *transport.Request) (transport.HandlerSpec, error)
- func (m MapRegistry) ChooseProcedure(service, procedure string) (transport.HandlerSpec, error)
- func (m MapRegistry) Register(rs []transport.Registrant)
- func (m MapRegistry) ServiceProcedures() []transport.ServiceProcedure
- type OutboundMiddleware
- type Outbounds
- type ReqMeta
- type ResMeta
- type StartStoppable
Constants ¶
const Version = "1.0.0-rc3"
Version is the current version of YARPC.
Variables ¶
This section is empty.
Functions ¶
func CanonicalizeHeaderKey ¶
CanonicalizeHeaderKey canonicalizes the given header key for storage into the Headers map.
func InjectClients ¶ added in v0.4.0
func InjectClients(src transport.ClientConfigProvider, dest interface{})
InjectClients injects clients from the given Dispatcher into the given struct. dest must be a pointer to a struct with zero or more exported fields Thrift client fields. Only fields with nil values and a `service` tag will be populated; everything else will be left unchanged.
type Handler struct { KeyValueClient keyvalueclient.Interface `service:"keyvalue"` UserClient json.Client `service:"users"` TagClient tagclient.Interface // will not be changed } var h Handler yarpc.InjectClients(dispatcher, &h) // InjectClients above is equivalent to, h.KeyValueClient = keyvalueclient.New(dispatcher.ClientConfig("keyvalue")) h.UserClient = json.New(dispatcher.ClientConfig("users"))
Builder functions for different client types may be registered using the RegisterClientBuilder function. This function panics if an empty client field without a registered constructor is encountered.
func OnewayInboundMiddleware ¶ added in v1.0.0
func OnewayInboundMiddleware(mw ...middleware.OnewayInboundMiddleware) middleware.OnewayInboundMiddleware
OnewayInboundMiddleware combines the given collection of unary inbound middleware in-order into a single OnewayInboundMiddleware.
func OnewayOutboundMiddleware ¶ added in v1.0.0
func OnewayOutboundMiddleware(mw ...middleware.OnewayOutboundMiddleware) middleware.OnewayOutboundMiddleware
OnewayOutboundMiddleware combines the given collection of unary outbound middleware in-order into a single OnewayOutboundMiddleware.
func RegisterClientBuilder ¶ added in v0.4.0
func RegisterClientBuilder(f interface{}) (forget func())
RegisterClientBuilder registers a builder function for a specific client type.
Functions must have the signature,
func(transport.ClientConfig) T
Where T is the type of the client. T MUST be an interface.
This function panics if a client for the given type has already been registered.
After a builder function for a client type is registered, these objects can be instantiated automatically using InjectClients.
A function to unregister the builder function is returned. Note that the function will clear whatever the corresponding type's builder function is at the time it is called, regardless of whether the value matches what was passed to this function or not.
func UnaryInboundMiddleware ¶ added in v1.0.0
func UnaryInboundMiddleware(mw ...middleware.UnaryInboundMiddleware) middleware.UnaryInboundMiddleware
UnaryInboundMiddleware combines the given collection of unary inbound middleware in-order into a single UnaryInboundMiddleware.
func UnaryOutboundMiddleware ¶ added in v1.0.0
func UnaryOutboundMiddleware(mw ...middleware.UnaryOutboundMiddleware) middleware.UnaryOutboundMiddleware
UnaryOutboundMiddleware combines the given collection of unary outbound middleware in-order into a single UnaryOutboundMiddleware.
Types ¶
type CallReqMeta ¶
type CallReqMeta interface { Procedure(string) CallReqMeta Headers(Headers) CallReqMeta ShardKey(string) CallReqMeta RoutingKey(string) CallReqMeta RoutingDelegate(string) CallReqMeta GetProcedure() string GetHeaders() Headers GetShardKey() string GetRoutingKey() string GetRoutingDelegate() string }
CallReqMeta contains information about an outgoing YARPC request.
func NewReqMeta ¶
func NewReqMeta() CallReqMeta
NewReqMeta constructs a CallReqMeta with the given Context.
type CallResMeta ¶
type CallResMeta interface {
Headers() Headers
}
CallResMeta contains information about an incoming YARPC response.
type Config ¶
type Config struct { Name string Inbounds Inbounds Outbounds Outbounds // Inbound and Outbound Middleware that will be applied to all incoming and // outgoing requests respectively. InboundMiddleware InboundMiddleware OutboundMiddleware OutboundMiddleware // Tracer is deprecated. The dispatcher does nothing with this propery. Tracer opentracing.Tracer }
Config specifies the parameters of a new RPC constructed via New.
type Dispatcher ¶
type Dispatcher interface { transport.Registrar transport.ClientConfigProvider // Inbounds returns a copy of the list of inbounds for this RPC object. // // The Inbounds will be returned in the same order that was used in the // configuration. Inbounds() Inbounds // Starts the RPC allowing it to accept and process new incoming // requests. // // Blocks until the RPC is ready to start accepting new requests. Start() error // Stops the RPC. No new requests will be accepted. // // Blocks until the RPC has stopped. Stop() error }
Dispatcher object is used to configure a YARPC application; it is used by Clients to send RPCs, and by Procedures to recieve them. This object is what enables an application to be transport-agnostic.
func NewDispatcher ¶
func NewDispatcher(cfg Config) Dispatcher
NewDispatcher builds a new Dispatcher using the specified Config.
type Headers ¶
Headers defines application headers which will be sent over the wire to the recipient of an RPC call.
func (Headers) Get ¶
Get retrieves the value associated with the given header key, and a boolean indicating whether the key actually existed in the header map.
func (Headers) Keys ¶
Keys returns a list of header keys defined on this Headers object.
All items in the list will be normalized using CanonicalizeHeaderKey.
func (Headers) With ¶
With returns a Headers object with the given key-value pair added to it. If a header with the same name already exists, it will be overwritten.
This API is similar to Go's append function. The returned Headers object MAY not point to the same underlying data store, so the returned value MUST always be used in place of the original object.
headers = headers.With("foo", "bar")
This call may be chained to set multiple headers consecutively.
headers = headers.With("foo", "bar").With("baz", "qux")
Again, note that the returned Headers object MAY point to a new object. It MAY also mutate the original object instead.
h1 = NewHeaders().With("foo", "bar") h2 = h1.With("baz", "qux") h1.Get("baz") // this MAY return "qux"
type InboundMiddleware ¶ added in v1.0.0
type InboundMiddleware struct { Unary middleware.UnaryInboundMiddleware Oneway middleware.OnewayInboundMiddleware }
InboundMiddleware contains the different type of inbound middleware
type MapRegistry ¶
type MapRegistry struct {
// contains filtered or unexported fields
}
MapRegistry is a Registry that maintains a map of the registered procedures.
func NewMapRegistry ¶
func NewMapRegistry(defaultService string) MapRegistry
NewMapRegistry builds a new MapRegistry that uses the given name as the default service name.
func (MapRegistry) Choose ¶
func (m MapRegistry) Choose(ctx context.Context, req *transport.Request) (transport.HandlerSpec, error)
Choose retrives the HandlerSpec for the service and procedure noted on the transport request, or returns an error.
func (MapRegistry) ChooseProcedure ¶
func (m MapRegistry) ChooseProcedure(service, procedure string) (transport.HandlerSpec, error)
ChooseProcedure retrieves the HandlerSpec for the given Procedure or returns an error.
func (MapRegistry) Register ¶
func (m MapRegistry) Register(rs []transport.Registrant)
Register registers the procedure with the MapRegistry.
func (MapRegistry) ServiceProcedures ¶
func (m MapRegistry) ServiceProcedures() []transport.ServiceProcedure
ServiceProcedures returns a list of services and their procedures that have been registered so far.
type OutboundMiddleware ¶ added in v1.0.0
type OutboundMiddleware struct { Unary middleware.UnaryOutboundMiddleware Oneway middleware.OnewayOutboundMiddleware }
OutboundMiddleware contains the different type of outbound middleware
type ReqMeta ¶
type ReqMeta interface { Caller() string Encoding() transport.Encoding Headers() Headers Procedure() string Service() string }
ReqMeta contains information about an incoming YARPC request.
type StartStoppable ¶
type StartStoppable interface { // Starts the RPC allowing it to accept and process new incoming // requests. // // Blocks until the RPC is ready to start accepting new requests. Start() error // Stops the RPC. No new requests will be accepted. // // Blocks until the RPC has stopped. Stop() error }
StartStoppable objects are used to define a common Start/Stop functionality across different dispatcher objects
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
api
|
|
thrift/gen-go/echo
Package echo is generated code used to make or handle TChannel calls using Thrift.
|
Package echo is generated code used to make or handle TChannel calls using Thrift. |
thrift/gen-go/gauntlet_tchannel
Package gauntlet_tchannel is generated code used to make or handle TChannel calls using Thrift.
|
Package gauntlet_tchannel is generated code used to make or handle TChannel calls using Thrift. |
encoding
|
|
json
Package json provides the JSON encoding for YARPC.
|
Package json provides the JSON encoding for YARPC. |
raw
Package raw provides the raw encoding for YARPC.
|
Package raw provides the raw encoding for YARPC. |
thrift
Package thrift implements Thrift encoding support for YARPC.
|
Package thrift implements Thrift encoding support for YARPC. |
thrift/thriftrw-plugin-yarpc
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. |
examples
|
|
Package transport implements the low level concerns of sending and receiving bytes.
|
Package transport implements the low level concerns of sending and receiving bytes. |
http
Package http implements the HTTP inbound and outbound transports for YARPC.
|
Package http implements the HTTP inbound and outbound transports for YARPC. |
x/redis
Package redis provides an simple, EXPERIMENTAL queuing transport backed by a redis list.
|
Package redis provides an simple, EXPERIMENTAL queuing transport backed by a redis list. |
Package yarpctest provides utilities to test YARPC services and clients.
|
Package yarpctest provides utilities to test YARPC services and clients. |
recorder
Package recorder records & replay yarpc requests on the client side.
|
Package recorder records & replay yarpc requests on the client side. |