Skip to content

Commit

Permalink
Rename ServiceInstance.Instance to Name.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmalloc committed Mar 17, 2023
1 parent 89180c2 commit 9a7c96a
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 19 deletions.
7 changes: 4 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ The format is based on [Keep a Changelog], and this project adheres to

### Changed

- **[BC]** Renamed `dnssd.ServiceInstance.Instance` to `Name`
- **[BC]** `dnssd.Attributes` now presents an immutable interface
- Renamed `dnssd.Attributes.Set()` to `WithPair()`
- Renamed `dnssd.Attributes.SetFlag()` to `WithFlag()`
- Renamed `dnssd.Attributes.Delete()` to `Without()`
- **[BC]** Renamed `dnssd.Attributes.Set()` to `WithPair()`
- **[BC]** Renamed `dnssd.Attributes.SetFlag()` to `WithFlag()`
- **[BC]** Renamed `dnssd.Attributes.Delete()` to `Without()`

## [0.1.3] - 2023-03-17

Expand Down
4 changes: 2 additions & 2 deletions dnssd/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import (
// ServiceInstance encapsulates information about a single DNS-SD service
// instance.
type ServiceInstance struct {
// Instance is the service instance's unqualified name.
// Name is the service instance's unqualified name.
//
// For example, "Boardroom Printer".
//
// This is the "<instance>" portion of the "service instance name", as
// described in https://www.rfc-editor.org/rfc/rfc6763#section-4.1.
Instance string
Name string

// ServiceType is the type of service that the instance provides.
//
Expand Down
8 changes: 4 additions & 4 deletions dnssd/records.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func NewPTRRecord(i ServiceInstance) *dns.PTR {
Class: dns.ClassINET,
Ttl: ttlInSeconds(i.TTL),
},
Ptr: ServiceInstanceName(i.Instance, i.ServiceType, i.Domain) + ".",
Ptr: ServiceInstanceName(i.Name, i.ServiceType, i.Domain) + ".",
}
}

Expand All @@ -60,7 +60,7 @@ func NewPTRRecord(i ServiceInstance) *dns.PTR {
func NewSRVRecord(i ServiceInstance) *dns.SRV {
return &dns.SRV{
Hdr: dns.RR_Header{
Name: ServiceInstanceName(i.Instance, i.ServiceType, i.Domain) + ".",
Name: ServiceInstanceName(i.Name, i.ServiceType, i.Domain) + ".",
Rrtype: dns.TypeSRV,
Class: dns.ClassINET,
Ttl: ttlInSeconds(i.TTL),
Expand All @@ -83,7 +83,7 @@ func NewSRVRecord(i ServiceInstance) *dns.SRV {
// See https://www.rfc-editor.org/rfc/rfc6763#section-6.8.
func NewTXTRecords(i ServiceInstance) []*dns.TXT {
header := dns.RR_Header{
Name: ServiceInstanceName(i.Instance, i.ServiceType, i.Domain) + ".",
Name: ServiceInstanceName(i.Name, i.ServiceType, i.Domain) + ".",
Rrtype: dns.TypeTXT,
Class: dns.ClassINET,
Ttl: ttlInSeconds(i.TTL),
Expand Down Expand Up @@ -131,7 +131,7 @@ func NewServiceSubTypePTRRecord(i ServiceInstance, subType string) *dns.PTR {
Class: dns.ClassINET,
Ttl: ttlInSeconds(i.TTL),
},
Ptr: ServiceInstanceName(i.Instance, i.ServiceType, i.Domain) + ".",
Ptr: ServiceInstanceName(i.Name, i.ServiceType, i.Domain) + ".",
}
}

Expand Down
2 changes: 1 addition & 1 deletion dnssd/records_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var _ = Context("DNS records", func() {

BeforeEach(func() {
instance = ServiceInstance{
Instance: "Boardroom Printer.",
Name: "Boardroom Printer.",
ServiceType: "_http._tcp",
Domain: "example.org",
TargetHost: "host.example.com",
Expand Down
2 changes: 1 addition & 1 deletion dnssd/unicastresolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ func (r *UnicastResolver) LookupInstance(
close(responses)

i := ServiceInstance{
Instance: instance,
Name: instance,
ServiceType: serviceType,
Domain: domain,
TTL: math.MaxInt64,
Expand Down
6 changes: 3 additions & 3 deletions dnssd/unicastresolver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ var _ = Context("UnicastResolver", func() {
ctx, cancel = context.WithTimeout(context.Background(), 3*time.Second)

instanceA = ServiceInstance{
Instance: "Instance A",
Name: "Instance A",
ServiceType: "_http._tcp",
Domain: "example.org",
TargetHost: "a.example.com",
Expand All @@ -40,7 +40,7 @@ var _ = Context("UnicastResolver", func() {
}

instanceB = ServiceInstance{
Instance: "Instance B",
Name: "Instance B",
ServiceType: "_http._tcp",
Domain: "example.org",
TargetHost: "b.example.com",
Expand All @@ -56,7 +56,7 @@ var _ = Context("UnicastResolver", func() {
}

instanceC = ServiceInstance{
Instance: "Instance C",
Name: "Instance C",
ServiceType: "_other._udp",
Domain: "example.org",
TargetHost: "c.example.com",
Expand Down
4 changes: 2 additions & 2 deletions dnssd/unicastserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ type instanceRecords struct {
// Typically, these records would be served by a separate domain name server
// that is authoratative for the internet domain name used in i.TargetHost.
func (s *UnicastServer) Advertise(i ServiceInstance, options ...AdvertiseOption) {
name := ServiceInstanceName(i.Instance, i.ServiceType, i.Domain)
name := ServiceInstanceName(i.Name, i.ServiceType, i.Domain)
records := NewRecords(i, options...)

s.m.Lock()
Expand Down Expand Up @@ -100,7 +100,7 @@ func (s *UnicastServer) Advertise(i ServiceInstance, options ...AdvertiseOption)

// Remove stops advertising a DNS-SD service instance.
func (s *UnicastServer) Remove(i ServiceInstance) {
name := ServiceInstanceName(i.Instance, i.ServiceType, i.Domain)
name := ServiceInstanceName(i.Name, i.ServiceType, i.Domain)

s.m.Lock()
defer s.m.Unlock()
Expand Down
6 changes: 3 additions & 3 deletions dnssd/unicastserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ var _ = Context("UnicastServer", func() {
ctx, cancel = context.WithTimeout(context.Background(), 3*time.Second)

instanceA = ServiceInstance{
Instance: "Instance A",
Name: "Instance A",
ServiceType: "_http._tcp",
Domain: "example.org",
TargetHost: "a.example.com",
Expand All @@ -37,7 +37,7 @@ var _ = Context("UnicastServer", func() {
}

instanceB = ServiceInstance{
Instance: "Instance B",
Name: "Instance B",
ServiceType: "_http._tcp",
Domain: "example.org",
TargetHost: "b.example.com",
Expand All @@ -53,7 +53,7 @@ var _ = Context("UnicastServer", func() {
}

instanceC = ServiceInstance{
Instance: "Instance C",
Name: "Instance C",
ServiceType: "_other._udp",
Domain: "example.org",
TargetHost: "c.example.com",
Expand Down

0 comments on commit 9a7c96a

Please sign in to comment.