distage is a pragmatic module system for Scala that combines simplicity and reliability of pure FP with extreme late-binding and flexibility of runtime dependency injection frameworks such as Guice.
distage is unopinionated, it’s good for structuring applications written in either imperative Scala as in Akka/Play, or in pure FP Tagless Final Style
- Faster applications and tests:
distageguarantees that no unneccessary instantiations will happen during your tests or application startup.
- Quicker failure detection:
distagepeforms all the integration checks for your application and tests even before any instantiations happened.
- Simpler tests:
distageeliminates all the hard work of setting up your test environments, especially polymorphic ones.
- Simpler development workflows:
distageallows you to develop Role-Based Applications – a fusion of Microservices and Monoliths. You may run all your services in one process for development purposes (and even switch to mock implementations with a single commandline argument).
- Simpler deployments:
distageallows you to simplify deployments and reduce your running costs by leveraging Role-Based Applications Architecture.
- Simpler debugging:
distageprovides you important insights about your application and allows you to introspect and modify it on the fly, before any instantiations happen.
- Higher Correctness:
distagesupports resources and lifecycle natively and guarantees proper cleanups even when something went wrong.
- Cheaper integration tests:
distageprovides you great memoization support for your tests so you may reuse heavy resources (like database connections) in multiple integration tests not sacrificing correctness.
- No pressure:
distageis non-invasive and designed to not impact the way your Scala code is written. It just removes all the initialization boilerplate. You don’t need to learn magic tricks to write components in a distage application.
distage is recommended by industry leaders:
Given its native support for type classes and higher-kinded types – both features indispensable to functional programming – distage is one of the leading dependency injection libraries out there. Bonus points for being built by a wicked-smart team that contributes to ZIO!
-? John A. De Goes
Q: isn’t it unsafe to use a runtime dependency injection framework?
distage has static verification mechanisms allowing to achieve same level of guarantees as hand-written static code. Full compile-time DI support is under development.
Q: how to pronounce “distage” ?
A: ‘Dee-stage’, but you can pronounce it however you like!
- distage Example Project
- Slides - distage: Staged Dependency Injection
- Config Injection
- Other features
- Role-Based Apps
- Syntax reference
See PPER Overview