http

package
v1.0.0-rc2 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2016 License: MIT Imports: 22 Imported by: 0

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 interface {
	transport.Inbound

	// Address on which the server is listening. Returns nil if Start has not
	// been called yet.
	Addr() net.Addr
}

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 NewInbound

func NewInbound(addr string, opts ...InboundOption) Inbound

NewInbound builds a new HTTP inbound that listens on the given address.

type InboundOption

type InboundOption func(*inbound)

InboundOption is an option for an HTTP inbound.

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 NewChooserOutbound

func NewChooserOutbound(chooser peer.Chooser, urlTemplate *url.URL) *Outbound

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

func NewOutbound deprecated

func NewOutbound(urlStr string, opts ...TransportOption) *Outbound

NewOutbound builds a new HTTP outbound that sends requests to the given URL.

Deprecated: create outbounds through NewChooserOutbound instead

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(d transport.Deps) error

Start the HTTP outbound

func (*Outbound) Stop added in v0.4.0

func (o *Outbound) Stop() error

Stop the HTTP outbound

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) 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.

Jump to

Keyboard shortcuts

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