"depo" is a complete solution for managing dependency construction and lifecycles in Golang projects.
Note
Automated DI frameworks (Uber Fx, Wire) don't play well with the absence of annotations and "local interfaces" idea in Go.
Many of Go developers also prefer to have more control and pass dependencies explicitly.
But the problem of managing dependencies initialization and run order in larger projects is still there and that's what the library is designed to address.
With the library you still manually choose the dependencies to initialize your components but also benefit from traditional DI features like:
- Building a dependency graph to use for running/shutting down components in the right order
- Lazy initialization of components (avoid creating components that are never used)
- Resolving circular dependencies (that's what both Uber Fx and Wire failed to do but is handled in other languages) by using late initialization
Since the library builds the dependency graph, it manages the entire application lifecycle with Runner that can start and
shut down components in the proper order concurrently when possible, speeding up your starts and shutdowns.
SIGINT/SIGTERM shutdown context is supported out of the box.
Fx's lifecycle starts components sequentially in the order they have been registered in it, while depo uses the dependency graph which enables it to start and shut down the components that are not dependent on each other concurrently
The library supports both waiting (Run) and async (Start and/or Close)
lifecycle semantics for components
go get github.com/cardinalby/depo👉 Check out the Documentation
👉 Check out the Example multi-cmd project


