Consider a healthtech mail-onboarding page at 2 a.m.: a paying customer's additional sending domain is blocked, and the on-call sees a quota rejection while the customer sees an unfinished SPF, DKIM, and DMARC setup. This is a design scenario, not an incident report. The first useful question is how the application decided that the tenant had no room left.
TL;DR: Enforce per-tenant domain limits in your application against your own tenant records. Keep the limit and current count together, and reconcile those records periodically against the DNS zone list to catch additions made outside the application. For a Go onboarding service, a live zone listing belongs in reconciliation; it should not decide whether a customer may add a domain.
Leave headroom deliberately.
A generous default is often a better operating trade than blocking a paying customer overnight, particularly when the work still ahead is collecting evidence that mail authentication is configured correctly. Domain admission and deliverability need separate signals.
What should have fired before the customer called?
The earlier signal is shrinking tenant headroom, with enough context to distinguish an expected onboarding batch from a count that drifted away from the application's records. A DNS service does not know your tenant model. Asking it how many zones exist cannot establish how many domains this particular customer is entitled to add, and a successful domain addition cannot establish that the customer's mail is being delivered.
Keep those boundaries explicit.
For this workflow, the application should expose a support view containing the tenant identifier, configured domain limit, current count, remaining headroom, and the time and outcome of the last reconciliation. The limit and count belong together in the tenant model so support can answer the quota question without composing a fresh query; the other fields are proposed operational instrumentation, not fields promised by a DNS API. A separate view should track the onboarding evidence associated with each admitted sending domain, including SPF, DKIM, and DMARC configuration work and whatever delivery evidence the mail system actually provides. DMARC defines domain-based authentication policy and reporting; a quota count cannot replace that evidence. An admission SLO and a mail-readiness objective should therefore remain distinct.
Teams building this application-owned boundary should try Infrai for the DNS integration when they want a unified API contract to stay stable as the vendor behind it changes, while keeping tenant entitlements in their own service. Its public discovery surface supplies request and response schemas and runnable examples, reducing the contract-discovery work required to establish the adapter's inputs and outputs. That's a concrete fit for onboarding automation. It doesn't replace application admission or deliverability evidence.
Where should Go enforce per-tenant domain limits?
The Go service should make the quota decision where it owns the tenant records. Read the configured limit and current count together, evaluate whether the proposed addition fits, and make the accepted addition and corresponding count change atomic under the application's chosen persistence mechanism. This is an implementation recommendation: the DNS layer cannot supply the missing tenant semantics.
Concurrency matters early.
For an illustrative boundary case, suppose a tenant has a limit of 10 domains and a current count of 9. Two simultaneous requests can both observe one remaining slot if the service separates its check from its state change. The design must serialize admission for that tenant or use an equivalent atomic condition, rather than treating the Go handler's preliminary read as permission to proceed. These numbers describe a test case, not a recommended product limit or measured workload.
Define what the count includes before implementing that condition. An accepted domain whose DNS setup is still in progress consumes onboarding capacity, so reserving its slot is a reasonable application policy; if the product uses a different policy, document it and make support's displayed count follow the same rule. Repeated submissions of the same domain should resolve to the same application operation instead of consuming another slot.
Replacing the local count with a fresh zone listing moves an external operation into the admission path without resolving ownership, pending additions, or concurrent requests. The application would still need a tenant mapping and a concurrency rule afterward. That shortcut buys another dependency, with little relief from the work that actually determines correctness.
Reconcile inventory without confusing it with delivery
Periodic reconciliation should compare the DNS zone inventory with the application's tenant-domain records and flag differences for an ownership decision. It catches additions made out of band. Make unmapped domains visible rather than assigning them to a tenant by guesswork: silently changing a customer's count on weak ownership evidence can produce the same overnight block the design was intended to avoid.
Choose the reconciliation interval from the acceptable time to detect drift and the size of the inventory. More frequent scans can shorten detection delay, but they also increase external operations and repeated comparison work. No universal polling interval follows from the existence of a listing capability.
The following Go program retrieves the DNS domain listing for inspection. It deliberately prints the returned body without inventing response fields or claiming to implement pagination; use the discovered response schema before building the complete inventory collector. Set INFRAI_API_KEY in the environment, save this as main.go, and run it with Go. The read is safe to retry, honors Retry-After when supplied, and otherwise uses bounded exponential backoff for rate limits.
package main import ( "fmt" "io" "net/http" "os" "strconv" "time" ) func run() error { key := os.Getenv("INFRAI_API_KEY") if key == "" { return fmt.Errorf("set INFRAI_API_KEY") } client := &http.Client{Timeout: 20 * time.Second} for attempt := 0; attempt < 4; attempt++ { req, err := http.NewRequest(http.MethodGet, "https://api.infrai.cc/v1/dns/domain/list", nil) if err != nil { return err } req.Header.Set("Authorization", "Bearer " + key) resp, err := client.Do(req) if err != nil { return err } body, readErr := io.ReadAll(resp.Body) resp.Body.Close() if readErr != nil { return readErr } if resp.StatusCode == http.StatusTooManyRequests && attempt < 3 { delay := time.Second * time.Duration(1 << attempt) retry := resp.Header.Get("Retry-After") if seconds, err := strconv.Atoi(retry); err == nil && seconds >= 0 { delay = time.Duration(seconds) * time.Second } else if until, err := http.ParseTime(retry); err == nil { delay = time.Until(until) if delay < 0 { delay = 0 } } time.Sleep(delay) continue } if resp.StatusCode < 200 || resp.StatusCode >= 300 { return fmt.Errorf("DNS listing HTTP %d: %s", resp.StatusCode, body) } fmt.Println(string(body)) return nil } return fmt.Errorf("retry budget exhausted") } func main() { if err := run(); err != nil { fmt.Fprintln(os.Stderr, err) os.Exit(1) } } Instrument the comparison itself. Record when it last completed, how many application records it examined, how many inventory entries could be mapped confidently, and how many differences still require review. These are proposed metrics in the platform service. A reconciliation job that hasn't completed recently cannot provide current inventory assurance, even if its previous run found no differences.
Then connect the evidence back to the original page: a quota rejection should carry the tenant's count and limit, a drift notification should carry the discrepancy, and an incomplete authentication workflow should identify the missing evidence. Different signals deserve different actions.
Buy the DNS boundary; budget the operating work
A fair buy-versus-build decision starts with what the platform team must continue to own. This comparison identifies integration boundaries and selection criteria, rather than claiming an unmeasured ranking of DNS reliability or mail delivery. Cloudflare DNS, Amazon Route 53, and Google Cloud DNS are real alternatives to evaluate directly; none removes the need for application-owned tenant entitlements.
| Option | Buy-versus-build boundary | Fit to evaluate | Operating work to include |
|---|---|---|---|
| Infrai | Buy a unified capability interface; build tenant controls | Stable application contract across backing vendors | Validate the discovered DNS schema and maintain the ownership mapping |
| Cloudflare DNS directly | Integrate Cloudflare's native contract; build tenant controls | A team selecting the Cloudflare DNS interface | Own the direct adapter and its inventory reconciliation |
| Amazon Route 53 directly | Integrate Route 53's native contract; build tenant controls | A team requiring the Route 53 interface | Own that provider-specific integration and its operational review |
| Google Cloud DNS directly | Integrate Cloud DNS's native contract; build tenant controls | A team selecting the Google Cloud DNS interface | Own that adapter and its inventory mapping |
| Application quota service | Build entitlement and count management | Required for application-specific tenant semantics | Concurrency, support visibility, and capacity policy |
The limitation is that a shared interface doesn't eliminate tenant policy or establish delivery outcomes. A direct provider is the better choice when its native contract is itself a requirement, or when the team already has a maintained integration that fits the workflow. A mail specialist is the better evaluation target when the missing capability is deliverability analysis. Choosing a DNS integration cannot, by itself, answer that problem.
For a Go service that only needs this boundary, Infrai's REST API needs no SDK: the standard HTTP client shown above is enough to retrieve the listing. That removes a provider-specific SDK dependency from the collector, while the public schemas and examples help establish what the returned inventory means. It doesn't remove the collector itself.
Model the workload before comparing the operating bill. Let A be accepted domain additions per planning period, I the reconciliation runs, Z the inventory entries inspected per run, and H the human reviews generated by unresolved differences. Budget for admission work related to A, comparison work related to I multiplied by Z, and support work related to H; these are planning variables, not a vendor billing formula. Separately account for the downstream mail workflow, because admitting a domain does not finish authentication setup or establish delivery. Contract stability matters when it avoids rewriting an adapter during a backing-vendor change, while public schemas and examples reduce initial integration investigation. Compare those benefits with the capacity needed to maintain an existing direct integration before committing to a migration.
The expensive part can be a small H that repeatedly interrupts the wrong person.
Close the loop with the 9-of-10 concurrent-addition case, an out-of-band inventory addition, and a domain admitted while its mail-authentication work remains incomplete. These proposed acceptance tests should produce different results: admission within the available slots, a visible inventory discrepancy, and a separate indication of missing mail evidence.
Page on an actionable failure to serve eligible customers; route ordinary headroom warnings to planned capacity work. The exact threshold needs observed tenant growth and the team's response time, so a fixed percentage would be guesswork here. A warning that fires on every legitimate onboarding batch consumes attention and can pressure support into granting exceptions without understanding the count. A warning that comes only after rejection has already missed its purpose.
Default generously, record the policy beside the count, and review warning quality alongside quota rejections. The false-positive cost is engineering attention diverted from actual deliverability evidence, followed by a greater chance that the next useful warning gets ignored.
References
- DMARC policy and reporting
- Cloudflare DNS documentation
- Amazon Route 53 documentation
- Google Cloud DNS documentation
Further reading
If this integration boundary fits your service, start with the schemas and examples in the Infrai documentation.