Documentation ¶
Overview ¶
Package rpc is a generated GoMock package.
Package rpc is a generated GoMock package.
Index ¶
- Constants
- func IsGRPCOutbound(config transport.ClientConfig) bool
- func ListenIP() (net.IP, error)
- type ClientPartitionConfigMiddleware
- type Factory
- type FactoryImpl
- type ForwardPartitionConfigMiddleware
- type HeaderForwardingMiddleware
- type InboundMetricsMiddleware
- type MockFactory
- type MockFactoryMockRecorder
- func (mr *MockFactoryMockRecorder) GetDispatcher() *gomock.Call
- func (mr *MockFactoryMockRecorder) GetMaxMessageSize() *gomock.Call
- func (mr *MockFactoryMockRecorder) GetTChannel() *gomock.Call
- func (mr *MockFactoryMockRecorder) Start(arg0 interface{}) *gomock.Call
- func (mr *MockFactoryMockRecorder) Stop() *gomock.Call
- type MockOutboundsBuilder
- type MockOutboundsBuilderMockRecorder
- type MockPeerLister
- func (m *MockPeerLister) EXPECT() *MockPeerListerMockRecorder
- func (m *MockPeerLister) Members(service string) ([]membership.HostInfo, error)
- func (m *MockPeerLister) Subscribe(service, name string, notifyChannel chan<- *membership.ChangedEvent) error
- func (m *MockPeerLister) Unsubscribe(service, name string) error
- type MockPeerListerMockRecorder
- type Outbounds
- type OutboundsBuilder
- type Params
- type PeerChooser
- type PeerChooserFactory
- type PeerChooserOptions
- type PeerLister
- type PinotComparatorMiddleware
- type ResponseInfo
- type ResponseInfoMiddleware
Constants ¶
const ComparatorYarpcKey = "cadence-visibility-override"
ComparatorYarpcKey is the const for yarpc key
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 ClientPartitionConfigMiddleware ¶ added in v1.2.1
type ClientPartitionConfigMiddleware struct{}
ClientPartitionConfigMiddleware stores the partition config and isolation group of the request into the context It reads a header from client request and uses it as the isolation group
func (*ClientPartitionConfigMiddleware) Handle ¶ added in v1.2.1
func (m *ClientPartitionConfigMiddleware) Handle(ctx context.Context, req *transport.Request, resw transport.ResponseWriter, h transport.UnaryHandler) error
type Factory ¶ added in v0.24.0
type Factory interface { GetDispatcher() *yarpc.Dispatcher GetMaxMessageSize() int Start(PeerLister) error GetTChannel() tchannel.Channel Stop() error }
Factory Creates a dispatcher that knows how to transport requests.
type FactoryImpl ¶ added in v1.2.14
type FactoryImpl struct {
// contains filtered or unexported fields
}
Factory is an implementation of rpc.Factory interface
func NewFactory ¶ added in v0.24.0
func NewFactory(logger log.Logger, p Params) *FactoryImpl
NewFactory builds a new rpc.Factory
func (*FactoryImpl) GetDispatcher ¶ added in v1.2.14
func (d *FactoryImpl) GetDispatcher() *yarpc.Dispatcher
GetDispatcher return a cached dispatcher
func (*FactoryImpl) GetMaxMessageSize ¶ added in v1.2.14
func (d *FactoryImpl) GetMaxMessageSize() int
func (*FactoryImpl) GetTChannel ¶ added in v1.2.14
func (d *FactoryImpl) GetTChannel() tchannel.Channel
GetChannel returns Tchannel Channel used by Ringpop
func (*FactoryImpl) Start ¶ added in v1.2.14
func (d *FactoryImpl) Start(peerLister PeerLister) error
func (*FactoryImpl) Stop ¶ added in v1.2.14
func (d *FactoryImpl) Stop() error
type ForwardPartitionConfigMiddleware ¶ added in v1.2.1
type ForwardPartitionConfigMiddleware struct{}
ForwardPartitionConfigMiddleware forwards the partition config to remote cluster The middleware should always be applied after any other middleware that inject partition config into the context so that it can overwrites the partition config into the context The purpose of this middleware is to make sure the partition config doesn't change when a request is forwarded from passive cluster to the active cluster
func (*ForwardPartitionConfigMiddleware) Call ¶ added in v1.2.1
func (m *ForwardPartitionConfigMiddleware) Call(ctx context.Context, request *transport.Request, out transport.UnaryOutbound) (*transport.Response, error)
func (*ForwardPartitionConfigMiddleware) Handle ¶ added in v1.2.1
func (m *ForwardPartitionConfigMiddleware) Handle(ctx context.Context, req *transport.Request, resw transport.ResponseWriter, h transport.UnaryHandler) error
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 MockFactory ¶ added in v1.2.14
type MockFactory struct {
// contains filtered or unexported fields
}
MockFactory is a mock of Factory interface.
func NewMockFactory ¶ added in v1.2.14
func NewMockFactory(ctrl *gomock.Controller) *MockFactory
NewMockFactory creates a new mock instance.
func (*MockFactory) EXPECT ¶ added in v1.2.14
func (m *MockFactory) EXPECT() *MockFactoryMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockFactory) GetDispatcher ¶ added in v1.2.14
func (m *MockFactory) GetDispatcher() *yarpc.Dispatcher
GetDispatcher mocks base method.
func (*MockFactory) GetMaxMessageSize ¶ added in v1.2.14
func (m *MockFactory) GetMaxMessageSize() int
GetMaxMessageSize mocks base method.
func (*MockFactory) GetTChannel ¶ added in v1.2.14
func (m *MockFactory) GetTChannel() tchannel.Channel
GetTChannel mocks base method.
func (*MockFactory) Start ¶ added in v1.2.14
func (m *MockFactory) Start(arg0 PeerLister) error
Start mocks base method.
func (*MockFactory) Stop ¶ added in v1.2.14
func (m *MockFactory) Stop() error
Stop mocks base method.
type MockFactoryMockRecorder ¶ added in v1.2.14
type MockFactoryMockRecorder struct {
// contains filtered or unexported fields
}
MockFactoryMockRecorder is the mock recorder for MockFactory.
func (*MockFactoryMockRecorder) GetDispatcher ¶ added in v1.2.14
func (mr *MockFactoryMockRecorder) GetDispatcher() *gomock.Call
GetDispatcher indicates an expected call of GetDispatcher.
func (*MockFactoryMockRecorder) GetMaxMessageSize ¶ added in v1.2.14
func (mr *MockFactoryMockRecorder) GetMaxMessageSize() *gomock.Call
GetMaxMessageSize indicates an expected call of GetMaxMessageSize.
func (*MockFactoryMockRecorder) GetTChannel ¶ added in v1.2.14
func (mr *MockFactoryMockRecorder) GetTChannel() *gomock.Call
GetTChannel indicates an expected call of GetTChannel.
func (*MockFactoryMockRecorder) Start ¶ added in v1.2.14
func (mr *MockFactoryMockRecorder) Start(arg0 interface{}) *gomock.Call
Start indicates an expected call of Start.
func (*MockFactoryMockRecorder) Stop ¶ added in v1.2.14
func (mr *MockFactoryMockRecorder) Stop() *gomock.Call
Stop indicates an expected call of Stop.
type MockOutboundsBuilder ¶ added in v1.2.14
type MockOutboundsBuilder struct {
// contains filtered or unexported fields
}
MockOutboundsBuilder is a mock of OutboundsBuilder interface.
func NewMockOutboundsBuilder ¶ added in v1.2.14
func NewMockOutboundsBuilder(ctrl *gomock.Controller) *MockOutboundsBuilder
NewMockOutboundsBuilder creates a new mock instance.
func (*MockOutboundsBuilder) Build ¶ added in v1.2.14
func (m *MockOutboundsBuilder) Build(arg0 *grpc.Transport, arg1 *tchannel.Transport) (*Outbounds, error)
Build mocks base method.
func (*MockOutboundsBuilder) EXPECT ¶ added in v1.2.14
func (m *MockOutboundsBuilder) EXPECT() *MockOutboundsBuilderMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
type MockOutboundsBuilderMockRecorder ¶ added in v1.2.14
type MockOutboundsBuilderMockRecorder struct {
// contains filtered or unexported fields
}
MockOutboundsBuilderMockRecorder is the mock recorder for MockOutboundsBuilder.
func (*MockOutboundsBuilderMockRecorder) Build ¶ added in v1.2.14
func (mr *MockOutboundsBuilderMockRecorder) Build(arg0, arg1 interface{}) *gomock.Call
Build indicates an expected call of Build.
type MockPeerLister ¶ added in v1.2.14
type MockPeerLister struct {
// contains filtered or unexported fields
}
MockPeerLister is a mock of PeerLister interface.
func NewMockPeerLister ¶ added in v1.2.14
func NewMockPeerLister(ctrl *gomock.Controller) *MockPeerLister
NewMockPeerLister creates a new mock instance.
func (*MockPeerLister) EXPECT ¶ added in v1.2.14
func (m *MockPeerLister) EXPECT() *MockPeerListerMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockPeerLister) Members ¶ added in v1.2.14
func (m *MockPeerLister) Members(service string) ([]membership.HostInfo, error)
Members mocks base method.
func (*MockPeerLister) Subscribe ¶ added in v1.2.14
func (m *MockPeerLister) Subscribe(service, name string, notifyChannel chan<- *membership.ChangedEvent) error
Subscribe mocks base method.
func (*MockPeerLister) Unsubscribe ¶ added in v1.2.14
func (m *MockPeerLister) Unsubscribe(service, name string) error
Unsubscribe mocks base method.
type MockPeerListerMockRecorder ¶ added in v1.2.14
type MockPeerListerMockRecorder struct {
// contains filtered or unexported fields
}
MockPeerListerMockRecorder is the mock recorder for MockPeerLister.
func (*MockPeerListerMockRecorder) Members ¶ added in v1.2.14
func (mr *MockPeerListerMockRecorder) Members(service interface{}) *gomock.Call
Members indicates an expected call of Members.
func (*MockPeerListerMockRecorder) Subscribe ¶ added in v1.2.14
func (mr *MockPeerListerMockRecorder) Subscribe(service, name, notifyChannel interface{}) *gomock.Call
Subscribe indicates an expected call of Subscribe.
func (*MockPeerListerMockRecorder) Unsubscribe ¶ added in v1.2.14
func (mr *MockPeerListerMockRecorder) Unsubscribe(service, name interface{}) *gomock.Call
Unsubscribe indicates an expected call of Unsubscribe.
type Outbounds ¶ added in v1.2.14
func (*Outbounds) UpdatePeers ¶ added in v1.2.14
func (o *Outbounds) UpdatePeers(peers []membership.HostInfo)
type OutboundsBuilder ¶ added in v0.24.0
type OutboundsBuilder interface { // Build creates yarpc outbounds given transport instances for either gRPC and TChannel based on the configuration Build(*grpc.Transport, *tchannel.Transport) (*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 NewDirectOutboundBuilder ¶ added in v1.2.14
func NewDirectOutboundBuilder(serviceName string, grpcEnabled bool, tlsConfig *tls.Config, pcf PeerChooserFactory, enableConnRetainMode dynamicconfig.BoolPropertyFn) OutboundsBuilder
type Params ¶ added in v0.24.0
type Params struct { ServiceName string TChannelAddress string GRPCAddress string GRPCMaxMsgSize int HTTP *httpParams InboundTLS *tls.Config OutboundTLS map[string]*tls.Config InboundMiddleware yarpc.InboundMiddleware OutboundMiddleware yarpc.OutboundMiddleware OutboundsBuilder OutboundsBuilder }
Params allows to configure rpc.Factory
type PeerChooser ¶ added in v1.2.14
type PeerChooser interface { peer.Chooser // UpdatePeers updates the list of peers if needed. UpdatePeers([]membership.HostInfo) }
type PeerChooserFactory ¶ added in v0.24.0
type PeerChooserFactory interface {
CreatePeerChooser(transport peer.Transport, opts PeerChooserOptions) (PeerChooser, error)
}
func NewDNSPeerChooserFactory ¶ added in v0.24.0
func NewDNSPeerChooserFactory(interval time.Duration, logger log.Logger) PeerChooserFactory
func NewDirectPeerChooserFactory ¶ added in v1.2.14
func NewDirectPeerChooserFactory(serviceName string, logger log.Logger) PeerChooserFactory
type PeerChooserOptions ¶ added in v1.2.14
type PeerChooserOptions struct { // Address is the target dns address. Used by dns peer chooser. Address string // ServiceName is the name of service. Used by direct peer chooser. ServiceName string // EnableConnectionRetainingDirectChooser is used by direct peer chooser. // If false, yarpc's own default direct peer chooser will be used which doesn't retain connections. // If true, cadence's own direct peer chooser will be used which retains connections. EnableConnectionRetainingDirectChooser dynamicconfig.BoolPropertyFn }
type PeerLister ¶ added in v1.2.14
type PeerLister interface { Subscribe(service, name string, notifyChannel chan<- *membership.ChangedEvent) error Unsubscribe(service, name string) error Members(service string) ([]membership.HostInfo, error) }
type PinotComparatorMiddleware ¶ added in v1.2.8
type PinotComparatorMiddleware struct{}
PinotComparatorMiddleware checks the header of a grpc request, and then override the context accordingly note: for Pinot Migration only (Jan. 2024)
func (*PinotComparatorMiddleware) Handle ¶ added in v1.2.8
func (m *PinotComparatorMiddleware) Handle(ctx context.Context, req *transport.Request, resw transport.ResponseWriter, h transport.UnaryHandler) error
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.