Skip to main content

Pivot to a Dependency Injection Toolkit

· 3 min read
Brandon Konkle
Principal Engineer @ Formidable

Nakago Pivots to a Dependency Injection Toolkit

With the release of Nakago v0.23, the project is pivoting away from the ambitious goal of a full-featured API framework, and towards a more streamlined dependency injection toolkit instead. The async Rust ecosystem is growing rapidly, and I haven't been able to devote enough time to Nakago to grow the application lifecycle and convenience features that I had originally envisioned. There are other projects that are doing a great job of providing these features - like Loco, Tide, Seaography, or Salvo.

What I haven't seen yet, however, is an async-first dependency injection container that is as lightweight and easy to work with as Nakago is, and doesn't require a lot of opaque macros or code generation. Nakago uses macros sparingly and takes advantage of Rust's Any dynamic typing tools to support a thread-safe, async-first dependency injection container that would work well with a variety of different Rust frameworks and team sizes.

I'll continue refining Nakago and adding features and integrations as I have need of them on side projects, and I'd love to collaborate with others who are interested in building a lightweight, async-first dependency injection toolkit for Rust.

The v0.23 Changelog

Removed

  • nakago - Removed Application, Hooks, the lifecycle::EventType and lifecycle::Events enums. The config utilities were moved to nakago-figment.
  • nakago-axum - Removed AxumApplication, Route, and Routes in favor of a more generic approach. Use the new Inject extractor to access dependencies in your Axum handlers.
  • nakago-warp - Removed WarpApplication, Route, and Routes in favor of a more generic approach. Use the with_injection() Filter to access dependencies in your Warp handlers.

Changed

  • nakago - The tag-based container operations were previously the default mode of working with Inject. This proved to be more verbose and than necessary in most cases, however. The new default mode is to use the type-based operations, which are more ergonomic and easier to use. The tag-based operations are still available, but they are now suffixed with _tag to make it clear that they are a different mode of operation. The type-based operations are no longer suffixed with _type, because they are now the default.
  • nakago - The inject namespace has been promoted to the top level. Where nakago::inject was used before, nakago should now be the equivalent.
  • nakago - The config utilities were moved to nakago-figment.
  • nakago-examples-simple, nakago-examples-async-graphql, nakago-examples-simple-warp - Updated with the new approach. See these examples for more information about how to use the tools mentioned above.

Added

  • nakago-axum - Added a new Inject extractor to access dependencies in your Axum handlers. This is a much more idiomatic way to use Nakago with Axum, and it's more flexible than the previous approach. Use the provided Axum State to make the Inject container available to your handlers.
  • nakago-figment - Generic config utilities extracted from the core nakago package.

Welcome

· One min read
Brandon Konkle
Principal Engineer @ Formidable

Welcome to Nakago

I created Nakago to help organize my Rust projects and cut down on boilerplate code as my applications grew larger. I wanted a framework that would allow me to focus on the business logic of my applications, while providing a solid foundation for the rest of the code.

I've had great experiences in other language ecosystems with frameworks like Django in Python and Nest.js in TypeScript. I wanted to bring some of the same ideas to Rust, while taking advantage of the unique features of the language.

Nakago is a lightweight framework for building Rust applications with a modular structure, taking advantage of dependency injection and lifecycle events to bring organization and testability to Rust projects large and small.

Documentation & Examples

Check out the Documentation and Examples to learn more about how to use Nakago. A 10-minute tutorial is coming soon, and stay tuned for videos on YouTube and Twitch as I begin to share my experiences with Nakago.