From 34db43f9efe84f5205cadd0f7c7ef9fbd67b8df5 Mon Sep 17 00:00:00 2001 From: ZueffC Date: Sat, 19 Jul 2025 22:08:46 +0300 Subject: [PATCH] Added comments --- dns_manager.go | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/dns_manager.go b/dns_manager.go index f6b88fa..6bc8f2c 100644 --- a/dns_manager.go +++ b/dns_manager.go @@ -2,6 +2,7 @@ package dns_manager type RecordType string +// Defining supported record types const ( None RecordType = "None essential" A RecordType = "A" @@ -11,6 +12,8 @@ const ( TXT RecordType = "TXT" ) +// This is the DNS record structure. +// Ready to be marshaled into JSON type Record struct { Type RecordType `json:"type,omitempty"` Name string `json:"name,omitempty"` @@ -18,6 +21,15 @@ type Record struct { TTL uint `json:"ttl,omitempty"` } +// This is representation of simple API response +// to driver query +type Response struct { + Error string `json:"error"` + Message string `json:"message"` +} + +// The core of library<->drivers architecture +// All drivers must implement those methods type Actions interface { AddRecord(*Record) (*Response, error) DeleteRecord(*Record) (*Response, error) @@ -25,15 +37,15 @@ type Actions interface { GetRecords() ([]*Record, error) } +// This is local scope interface that defines +// method New() which must be implemented by all +// libraries. The New() represents fabric method. type manager interface { New() (Actions, error) } -type Response struct { - Error string `json:"error"` - Message string `json:"message"` -} - +// Naive method that checks if record type is +// supported by this library. func (rt RecordType) Check() bool { switch rt { case None, A, AAAA, MX, CNAME, TXT: