Go53 DNS Data Storage Design

1. In-Memory Data Structure

Go structure:

map[string]map[string]map[string]any
// zone      // type      // record name -> struct

Example (JSON):

{
  "A": {
    "www.example.com.": { "name": "www.example.com.", "ip": "192.0.2.5", "ttl": 3600 }
  },
  "SOA": {
    "example.com.": {
      "name": "example.com.",
      "ns": "ns1.example.com.",
      "mbox": "admin.example.com.",
      "serial": 2024060101,
      "refresh": 3600,
      "retry": 600,
      "expire": 86400,
      "minttl": 3600,
      "ttl": 3600
    }
  },
  "MX": {
    "example.com.": {
      "name": "example.com.",
      "preference": 10,
      "mx": "mx1.example.com.",
      "ttl": 3600
    }
  },
  "NS": {
    "example.com.": [
      { "name": "example.com.", "ns": "ns1.example.com.", "ttl": 3600 },
      { "name": "example.com.", "ns": "ns2.example.com.", "ttl": 3600 }
    ]
  }
}

2. Backend: BadgerDB Key-Value Storage

Write Flow

Read Flow

3. Loading/Saving Data

4. Summary