Skip to content

cardinalby/depo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

list test Go Reference

"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.

🔹 Alternative to automated Dependency Injection

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

🔹 Concurrent run and shutdown

👉 Web Demo page

Full application lifecycle
A component fails to Start
Component's Run method returns an error

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

🔹 Getting started

go get github.com/cardinalby/depo

👉 Check out the Documentation

👉 Check out the Example multi-cmd project

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages