consul

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2023 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var HostAddress string

Functions

func AddDependency

func AddDependency(serviceName string)

func FilterServiceEntries

func FilterServiceEntries(cs []*api.ServiceEntry, tagConst string) []*api.ServiceEntry

func IsInsideDockerContainer

func IsInsideDockerContainer() bool

func ListDependencies

func ListDependencies() []string

func ReplaceHostAddress

func ReplaceHostAddress(addrs []string) []string

func SetDependency

func SetDependency(serviceName string)

Types

type ConsulClient

type ConsulClient struct {
	*api.Client
	// contains filtered or unexported fields
}

func GetConsulClient

func GetConsulClient() *ConsulClient

func (*ConsulClient) Close

func (cc *ConsulClient) Close()

func (*ConsulClient) GetAddress

func (cc *ConsulClient) GetAddress(serviceName string) string

func (*ConsulClient) GetAddressWithConstraint

func (cc *ConsulClient) GetAddressWithConstraint(serviceName, tagConst string) []string

GetAddressWithConstraint select the latest version of service meeting the given constraint. If no version is attached to the services, and constraint is empty, all of them will be returns. Otherwise, only the verioned services will be considered. Among all the veresioned services, we will return the service address with largest veresion under given constraint.

func (*ConsulClient) GetAddressWithTag

func (cc *ConsulClient) GetAddressWithTag(serviceName, tag string) string

func (*ConsulClient) GetAllAddress

func (cc *ConsulClient) GetAllAddress(serviceName, tag string) []string

GetAllAddress returns all the service address with specific tag. [Deprecated] Use `GetAddressWithConstraint` instead, which meeting the new CM microservice standard.

func (*ConsulClient) GetDatacenter

func (cc *ConsulClient) GetDatacenter() string

func (*ConsulClient) GetMappedAddress

func (cc *ConsulClient) GetMappedAddress(addr string) (string, error)

func (*ConsulClient) GetRegisteredService

func (cc *ConsulClient) GetRegisteredService() []RegisteredService

func (*ConsulClient) Register

func (cc *ConsulClient) Register(name string, port int) error

func (*ConsulClient) RegisterWithTags

func (cc *ConsulClient) RegisterWithTags(name string, port int, tags []string) error

func (*ConsulClient) ResolveAddresses

func (cc *ConsulClient) ResolveAddresses(target string) []string

ResolveAddresses resolves address in the following formats: * ip * serviceName * domain * ip:port * serviceName:tag * domain:port

type DependencyService

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

DependencyService is the store to store the dependency relationship.

func (*DependencyService) AddDependency

func (ds *DependencyService) AddDependency(serviceName string)

AddDependency records the downstream service name.

func (*DependencyService) GetDependency

func (ds *DependencyService) GetDependency() map[string]bool

GetDependency returns a copy of dependency list. Deprecated, please use ListDependencies()

func (*DependencyService) ListDependencies

func (ds *DependencyService) ListDependencies() []string

ListDependencies returns the dependencies in a slice list.

func (*DependencyService) SetDependency

func (ds *DependencyService) SetDependency(serviceName string)

SetDependency registers the service. Deprecated, please use AddDependency()

type RegisteredService

type RegisteredService struct {
	ServiceID string
	CheckID   string
}

Jump to

Keyboard shortcuts

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