add consul cluster (#494)

This commit is contained in:
Jun
2023-08-19 10:40:34 +08:00
committed by GitHub
parent 8b24a20651
commit 1051201e97

View File

@@ -131,3 +131,23 @@ func (c DnsCluster) ClusterName() string {
func (c DnsCluster) HostName() string {
return c.Domain
}
type ConsulCluster struct {
ServiceName string
Datacenter string
Port int64
Host string
}
func (c ConsulCluster) ClusterName() string {
tail := "consul"
return fmt.Sprintf("outbound|%d||%s.%s.%s",
c.Port, c.ServiceName, c.Datacenter, tail)
}
func (c ConsulCluster) HostName() string {
if c.Host != "" {
return c.Host
}
return c.ServiceName
}