Documentation
¶
Overview ¶
Package discovery provides a common interface for all providers and Match to transform source to destination URL. Run func starts event loop checking all providers and retrieving lists of rules. All lists combined into a merged one.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Provider ¶
type Provider interface {
Events(ctx context.Context) (res <-chan ProviderID)
List() (res []URLMapper, err error)
}
Provider defines sources of mappers
type ProviderID ¶
type ProviderID string
ProviderID holds provider identifier to emulate enum of them
const ( PIDocker ProviderID = "docker" PIStatic ProviderID = "static" PIFile ProviderID = "file" )
enum of all provider ids
type ProviderMock ¶
type ProviderMock struct {
// EventsFunc mocks the Events method.
EventsFunc func(ctx context.Context) <-chan ProviderID
// ListFunc mocks the List method.
ListFunc func() ([]URLMapper, 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 ProviderID {
panic("mock out the Events method")
},
ListFunc: func() ([]URLMapper, error) {
panic("mock out the List method")
},
}
// use mockedProvider in code that requires Provider
// and then make assertions.
}
func (*ProviderMock) Events ¶
func (mock *ProviderMock) Events(ctx context.Context) <-chan ProviderID
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) List ¶
func (mock *ProviderMock) List() ([]URLMapper, error)
List calls ListFunc.
func (*ProviderMock) ListCalls ¶
func (mock *ProviderMock) ListCalls() []struct { }
ListCalls gets all the calls that were made to List. Check the length with:
len(mockedProvider.ListCalls())
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service implements discovery with multiple providers and url matcher
func NewService ¶
NewService makes service with given providers