Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4ce9064fbb | |||
| 75f7a75379 |
@@ -27,16 +27,20 @@ type Service struct {
|
|||||||
|
|
||||||
var ErrServiceUnavailable = fmt.Errorf("Service is unavailable")
|
var ErrServiceUnavailable = fmt.Errorf("Service is unavailable")
|
||||||
|
|
||||||
func NewService(servAddr, id, name, hostname, domain, pathPrefix string, appPort int) (*Service, error) {
|
func NewService(servAddr, id, name, useDomainOverIp, addr, domain, pathPrefix string, appPort int) (*Service, error) {
|
||||||
s := new(Service)
|
s := new(Service)
|
||||||
s.Name = name
|
s.Name = name
|
||||||
s.Address = hostname
|
s.Address = addr
|
||||||
s.appID = id
|
s.appID = id
|
||||||
s.domain = domain
|
s.domain = domain
|
||||||
s.pathPrefix = pathPrefix
|
s.pathPrefix = pathPrefix
|
||||||
s.port = appPort
|
s.port = appPort
|
||||||
s.ttl = time.Second * 10
|
s.ttl = time.Second * 10
|
||||||
|
|
||||||
|
if useDomainOverIp == "true" { // FIXME types...
|
||||||
|
s.Address = domain
|
||||||
|
}
|
||||||
|
|
||||||
client, err := consul.NewClient(newClientConfig(servAddr))
|
client, err := consul.NewClient(newClientConfig(servAddr))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -66,7 +70,7 @@ func (s *Service) GetFullAddr() string {
|
|||||||
if isTLS {
|
if isTLS {
|
||||||
proto = "https"
|
proto = "https"
|
||||||
}
|
}
|
||||||
return fmt.Sprintf("%s://%s:%d/", proto, s.domain, s.port)
|
return fmt.Sprintf("%s://%s:%d/", proto, s.Address, s.port)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Service) Register() error {
|
func (s *Service) Register() error {
|
||||||
|
|||||||
Reference in New Issue
Block a user