consulcatalog

package
v1.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 6, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConsulCatalog

type ConsulCatalog struct {
	// contains filtered or unexported fields
}

ConsulCatalog provider periodically gets consul services with tags, started with 'reproxy.' It stores service list IDs in the internal storage. If service list was changed, it send signal to the core The provider maps services with rules, described in the docker provider documentation

reproxy.route sets source route, and reproxy.dest sets the destination. Optional reproxy.server enforces match by server name (hostname) and reproxy.ping sets the health check url

func New

func New(client ConsulClient, checkInterval time.Duration) *ConsulCatalog

New creates new ConsulCatalog instance

func (*ConsulCatalog) Events

func (cc *ConsulCatalog) Events(ctx context.Context) (res <-chan discovery.ProviderID)

Events gets eventsCh, which emit services list update events

func (*ConsulCatalog) List

func (cc *ConsulCatalog) List() ([]discovery.URLMapper, error)

List all containers and make url mappers If AutoAPI enabled all each container and set all params, if not - allow only container with reproxy.* tags

type ConsulClient

type ConsulClient interface {
	Get() ([]consulService, error)
}

ConsulClient defines interface getting consul services

func NewClient

func NewClient(address string, httpClient HTTPClient) ConsulClient

NewClient creates new Consul consulClient

type ConsulClientMock

type ConsulClientMock struct {
	// GetFunc mocks the Get method.
	GetFunc func() ([]consulService, error)
	// contains filtered or unexported fields
}

ConsulClientMock is a mock implementation of ConsulClient.

func TestSomethingThatUsesConsulClient(t *testing.T) {

	// make and configure a mocked ConsulClient
	mockedConsulClient := &ConsulClientMock{
		GetFunc: func() ([]consulService, error) {
			panic("mock out the Get method")
		},
	}

	// use mockedConsulClient in code that requires ConsulClient
	// and then make assertions.

}

func (*ConsulClientMock) Get

func (mock *ConsulClientMock) Get() ([]consulService, error)

Get calls GetFunc.

func (*ConsulClientMock) GetCalls

func (mock *ConsulClientMock) GetCalls() []struct {
}

GetCalls gets all the calls that were made to Get. Check the length with:

len(mockedConsulClient.GetCalls())

type HTTPClient

type HTTPClient interface {
	Do(r *http.Request) (*http.Response, error)
}

HTTPClient represents interface for http client

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL