From 612cf06c066c8a4e0ef62ba23e445dfca9b1285e Mon Sep 17 00:00:00 2001 From: Virgil Date: Sat, 4 Apr 2026 02:55:03 +0000 Subject: [PATCH] Add semantic service snapshot alias --- service.go | 14 +++++++++++--- service_test.go | 19 +++++++++++++++++++ 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/service.go b/service.go index f3ad657..f27c5ef 100644 --- a/service.go +++ b/service.go @@ -1169,11 +1169,11 @@ func (service *Service) Health() HealthResult { } } -// Describe returns a structured snapshot that is easier to inspect than String(). +// Snapshot returns a structured view of the service state. // -// snapshot := service.Describe() +// snapshot := service.Snapshot() // fmt.Printf("%+v\n", snapshot) -func (service *Service) Describe() ServiceDescription { +func (service *Service) Snapshot() ServiceDescription { if service == nil { return ServiceDescription{ Status: "not_ready", @@ -1211,6 +1211,14 @@ func (service *Service) Describe() ServiceDescription { } } +// Describe is the compatibility alias for Snapshot. +// +// snapshot := service.Describe() +// fmt.Printf("%+v\n", snapshot) +func (service *Service) Describe() ServiceDescription { + return service.Snapshot() +} + // ZoneApex returns the computed apex for the current record set. // // apex := service.ZoneApex() diff --git a/service_test.go b/service_test.go index 21d4a6d..4bb84e8 100644 --- a/service_test.go +++ b/service_test.go @@ -686,6 +686,25 @@ func TestServiceDescribeReturnsSemanticSnapshot(t *testing.T) { } } +func TestServiceSnapshotMatchesDescribe(t *testing.T) { + service := NewService(ServiceOptions{ + Records: map[string]NameRecords{ + "gateway.charon.lthn": { + A: []string{"10.10.10.10"}, + }, + }, + DNSPort: 1053, + HTTPPort: 5555, + }) + + snapshot := service.Snapshot() + description := service.Describe() + + if snapshot != description { + t.Fatalf("expected Snapshot to match Describe, got %#v and %#v", snapshot, description) + } +} + func TestServiceServeHTTPHealthReturnsJSON(t *testing.T) { service := NewService(ServiceOptions{ Records: map[string]NameRecords{