Discovery

Configuration

Config reference, YAML example, and options for Discovery

YAML Configuration Example

config.yaml
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: []

Programmatic Configuration

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",
    }),
)

Key Config Sections

Service Registration

FieldDefaultDescription
Name""Service name (falls back to app.Name())
ID""Service instance ID (auto-generated)
Version""Service version
Address""Service address
Port0Service port
Tags[]Service tags for filtering
Metadata{}Arbitrary key-value metadata
EnableAutoDeregistertrueAuto-deregister on shutdown

Health Check

FieldDefaultDescription
EnabledtrueEnable health checks
Interval10sHealth check interval
Timeout5sHealth check timeout
DeregisterCriticalServiceAfter1mDeregister after critical for this duration

FARP

FieldDefaultDescription
EnabledfalseEnable FARP endpoints
AutoRegistertrueAuto-register FARP manifest
Strategy"push"Registration strategy: push, pull, hybrid
Schemas[]Schema configurations (OpenAPI, AsyncAPI, GraphQL, gRPC)
EndpointsAPI endpoint paths for schema discovery
Capabilities[]Advertised capabilities

FARP Endpoints

FieldDefaultDescription
Health"/health"Health check endpoint path
Metrics""Metrics endpoint path
OpenAPI""OpenAPI spec endpoint path
AsyncAPI""AsyncAPI spec endpoint path
GRPCReflectionfalseWhether gRPC reflection is enabled
GraphQL""GraphQL endpoint path

mDNS

FieldDefaultDescription
Domain"local."mDNS domain
ServiceType""Service type for registration (default: _<name>._tcp)
ServiceTypes[]Service types to browse for discovery
BrowseTimeout3sBrowse operation timeout
TTL120DNS record TTL
WatchInterval0Watch polling interval
Interface""Network interface to bind to
IPv6falseEnable IPv6

FARP Config Options

OptionDescription
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

mDNS Config Options

OptionDescription
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?

On this page