Documentation ¶
Index ¶
Constants ¶
const (
// OutboundPublicClient is the name of configured public client outbound
OutboundPublicClient = "public-client"
)
Variables ¶
This section is empty.
Functions ¶
func IsGRPCOutbound ¶ added in v0.24.0
func IsGRPCOutbound(config transport.ClientConfig) bool
Types ¶
type Factory ¶ added in v0.24.0
type Factory struct {
// contains filtered or unexported fields
}
Factory is an implementation of common.RPCFactory interface
func NewFactory ¶ added in v0.24.0
NewFactory builds a new rpc.Factory
func (*Factory) GetChannel ¶ added in v0.24.0
GetChannel returns Tchannel Channel used by Ringpop
func (*Factory) GetDispatcher ¶ added in v0.24.0
func (d *Factory) GetDispatcher() *yarpc.Dispatcher
GetDispatcher return a cached dispatcher
func (*Factory) GetMaxMessageSize ¶ added in v0.24.0
type HeaderForwardingMiddleware ¶ added in v0.24.0
type HeaderForwardingMiddleware struct { // Rules are applied in order to add or remove headers by regex. // // There are no default rules, so by default no headers are copied. // To include headers by default, Add with a permissive regex and then remove specific ones. Rules []config.HeaderRule }
HeaderForwardingMiddleware forwards headers from current inbound RPC call that is being handled to new outbound calls being made. As this does NOT differentiate between transports or purposes, it generally assumes we are not acting as a true proxy, so things like content lengths and encodings should not be forwarded - they will be provided by the outbound RPC library as needed.
Duplicated headers retain the first value only, matching how browsers and Go (afaict) generally behave.
This uses overly-simplified rules for choosing which headers are forwarded and which are not, intended to be lightly configurable. For a more in-depth logic review if it becomes needed, check:
- How Go's ReverseProxy deals with headers, e.g. per-protocol and a list of exclusions: https://cs.opensource.google/go/go/+/refs/tags/go1.20.1:src/net/http/httputil/reverseproxy.go;l=332
- HTTP's spec for headers, namely how duplicates and Connection work: https://www.rfc-editor.org/rfc/rfc9110.html#name-header-fields
- Many browsers prefer first-value-wins for unexpected duplicates: https://bugzilla.mozilla.org/show_bug.cgi?id=376756
- But there are MANY map-like implementations that choose last-value wins, and this mismatch is a source of frequent security problems.
- YARPC's `With` only retains the last call's value: https://github.com/yarpc/yarpc-go/blob/8ccd79a2ca696150213faac1d35011c5be52e5fb/api/transport/header.go#L69-L77
- Go's MIMEHeader's Get (used by YARPC) only returns the first value, and does not join duplicates: https://pkg.go.dev/net/textproto#MIMEHeader.Get
There is likely no correct choice, as it depends on the recipients' behavior. If we need to support more complex logic, it's likely worth jumping to a fully-controllable thing. Middle-grounds will probably just need to be changed again later.
type InboundMetricsMiddleware ¶ added in v0.24.0
type InboundMetricsMiddleware struct{}
InboundMetricsMiddleware tags context with additional metric tags from incoming request.
func (*InboundMetricsMiddleware) Handle ¶ added in v0.24.0
func (m *InboundMetricsMiddleware) Handle(ctx context.Context, req *transport.Request, resw transport.ResponseWriter, h transport.UnaryHandler) error
type OutboundsBuilder ¶ added in v0.24.0
type OutboundsBuilder interface {
Build(*grpc.Transport, *tchannel.Transport) (yarpc.Outbounds, error)
}
OutboundsBuilder allows defining outbounds for the dispatcher
func CombineOutbounds ¶ added in v0.24.0
func CombineOutbounds(builders ...OutboundsBuilder) OutboundsBuilder
CombineOutbounds takes multiple outbound builders and combines them
func NewCrossDCOutbounds ¶ added in v0.24.0
func NewCrossDCOutbounds(clusterGroup map[string]config.ClusterInformation, pcf PeerChooserFactory) OutboundsBuilder
func NewDirectOutbound ¶ added in v0.24.0
func NewDirectOutbound(serviceName string, grpcEnabled bool, tlsConfig *tls.Config) OutboundsBuilder
type Params ¶ added in v0.24.0
type Params struct { ServiceName string TChannelAddress string GRPCAddress string GRPCMaxMsgSize int InboundTLS *tls.Config OutboundTLS map[string]*tls.Config InboundMiddleware yarpc.InboundMiddleware OutboundMiddleware yarpc.OutboundMiddleware OutboundsBuilder OutboundsBuilder }
Params allows to configure rpc.Factory
func NewParams ¶ added in v0.24.0
func NewParams(serviceName string, config *config.Config, dc *dynamicconfig.Collection) (Params, error)
NewParams creates parameters for rpc.Factory from the given config
type PeerChooserFactory ¶ added in v0.24.0
type PeerChooserFactory interface {
CreatePeerChooser(transport peer.Transport, address string) (peer.Chooser, error)
}
func NewDNSPeerChooserFactory ¶ added in v0.24.0
func NewDNSPeerChooserFactory(interval time.Duration, logger log.Logger) PeerChooserFactory
type ResponseInfo ¶
type ResponseInfo struct {
Size int
}
ResponseInfo structure is filled with data after the RPC call. It can be obtained with rpc.ContextWithResponseInfo function.
func ContextWithResponseInfo ¶
func ContextWithResponseInfo(parent context.Context) (context.Context, *ResponseInfo)
ContextWithResponseInfo will create a child context that has ResponseInfo set as value. This value will get filled after the call is made and can be used later to retrieve some info of interest.
type ResponseInfoMiddleware ¶
type ResponseInfoMiddleware struct{}
ResponseInfoMiddleware populates context with ResponseInfo structure which contains info about response that was received. In particular, it counts the size of the response in bytes. Such information can be useful down the line, where payload are deserialized and no longer have their size.