generated from dogmatiq/template-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
options.go
40 lines (32 loc) · 1.02 KB
/
options.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package dnssd
import "net"
// AdvertiseOption is an option that changes the behavior of how a service
// instance is advertised.
type AdvertiseOption func(*advertiseOptions)
// WithIPAddress is an AccountOption that adds DNS A and/or AAAA records that
// map the service's hostname to the given IP.
func WithIPAddress(ip net.IP) AdvertiseOption {
return func(opts *advertiseOptions) {
opts.IPAddresses = append(opts.IPAddresses, ip)
}
}
// WithServiceSubType is an announce option that advertises the service as
// providing a specific service sub-type.
//
// See https://www.rfc-editor.org/rfc/rfc6763#section-7.1
func WithServiceSubType(subType string) AdvertiseOption {
return func(opts *advertiseOptions) {
opts.ServiceSubTypes = append(opts.ServiceSubTypes, subType)
}
}
type advertiseOptions struct {
IPAddresses []net.IP
ServiceSubTypes []string
}
func resolveAdvertiseOptions(options []AdvertiseOption) advertiseOptions {
var opts advertiseOptions
for _, opt := range options {
opt(&opts)
}
return opts
}