Skip to content

Commit 0a73850

Browse files
committed
Allow Registering specifc ServiceEntries
This patch allows the library user more control in the registry flow by giving them the chance to pass the ServiceEntries they crafted.
1 parent c2d1b41 commit 0a73850

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

server.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,24 @@ const (
2323
multicastRepetitions = 2
2424
)
2525

26+
// Register a service from a given ServiceEntry.
27+
func RegisterSvcEntry(entry *ServiceEntry, ifaces []net.Interface) (*Server, error) {
28+
if entry.AddrIPv4 == nil && entry.AddrIPv6 == nil {
29+
return nil, fmt.Errorf("Could not determine host IP addresses")
30+
}
31+
32+
s, err := newServer(ifaces)
33+
if err != nil {
34+
return nil, err
35+
}
36+
37+
s.service = entry
38+
go s.mainloop()
39+
go s.probe()
40+
41+
return s, nil
42+
}
43+
2644
// Register a service by given arguments. This call will take the system's hostname
2745
// and lookup IP by that hostname.
2846
func Register(instance, service, domain string, port int, text []string, ifaces []net.Interface) (*Server, error) {

0 commit comments

Comments
 (0)