Etcd Plugin
The Etcd module is both a config-center plugin and a service registry or discovery backend.
Runtime Facts
| Item | Value |
|---|---|
| Go module | github.com/go-lynx/lynx-etcd |
| Config prefix | lynx.etcd |
| Runtime plugin name | etcd.config.center |
| Public APIs | GetClient(), GetEtcdConfig(), GetNamespace(), GetConfigSources(), GetConfigValue(prefix, key) |
What The Implementation Provides
The code supports:
- config loading from an Etcd prefix
- multiple config prefixes with merge strategy
- optional local cache
- retry, graceful shutdown, metrics, and health checks
- optional service registration
- optional service discovery and watchers
So this plugin is broader than "read a few keys from Etcd".
Configuration
lynx:
etcd:
endpoints:
- "127.0.0.1:2379"
namespace: "lynx/config"
enable_register: true
enable_discovery: true
registry_namespace: "lynx/services"
ttl: 30s
service_config:
prefix: "lynx/config"
additional_prefixes:
- "lynx/config/shared"
merge_strategy: "override"
What The Official Template Uses
The official template does not enable Etcd by default. The current scaffold uses Polaris as its control-plane example instead.
That is important because Etcd serves two very different roles in Lynx:
- config-center and service-registry infrastructure
- runtime dependency for higher-level features such as Etcd Lock
So this page should be read as "how to bring Etcd into the runtime when your environment needs it", not as something the base template already wires.
How To Consume It
plugin := lynx.Lynx().GetPluginManager().GetPlugin("etcd.config.center")
etcdPlugin := plugin.(*etcd.PlugEtcd)
client := etcdPlugin.GetClient()
sources, err := etcdPlugin.GetConfigSources()
value, err := etcdPlugin.GetConfigValue("lynx/config", "my.key")
For service registration and discovery, the module also exposes registrar and discovery implementations such as NewEtcdRegistrar and NewEtcdDiscovery.
Practical Notes
namespaceandservice_config.prefixaffect configuration lookup, whileregistry_namespaceaffects service instance paths.- Enabling register or discovery changes this plugin from pure config-center usage into control-plane infrastructure.
- Etcd Lock depends on this plugin's runtime resource.