Go Micro Logo Go Micro

ADR-004: mDNS as Default Registry

Status

Accepted

Context

Service discovery is critical for microservices. Common approaches:

  1. Central registry (Consul, Etcd) - Requires infrastructure
  2. DNS-based (Kubernetes DNS) - Platform-specific
  3. Static configuration - Doesn’t scale
  4. Multicast DNS (mDNS) - Zero-config, local network

For local development and getting started, requiring infrastructure setup is a barrier. Production deployments typically have existing service discovery infrastructure.

Decision

Use mDNS as the default registry for service discovery.

Implementation

// Default - uses mDNS automatically
svc := micro.NewService(micro.Name("myservice"))

// Production - swap to Consul
reg := consul.NewConsulRegistry()
svc := micro.NewService(
    micro.Name("myservice"),
    micro.Registry(reg),
)

Consequences

Positive

Negative

Mitigations

Use Cases

Good for mDNS

Need Production Registry

Alternatives Considered

No Default (Force Configuration)

Rejected because:

Static Configuration

Rejected because:

Consul as Default

Rejected because:

Migration Path

Start with mDNS, migrate to production registry:

# Development
go run main.go

# Staging
MICRO_REGISTRY=consul MICRO_REGISTRY_ADDRESS=consul:8500 go run main.go

# Production (Kubernetes)
MICRO_REGISTRY=nats MICRO_REGISTRY_ADDRESS=nats://nats:4222 ./service