Documentation ¶
Index ¶
- Variables
- func AddDependency(serviceName string)
- func FilterServiceEntries(cs []*api.ServiceEntry, tagConst string) []*api.ServiceEntry
- func IsInsideDockerContainer() bool
- func ListDependencies() []string
- func ReplaceHostAddress(addrs []string) []string
- func SetDependency(serviceName string)
- type ConsulClient
- func (cc *ConsulClient) Close()
- func (cc *ConsulClient) GetAddress(serviceName string) string
- func (cc *ConsulClient) GetAddressWithConstraint(serviceName, tagConst string) []string
- func (cc *ConsulClient) GetAddressWithTag(serviceName, tag string) string
- func (cc *ConsulClient) GetAllAddress(serviceName, tag string) []string
- func (cc *ConsulClient) GetDatacenter() string
- func (cc *ConsulClient) GetMappedAddress(addr string) (string, error)
- func (cc *ConsulClient) GetRegisteredService() []RegisteredService
- func (cc *ConsulClient) Register(name string, port int) error
- func (cc *ConsulClient) RegisterWithTags(name string, port int, tags []string) error
- func (cc *ConsulClient) ResolveAddresses(target string) []string
- type DependencyService
- type RegisteredService
Constants ¶
This section is empty.
Variables ¶
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 SetDependency ¶
func SetDependency(serviceName string)
Types ¶
type ConsulClient ¶
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) 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()