Seata Distributed Transaction Plugin
lynx-seata only does two things inside Lynx: decide whether the Seata client should start, and tell Seata which external config file to load. Registry, coordinator, namespace, auth, and transport settings still live in the file pointed to by config_file_path.
Runtime Facts
| Item | Value |
|---|---|
| Go module | github.com/go-lynx/lynx-seata |
| Config prefix | lynx.seata |
| Runtime plugin name | seata.server |
| Public APIs | GetPlugin(), GetConfig(), GetConfigFilePath(), IsEnabled(), WithGlobalTx(...), GetMetrics() |
What This YAML Actually Controls
- Use this plugin when the service already belongs to a Seata-based transaction topology and you want Lynx startup to own
client.InitPath(...). - The plugin does not describe transaction boundaries. Your service code still decides where to call
WithGlobalTx(...). - Passing
timeout == 0toWithGlobalTx(...)uses an internal60sdefault. That timeout is not configured inlynx.seata.
YAML Template
lynx:
seata:
enabled: true
config_file_path: "./conf/seata.yml"
Field Reference
| Field | Purpose | When it takes effect | Default and interactions | Common misconfig |
|---|---|---|---|---|
enabled | Gates Seata client startup and shared-resource registration. | Only when true; otherwise startup returns early and WithGlobalTx(...) reports that the plugin is disabled. | Default false. This field is the real on/off switch; config_file_path alone does not enable anything. | Setting a valid path but forgetting enabled: true, then expecting transactions to work. |
config_file_path | Filesystem path passed to client.InitPath(...). | Only when enabled: true. | Default ./conf/seata.yml when omitted. The file can be a local seata.yml / seatago.yml-style config or a config-center generated file that seata-go understands. | Writing coordinator or registry addresses directly here instead of pointing at an actual Seata YAML file. |
Complete YAML Example
lynx:
seata:
enabled: true # required switch; false skips Seata client startup entirely
config_file_path: "./conf/seata.yml" # defaults to ./conf/seata.yml; points to the external Seata client config file
Minimum Viable YAML Example
lynx:
seata:
enabled: true # turn on the plugin
config_file_path: "./conf/seata.yml" # point at the external Seata config file that seata-go will load
Operational Notes
- The referenced Seata YAML is not generated by Lynx. Keep registry, coordinator, auth, namespace, and transport settings in that external file.
CheckHealth()only verifies that the path is non-empty when the plugin is enabled. It does not prove that the file exists or that Seata can actually connect.- If your use case is business-level orchestration with Saga, TCC, XA, or two-phase message helpers, compare this page with DTM instead of stacking both transaction styles by default.
How To Consume It
plugin := seata.GetPlugin()
err := plugin.WithGlobalTx(ctx, "CreateOrderTx", 30*time.Second, func(ctx context.Context) error {
return doBusiness(ctx)
})
WithGlobalTx(...) is the intended entry point when you want Lynx-managed Seata runtime state but still want explicit transaction boundaries in your service layer.