discovery

package
v0.0.0-...-d88ec87 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2024 License: Apache-2.0 Imports: 13 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 GetHTTPClient

func GetHTTPClient() *http.Client

GetHTTPClient for service discovery

Types

type Client

type Client interface {
	GetEndpoint(serviceName string) (*url.URL, error)
}

Client is an interface for a client that resolves service name to host:port pair

func NewDefaultServices

func NewDefaultServices() Client

NewDefaultServices creates an instance of Services to use for discovery, using the default cfg

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

Jump to

Keyboard shortcuts

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