http

package
v1.0.0-rc3 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2016 License: MIT Imports: 22 Imported by: 13

Documentation

Overview

Package http implements the HTTP inbound and outbound transports for YARPC.

Note that the Close method for the HTTP Inbound does NOT immediately close the ongoing connections. The connection will remain open until all clients have disconnected.

Index

Constants

View Source
const (
	// ApplicationHeaderPrefix is the prefix added to application headers over
	// the wire.
	ApplicationHeaderPrefix = "Rpc-Header-"

	// CallerHeader is the HTTP header used to indiate the service doing the calling
	CallerHeader = "Rpc-Caller"

	// EncodingHeader is the HTTP header used to specify the name of the
	// encoding.
	EncodingHeader = "Rpc-Encoding"

	// TTLMSHeader is the HTTP header used to indicate the ttl in ms
	TTLMSHeader = "Context-TTL-MS"

	// ProcedureHeader is the HTTP header used to indicate the procedure
	ProcedureHeader = "Rpc-Procedure"

	// ServiceHeader is the HTTP header used to indicate the service
	ServiceHeader = "Rpc-Service"

	// ShardKeyHeader is the HTTP header used by a clustered service to
	// identify the node responsible for handling the request.
	ShardKeyHeader = "Rpc-Shard-Key"

	// RoutingKeyHeader is the HTTP header used by a relay to identify
	// the traffic group responsible for handling the request, overriding the
	// service name when available.
	RoutingKeyHeader = "Rpc-Routing-Key"

	// RoutingDelegateHeader is the HTTP header used by a relay to identify a
	// service that can proxy for the destined service and perform
	// application-specific routing.
	RoutingDelegateHeader = "Rpc-Routing-Delegate"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Inbound

type Inbound struct {
	// contains filtered or unexported fields
}

Inbound represents an HTTP Inbound. It is the same as the transport Inbound except it exposes the address on which the system is listening for connections.

func (*Inbound) Addr

func (i *Inbound) Addr() net.Addr

Addr returns the address on which the server is listening. Returns nil if Start has not been called yet.

func (*Inbound) SetRegistry

func (i *Inbound) SetRegistry(registry transport.Registry)

SetRegistry configures a registry to handle incoming requests. This satisfies the transport.Inbound interface, and would be called by a dispatcher when it starts.

func (*Inbound) Start added in v1.0.0

func (i *Inbound) Start() error

Start starts the inbound with a given service detail, opening a listening socket.

func (*Inbound) Stop added in v1.0.0

func (i *Inbound) Stop() error

Stop the inbound, closing the listening socket.

func (*Inbound) Tracer added in v1.0.0

func (i *Inbound) Tracer(tracer opentracing.Tracer) *Inbound

Tracer configures a tracer on this inbound.

func (*Inbound) Transports added in v1.0.0

func (i *Inbound) Transports() []transport.Transport

Transports returns the inbound's HTTP transport.

type InboundOption

type InboundOption func(*Inbound)

InboundOption can be added as a variadic argument to the NewInbound constructor.

func Mux

func Mux(pattern string, mux *http.ServeMux) InboundOption

Mux specifies the ServeMux that the HTTP server should use and the pattern under which the YARPC endpoint should be registered.

type Outbound added in v0.4.0

type Outbound struct {
	// contains filtered or unexported fields
}

Outbound is an HTTP UnaryOutbound and OnewayOutbound

func NewOutbound

func NewOutbound(chooser peer.Chooser, opts ...OutboundOption) *Outbound

NewOutbound builds a new HTTP outbound built around a peer.Chooser for getting potential downstream hosts. Chooser.Choose MUST return *hostport.Peer objects. Chooser.Start MUST be called before Outbound.Start

func (*Outbound) Call added in v0.4.0

func (o *Outbound) Call(ctx context.Context, treq *transport.Request) (*transport.Response, error)

Call makes a HTTP request

func (*Outbound) CallOneway added in v0.4.0

func (o *Outbound) CallOneway(ctx context.Context, treq *transport.Request) (transport.Ack, error)

CallOneway makes a oneway request

func (*Outbound) Start added in v0.4.0

func (o *Outbound) Start() error

Start the HTTP outbound

func (*Outbound) Stop added in v0.4.0

func (o *Outbound) Stop() error

Stop the HTTP outbound

func (*Outbound) Transports added in v1.0.0

func (o *Outbound) Transports() []transport.Transport

Transports returns the outbound's HTTP transport.

type OutboundOption

type OutboundOption func(*Outbound)

OutboundOption is suitable as an argument to NewOutbound

func URLTemplate added in v1.0.0

func URLTemplate(template string) OutboundOption

URLTemplate specifies a template for URLs to this outbound. The peer (host:port) may vary from call to call. The URL template specifies the protocol and path.

type Transport added in v1.0.0

type Transport struct {
	// contains filtered or unexported fields
}

Transport keeps track of http peers and the associated client with which the peer will call into.

func NewTransport added in v1.0.0

func NewTransport(opts ...TransportOption) *Transport

NewTransport creates a new http transport for managing peers and sending requests

func (*Transport) NewInbound added in v1.0.0

func (t *Transport) NewInbound(addr string, opts ...InboundOption) *Inbound

NewInbound builds a new HTTP inbound that listens on the given address and sharing this transport.

func (*Transport) NewOutbound added in v1.0.0

func (t *Transport) NewOutbound(chooser peer.Chooser) *Outbound

NewOutbound builds a new HTTP outbound built around a peer.Chooser for getting potential downstream hosts. Chooser.Choose MUST return *hostport.Peer objects. Chooser.Start MUST be called before Outbound.Start

func (*Transport) NewSingleOutbound added in v1.0.0

func (t *Transport) NewSingleOutbound(URL string, opts ...OutboundOption) *Outbound

NewSingleOutbound creates an outbound from a single URL (a bare host:port is not sufficient). This form defers to the underlying HTTP agent's peer selection and load balancing, using DNS.

func (*Transport) ReleasePeer added in v1.0.0

func (a *Transport) ReleasePeer(pid peer.Identifier, sub peer.Subscriber) error

ReleasePeer releases a peer from the peer.Subscriber and removes that peer from the Transport if nothing is listening to it

func (*Transport) RetainPeer added in v1.0.0

func (a *Transport) RetainPeer(pid peer.Identifier, sub peer.Subscriber) (peer.Peer, error)

RetainPeer gets or creates a Peer for the specified peer.Subscriber (usually a peer.Chooser)

type TransportOption added in v1.0.0

type TransportOption func(*transportConfig)

TransportOption customizes the behavior of an HTTP transport.

func KeepAlive

func KeepAlive(t time.Duration) TransportOption

KeepAlive specifies the keep-alive period for the network connection. If zero, keep-alives are disabled.

Defaults to 30 seconds.

func Tracer added in v1.0.0

func Tracer(tracer opentracing.Tracer) TransportOption

Tracer configures a tracer for the transport and all its inbounds and outbounds.

Jump to

Keyboard shortcuts

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