Skip to content

Commit

Permalink
Add fx.Module (#830)
Browse files Browse the repository at this point in the history
This adds fx.Module Option which is a first-class object for supporting scoped operations on dependencies. A Module can consist of zero or more fx.Options.

By default, Provides to a Module is provided to the entire App, but there is a room for adding an option to scope that to a Module. Module can wrap Options such asSupply/Extract, Provide, and Invoke but there are some Options that don't make sense to put under Module. For example, StartTimeout, StopTimeout, WithLogger explicitly errors out when supplied to a Module.

Implementation-wise, a Module corresponds to dig.Scope which was added in uber-go/dig#305. Extra bookkeeping is done by the module struct which contains the provides and invokes to a Scope.

Co-authored-by: Abhinav Gupta <mail@abhinavg.net>
Co-authored-by: Abhinav Gupta <abg@uber.com>
Co-authored-by: Abhinav Gupta <mail@abhinavg.net>
  • Loading branch information
3 people authored and josephinedotlee committed Feb 8, 2022
1 parent 34519fa commit d173aa3
Show file tree
Hide file tree
Showing 7 changed files with 603 additions and 78 deletions.
Loading

0 comments on commit d173aa3

Please sign in to comment.