Uber Go Fx Versions Save

A dependency injection based application framework for Go.

v1.18.0

1 year ago

Added

  • Soft value groups that lets you specify value groups as best-effort dependencies.
  • fx.OnStart and fx.OnStop annotations which lets you annotate dependencies to provide OnStart and OnStop lifecycle hooks.
  • A new fxevent.Replaced event written to fxevent.Logger following an fx.Replace.

Fixed

  • Upgrade Dig dependency to v1.14.1 to address a couple of issues with decorations. Refer to Dig v1.14.1 release notes for more details.
  • fx.WithLogger no longer ignores decorations and replacements of types that it depends on.
  • Don't run lifecycle hooks if the context for them has already expired.
  • App.Start and App.Stop no longer deadlock if the OnStart/OnStop hook exits the current goroutine.
  • fxevent.ConsoleLogger no longer emits an extraneous argument for the Supplied event.

Deprecated

  • fx.Extract in favor of fx.Populate.

v1.17.1

2 years ago

Added

  • Logging for provide/invoke/decorate now includes the associated fx.Module name.

v1.17.0

2 years ago

Added

  • Add fx.Module which scopes any modifications made to the dependency graph.
  • Add fx.Decorate and fx.Replace that lets you modify a dependency graph with decorators.
  • Add fxevent.Decorated event which gets emitted upon a dependency getting decorated.

Changed

  • fx.Annotate: Validate that fx.In or fx.Out structs are not passed to it.
  • fx.Annotate: Upon failure to Provide, the error contains the actual location of the provided constructor.

v1.16.0

2 years ago

Added

  • Add the ability to provide a function as multiple interfaces at once using fx.As.

Changed

  • fx.Annotate: support variadic functions, and feeding value groups into them.

Fixed

  • Fix an issue where OnStop hooks weren't getting called on SIGINT on Windows.
  • Fix a data race between app.Done() and shutdown.

v1.15.0

2 years ago

Added

  • Add fx.Annotate to allow users to provide parameter and result tags easily without having to create fx.In or fx.Out structs.
  • Add fx.As that allows users to annotate a constructor to provide its result type(s) as interface(s) that they implement instead of the types themselves.

Fixed

  • Fix fxevent.Stopped not being logged when App.Stop is called.
  • Fix fxevent.Started or fxevent.Stopped not being logged when start or stop times out.

v1.14.2

2 years ago

Changed

  • For fxevent console implementation: no longer log non-error case for fxevent.Invoke event, while for zap implementation, start logging fx.Invoking case without stack.

v1.14.1

2 years ago

Changed

  • fxevent.Invoked was being logged at Error level even upon successful Invoke. This was changed to log at Info level when Invoke succeeded.

v1.14.0

2 years ago

Added

  • Introduce the new fx.WithLogger option. Provide a constructor for fxevent.Logger objects with it to customize how Fx logs events.
  • Add new fxevent package that exposes events from Fx in a structured way. Use this to write custom logger implementations for use with the fx.WithLogger option.
  • Expose and log additional information when lifecycle hooks time out.

Changed

  • Fx now emits structured JSON logs by default. These may be parsed and processed by log ingestion systems.
  • fxtest.Lifecycle now logs to the provided testing.TB instead of stderr.
  • fx.In and fx.Out are now type aliases instead of structs.

v1.13.1

3 years ago

Fixed

  • Fix minimum version constraint for dig. fx.ValidateGraph requires at least dig 1.10.

v1.13.0

3 years ago

Added

  • Added fx.ValidateGraph which allows graph cycle validation and dependency correctness without running anything. This is useful if fx.Invoke has side effects, does I/O, etc.