Skip to content

Commit

Permalink
Allow Registering specifc ServiceEntries
Browse files Browse the repository at this point in the history
This patch allows the library user more control in the registry flow by
giving them the chance to pass the ServiceEntries they crafted.
  • Loading branch information
celebdor committed Mar 13, 2019
1 parent c2d1b41 commit ad6f6e1
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,23 @@ const (
multicastRepetitions = 2
)

func RegisterSvcEntry(entry *ServiceEntry, ifaces []net.Interface) (*Server, error) {
if entry.AddrIPv4 == nil && entry.AddrIPv6 == nil {
return nil, fmt.Errorf("Could not determine host IP addresses")
}

s, err := newServer(ifaces)
if err != nil {
return nil, err
}

s.service = entry
go s.mainloop()
go s.probe()

return s, nil
}

// Register a service by given arguments. This call will take the system's hostname
// and lookup IP by that hostname.
func Register(instance, service, domain string, port int, text []string, ifaces []net.Interface) (*Server, error) {
Expand Down

0 comments on commit ad6f6e1

Please sign in to comment.