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
- type Inbound
- type InboundOption
- type Outbound
- func (o *Outbound) Call(ctx context.Context, treq *transport.Request) (*transport.Response, error)
- func (o *Outbound) CallOneway(ctx context.Context, treq *transport.Request) (transport.Ack, error)
- func (o *Outbound) Start() error
- func (o *Outbound) Stop() error
- func (o *Outbound) Transports() []transport.Transport
- type OutboundOption
- type Transport
- func (t *Transport) NewInbound(addr string, opts ...InboundOption) *Inbound
- func (t *Transport) NewOutbound(chooser peer.Chooser) *Outbound
- func (t *Transport) NewSingleOutbound(URL string, opts ...OutboundOption) *Outbound
- func (a *Transport) ReleasePeer(pid peer.Identifier, sub peer.Subscriber) error
- func (a *Transport) RetainPeer(pid peer.Identifier, sub peer.Subscriber) (peer.Peer, error)
- type TransportOption
Constants ¶
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 ¶
Addr returns the address on which the server is listening. Returns nil if Start has not been called yet.
func (*Inbound) SetRegistry ¶
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
Start starts the inbound with a given service detail, opening a listening socket.
func (*Inbound) Transports ¶ added in v1.0.0
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.
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) CallOneway ¶ added in v0.4.0
CallOneway makes a oneway request
func (*Outbound) Transports ¶ added in v1.0.0
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
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.