Documentation ¶
Overview ¶
Package discovery provides the interface for matching gRPC requests to upstreams.
Index ¶
- type ClientConn
- type Forward
- type Matches
- type Mock
- type Provider
- type ProviderMock
- func (mock *ProviderMock) Events(ctx context.Context) <-chan string
- func (mock *ProviderMock) EventsCalls() []struct{ ... }
- func (mock *ProviderMock) Name() string
- func (mock *ProviderMock) NameCalls() []struct{}
- func (mock *ProviderMock) State(ctx context.Context) (*State, error)
- func (mock *ProviderMock) StateCalls() []struct{ ... }
- type RequestMatcher
- type Rule
- type Service
- type State
- type Upstream
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ClientConn ¶ added in v0.3.0
type ClientConn struct { ConnName string ServeReflection bool *grpc.ClientConn }
ClientConn is a named closable client connection.
func (ClientConn) Name ¶ added in v0.3.0
func (n ClientConn) Name() string
Name returns the name of the connection.
func (ClientConn) Reflection ¶ added in v0.3.0
func (n ClientConn) Reflection() bool
Reflection returns true if the connection serves reflection.
type Forward ¶ added in v0.3.0
Forward specifies the upstream to forward the request and the parameters to invoke the upstream.
type Matches ¶
type Matches []*Rule
Matches is a set of matches.
func (Matches) MatchMessage ¶
MatchMessage matches the given gRPC request to a rule. It returns the first match and true if the request is matched.
func (Matches) NeedsDeeperMatch ¶
NeedsDeeperMatch returns true if first RECV message is needed to match the request.
type Mock ¶
type Mock struct { Header metadata.MD Trailer metadata.MD Body proto.Message Status *status.Status }
Mock contains the details of how the handler should reply to the downstream.
type Provider ¶
type Provider interface { // Name returns the name of the provider. Name() string // Events returns the events of the routing rules. // It returns the name of the provider to update the routing rules. Events(ctx context.Context) <-chan string // State returns the current state of the provider. State(ctx context.Context) (*State, error) }
Provider provides routing rules for the Service.
type ProviderMock ¶
type ProviderMock struct { // EventsFunc mocks the Events method. EventsFunc func(ctx context.Context) <-chan string // NameFunc mocks the Name method. NameFunc func() string // StateFunc mocks the State method. StateFunc func(ctx context.Context) (*State, error) // contains filtered or unexported fields }
ProviderMock is a mock implementation of Provider.
func TestSomethingThatUsesProvider(t *testing.T) { // make and configure a mocked Provider mockedProvider := &ProviderMock{ EventsFunc: func(ctx context.Context) <-chan string { panic("mock out the Events method") }, NameFunc: func() string { panic("mock out the Name method") }, StateFunc: func(ctx context.Context) (*State, error) { panic("mock out the State method") }, } // use mockedProvider in code that requires Provider // and then make assertions. }
func (*ProviderMock) Events ¶
func (mock *ProviderMock) Events(ctx context.Context) <-chan string
Events calls EventsFunc.
func (*ProviderMock) EventsCalls ¶
func (mock *ProviderMock) EventsCalls() []struct { Ctx context.Context }
EventsCalls gets all the calls that were made to Events. Check the length with:
len(mockedProvider.EventsCalls())
func (*ProviderMock) NameCalls ¶
func (mock *ProviderMock) NameCalls() []struct { }
NameCalls gets all the calls that were made to Name. Check the length with:
len(mockedProvider.NameCalls())
func (*ProviderMock) State ¶ added in v0.3.0
func (mock *ProviderMock) State(ctx context.Context) (*State, error)
State calls StateFunc.
func (*ProviderMock) StateCalls ¶ added in v0.3.0
func (mock *ProviderMock) StateCalls() []struct { Ctx context.Context }
StateCalls gets all the calls that were made to State. Check the length with:
len(mockedProvider.StateCalls())
type RequestMatcher ¶
type RequestMatcher struct { // URI defines the fully-qualified method name, e.g. // "/package.Service/Method". URI *regexp.Regexp // IncomingMetadata contains the metadata of the incoming request. IncomingMetadata metadata.MD // Message contains the expected first RECV message of the request. Message proto.Message }
RequestMatcher defines parameters to match the request to the rule.
type Rule ¶
type Rule struct { // Name is an optional name of the rule. Name string // Match defines the request matcher. // Any request that matches the matcher will be handled by the rule. Match RequestMatcher // Mock defines the details of how the handler should reply to the downstream. Mock *Mock // Forward specifies the upstream to forward the request. Forward *Forward }
Rule is a routing rule for the Service.
type Service ¶
type Service struct { Providers []Provider // contains filtered or unexported fields }
Service provides routing rules for the Service.
func (*Service) MatchMetadata ¶
MatchMetadata matches the given gRPC request to an upstream connection.
Directories ¶
Path | Synopsis |
---|---|
Package fileprovider provides a file-based discovery provider.
|
Package fileprovider provides a file-based discovery provider. |