discovery

package
v0.0.0-...-e6f4ba9 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2019 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultCacheInvalidationTimeout = 10
)

DefaultCacheInvalidationTimeout for updating instances

Variables

This section is empty.

Functions

func DiscardBody

func DiscardBody(resp *http.Response) error

DiscardBody from response

func DoRequestWithDiscoveryService

func DoRequestWithDiscoveryService(httpClient *http.Client, host, path, username, password, payload string) (resp *http.Response, endpoint string, err error)

DoRequestWithDiscoveryService with hostname (username + password) and payload

func GetHTTPClient

func GetHTTPClient() *http.Client

GetHTTPClient for service discovery

Types

type ClientWrapper

type ClientWrapper struct {
	Client *api.Client
}

ClientWrapper for consul api.Client

func (*ClientWrapper) Health

func (c *ClientWrapper) Health() IHealth

Health function wrapper

type HealthWrapper

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

HealthWrapper for consul api.Health

func (*HealthWrapper) Service

func (hw *HealthWrapper) Service(service, tag string, passingOnly bool, q *api.QueryOptions) ([]*api.ServiceEntry, *api.QueryMeta, error)

Service function wrapper

type IClient

type IClient interface {
	Health() IHealth
}

IClient interface

func NewClientWrapper

func NewClientWrapper(config *api.Config, httpClient *http.Client) (IClient, error)

NewClientWrapper returns a new Consul client wrapper

type IHealth

type IHealth interface {
	Service(service, tag string, passingOnly bool, q *api.QueryOptions) ([]*api.ServiceEntry, *api.QueryMeta, error)
}

IHealth interface

type Resolver

type Resolver struct {
	LastUpdateTimestamp int64
	// contains filtered or unexported fields
}

Resolver for discovery service

func NewResolver

func NewResolver(consulClient IClient) *Resolver

NewResolver for discovery client

func (*Resolver) GetNodesFromConsul

func (r *Resolver) GetNodesFromConsul(service string) (entries []*api.ServiceEntry)

GetNodesFromConsul get service nodes form service discovery

type Services

type Services struct {
	ConsulClient IClient
	Instances    *syncmap.Map
	CacheTTL     int64
}

Services for discovery service

func NewServices

func NewServices(consulClient IClient, cacheInvalidationTimeout int64) *Services

NewServices constructor

func (*Services) GetEndpoint

func (s *Services) GetEndpoint(serviceName string) (url *url.URL, err error)

GetEndpoint by service name

func (*Services) UpdateInstances

func (s *Services) UpdateInstances(serviceName string) (resolver *Resolver)

UpdateInstances get service instances from service discovery

Jump to

Keyboard shortcuts

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