Documentation ¶
Overview ¶
Package discovery provides the interface for matching gRPC requests to upstreams.
Index ¶
- 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) Rules(ctx context.Context) ([]*Rule, error)
- func (mock *ProviderMock) RulesCalls() []struct{ ... }
- type RequestMatcher
- type Rule
- type Service
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
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 // Rules returns the routing rules. Rules(ctx context.Context) ([]*Rule, 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 // RulesFunc mocks the Rules method. RulesFunc func(ctx context.Context) ([]*Rule, 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") }, RulesFunc: func(ctx context.Context) ([]*Rule, error) { panic("mock out the Rules 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) Rules ¶
func (mock *ProviderMock) Rules(ctx context.Context) ([]*Rule, error)
Rules calls RulesFunc.
func (*ProviderMock) RulesCalls ¶
func (mock *ProviderMock) RulesCalls() []struct { Ctx context.Context }
RulesCalls gets all the calls that were made to Rules. Check the length with:
len(mockedProvider.RulesCalls())
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 }
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. |