type ServiceDefinition struct {
Engine string `json:"type"`
ServiceName string `json:"service_name"`
+ Shard string `json:"shard"`
PollInterval uint `json:"poll_interval"`
}
func (hcs *httpHealthCheckService) NewPublisher(domain string, regions []string) *SDPublisher {
_, port := hcs.PublishAddress()
+ shard := hcs.serviceDef.Shard
+ if shard == "" {
+ shard = strings.Split(hcs.SocketHost, ".")[0]
+ }
publisher := &SDPublisher{
AdvertiseHost: hcs.SocketHost,
Domain: domain,
Protocol: ProtocolTCP,
Service: hcs.serviceDef.ServiceName,
- ShardName: strings.Split(hcs.SocketHost, ".")[0],
+ ShardName: shard,
Regions: regions,
}
func (lcs *ldapHealthCheckService) NewPublisher(domain string, regions []string) *SDPublisher {
_, port := lcs.PublishAddress()
+ shard := lcs.serviceDef.Shard
+ if shard == "" {
+ shard = strings.Split(lcs.SocketHost, ".")[0]
+ }
publisher := &SDPublisher{
AdvertiseHost: lcs.SocketHost,
Domain: domain,
Protocol: ProtocolTCP,
Service: lcs.serviceDef.ServiceName,
- ShardName: strings.Split(lcs.SocketHost, ".")[0],
+ ShardName: shard,
Regions: regions,
}
Domain string
Protocol Layer4Protocol
Service string
+ NodeName string
ShardName string
LocalRegion string
Regions []string
errors = append(errors, "service name was not set")
}
- if s.ShardName == "" {
- s.ShardName = hostname.Hostname()
+ if s.NodeName == "" {
+ s.NodeName = hostname.Hostname()
}
if s.LocalRegion == "" {
func (s *SDPublisher) srvRecordPath() string {
domainPathComponents := strings.Join(utils.Reverse(strings.Split(s.Domain, ".")), "/")
- return fmt.Sprintf("/sd/%s/%s/%s/_%s/%s",
+ shardName := ""
+ if s.ShardName != "" {
+ shardName = "/" + s.ShardName
+ }
+ return fmt.Sprintf("/sd/%s/%s/%s/_%s/%s%s",
"dns",
domainPathComponents,
s.Protocol.DNSComponent(),
s.Service,
- s.ShardName)
+ s.NodeName,
+ shardName)
}
func (s *SDPublisher) srvRecordJson(region string) string {
func (s *SDPublisher) aRecordPath() string {
domainPathComponents := strings.Join(utils.Reverse(strings.Split(s.Domain, ".")), "/")
- return fmt.Sprintf("/sd/%s/%s/%s/%s/a",
+ shardName := ""
+ if s.ShardName != "" {
+ shardName = "/" + s.ShardName
+ }
+ return fmt.Sprintf("/sd/%s/%s/%s/%s%s/a",
"dns",
domainPathComponents,
s.Service,
- s.ShardName)
+ s.NodeName,
+ shardName)
}
func (s *SDPublisher) aRecordJson() string {
func (s *SDPublisher) aaaaRecordPath() string {
domainPathComponents := strings.Join(utils.Reverse(strings.Split(s.Domain, ".")), "/")
- return fmt.Sprintf("/sd/%s/%s/%s/%s/aaaa",
+ shardName := ""
+ if s.ShardName != "" {
+ shardName = "/" + s.ShardName
+ }
+ return fmt.Sprintf("/sd/%s/%s/%s/%s%s/aaaa",
"dns",
domainPathComponents,
s.Service,
- s.ShardName)
+ s.NodeName,
+ shardName)
}
func (s *SDPublisher) aaaaRecordJson() string {
IP6 string
Protocol Layer4Protocol
Service string
+ Node string
Shard string
key string
if len(components) == 3 {
sa.Protocol, _ = Layer4ProtocolFromString(components[0])
sa.Service = components[1][1:]
+ sa.Node = components[2]
sa.Shard = components[2]
+ } else if len(components) == 4 {
+ sa.Protocol, _ = Layer4ProtocolFromString(components[0])
+ sa.Service = components[1][1:]
+ sa.Node = components[2]
+ sa.Shard = components[3]
}
sas = append(sas, sa)
}