Discovery
Configuration
Config reference, YAML example, and options for Discovery
extensions:
discovery:
enabled: true
backend: "consul" # "memory", "consul", "etcd", "mdns", "kubernetes", "eureka"
service:
name: "my-service"
id: "" # auto-generated if empty
version: "1.0.0"
address: "localhost"
port: 8080
tags: ["api", "v1"]
metadata:
team: "platform"
enableAutoDeregister: true
healthCheck:
enabled: true
interval: "10s"
timeout: "5s"
deregisterCriticalServiceAfter: "1m"
watch:
enabled: false
services: []
tags: []
consul:
address: "127.0.0.1:8500"
etcd:
endpoints:
- "127.0.0.1:2379"
dialTimeout: "5s"
keyPrefix: "/services"
mdns:
domain: "local."
browseTimeout: "3s"
ttl: 120
farp:
enabled: false
autoRegister: true
strategy: "push" # "push", "pull", "hybrid"
endpoints:
health: "/health"
metrics: ""
openAPI: ""
asyncAPI: ""
grpcReflection: ""
graphQL: ""
capabilities: []
All configuration can be set with variadic options:
ext := discovery.NewExtension(
discovery.WithBackend("consul"),
discovery.WithServiceName("my-service"),
discovery.WithServiceAddress("0.0.0.0", 8080),
discovery.WithServiceTags("api", "v1"),
discovery.WithHealthCheck(discovery.HealthCheckConfig{
Enabled: true,
Interval: 10 * time.Second,
}),
discovery.WithFARPEnabled(true),
discovery.WithFARPAutoRegister(true),
discovery.WithFARPEndpoints(discovery.FARPEndpointsConfig{
OpenAPI: "/openapi.json",
Health: "/health",
}),
)
| Field | Default | Description |
|---|
Name | "" | Service name (falls back to app.Name()) |
ID | "" | Service instance ID (auto-generated) |
Version | "" | Service version |
Address | "" | Service address |
Port | 0 | Service port |
Tags | [] | Service tags for filtering |
Metadata | {} | Arbitrary key-value metadata |
EnableAutoDeregister | true | Auto-deregister on shutdown |
| Field | Default | Description |
|---|
Enabled | true | Enable health checks |
Interval | 10s | Health check interval |
Timeout | 5s | Health check timeout |
DeregisterCriticalServiceAfter | 1m | Deregister after critical for this duration |
| Field | Default | Description |
|---|
Enabled | false | Enable FARP endpoints |
AutoRegister | true | Auto-register FARP manifest |
Strategy | "push" | Registration strategy: push, pull, hybrid |
Schemas | [] | Schema configurations (OpenAPI, AsyncAPI, GraphQL, gRPC) |
Endpoints | | API endpoint paths for schema discovery |
Capabilities | [] | Advertised capabilities |
| Field | Default | Description |
|---|
Health | "/health" | Health check endpoint path |
Metrics | "" | Metrics endpoint path |
OpenAPI | "" | OpenAPI spec endpoint path |
AsyncAPI | "" | AsyncAPI spec endpoint path |
GRPCReflection | false | Whether gRPC reflection is enabled |
GraphQL | "" | GraphQL endpoint path |
| Field | Default | Description |
|---|
Domain | "local." | mDNS domain |
ServiceType | "" | Service type for registration (default: _<name>._tcp) |
ServiceTypes | [] | Service types to browse for discovery |
BrowseTimeout | 3s | Browse operation timeout |
TTL | 120 | DNS record TTL |
WatchInterval | 0 | Watch polling interval |
Interface | "" | Network interface to bind to |
IPv6 | false | Enable IPv6 |
| Option | Description |
|---|
WithFARP(cfg) | Set the full FARP configuration |
WithFARPEnabled(bool) | Enable or disable FARP |
WithFARPAutoRegister(bool) | Auto-register schemas on startup |
WithFARPStrategy(string) | Set strategy: push, pull, or hybrid |
WithFARPSchemas(schemas...) | Set schema configurations |
WithFARPEndpoints(cfg) | Set endpoint configuration |
WithFARPCapabilities(caps...) | Set capability tags |
| Option | Description |
|---|
WithMDNS(domain) | Set backend to mDNS with optional domain |
WithMDNSServiceType(t) | Set the mDNS service type for registration |
WithMDNSServiceTypes(t...) | Set service types to browse for discovery |
WithMDNSBrowseTimeout(d) | Set browse operation timeout |
WithMDNSTTL(ttl) | Set DNS record TTL |
WithMDNSWatchInterval(d) | Set watch polling interval |
WithMDNSInterface(iface) | Bind to a specific network interface |
WithMDNSIPv6(bool) | Enable IPv6 support |
How is this guide?