Di; new dependency injection shard

Hello everyone,

I just released Di v0.1.0, a new dependency injection shard.

Di is macro first and type safe. It supports auto wire from constructor types, named services, transient services, fiber local scopes, health checks, and graceful shutdown.

require "di"

Di.provide { Database.new(ENV["DATABASE_URL"]) }
Di.provide UserRepo
Di.provide UserService

svc = Di.invoke(UserService)

Di.scope(:request) do
  Di.provide { CurrentUser.from_token(token) }
  current = Di.invoke(CurrentUser)
end

Repo: GitHub - omarluq/di: Dependency injection for the Crystal programming language
Docs: https://crystaldoc.info/github/omarluq/di

Feedback are always welcome.

2 Likes