Skip to main content

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

ItemValue
Go modulegithub.com/go-lynx/lynx-seata
Config prefixlynx.seata
Runtime plugin nameseata.server
Public APIsGetPlugin(), 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 == 0 to WithGlobalTx(...) uses an internal 60s default. That timeout is not configured in lynx.seata.

YAML Template

lynx:
seata:
enabled: true
config_file_path: "./conf/seata.yml"

Field Reference

FieldPurposeWhen it takes effectDefault and interactionsCommon misconfig
enabledGates 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_pathFilesystem 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.