Repository navigation
Experimental Inara bindings - #65
Draft
rocketraman wants to merge 4 commits into
Draft
rocketraman wants to merge 4 commits into
rocketraman wants to merge 4 commits into
Conversation
rocketraman
force-pushed
the
rg/inara-di
branch
from
November 10, 2026 22:23
799c40b to
c45c26c
Compare
rocketraman
force-pushed
the
rg/inara-di
branch
2 times, most recently
from
November 10, 2026 23:53
9ab21be to
4458f01
Compare
Kodein's authors are sunsetting it in favour of Inara, a compile-time successor run by KSP. Add an inara flavor to configureDiVariants(), published as <module>-inara like the kodein and metro ones. KSP runs Inara's processor on the flavor's source set only, and the sources jar ships the generated builders. Each Bootable module is a @DIModule with a builder overload of the same name. The application composes the modules into its own @DIModule(composed = true), as Inara's maintainer suggested. - boot-config-common: ConfigModule, the ConfigModule.config(prefix) helper, and EmptyConfigModule, whose EmptyConfigBinder fails every read - boot-config-hoplite: HopliteConfigModule(), like Kodein's hopliteConfigModule - boot: BootableModule, composed over ConfigModule, taking the start order and tiebreaker as parameters, and reading the tiebreaker from config when there is one - boot: AppServiceAcceptor and LifecycleControllerAcceptor. Inara has no multibindings, so other modules' builders add their services to the BootableModule through these, and BootableModule runs them. The contributions live in the module instance, not in a global. - Name the files' JVM classes so they don't clash with the Kodein flavor's - boot's wiring tests cover the inara defaults, bindings, and config
Add inara flavors to boot-env, boot-db-jdbc, the JDBC driver modules, boot-db-pool-hikari, boot-db-flyway, and boot-db-exposed, named like their Kodein counterparts. - JdbcDataSourceModule(configSource, pool, context) takes a JdbcConfigSource and a JdbcPool, as Kodein imports a driver and a pool: SqliteConfigSource, MysqlConfigSource, PostgresqlConfigSource, JdbcGenericConfigSource, and HikariPool(customizers). - The builders take one context, typed C : ConfigModule, C : AppServiceAcceptor (or LifecycleControllerAcceptor for env). The app passes its BootableModule, and the builders see only the config and the acceptor. - The modules don't extend each other, as composed modules reject diamonds: Flyway and Exposed take the JdbcDataSourceModule as a parameter.
server-ktor-db/inara keeps its own code in an EntriesModule, built like the library modules, and AppModule only composes, as the Kodein example imports entriesModule. IDEA's Gradle settings gain both example projects.
rocketraman
force-pushed
the
rg/inara-di
branch
from
November 11, 2026 04:43
e4d82b7 to
16815f3
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Kodein's authors are sunsetting Kodein in favour of Inara, a compile-time successor that runs as a KSP processor. This adds experimental Inara bindings. If they work out, we'll deprecate the Kodein bindings and point users to Inara.
What's here
inaraflavor inconfigureDiVariants(), published as<module>-inaralike the-kodeinand-metrocoordinates. Every module with Kodein bindings has one.@DIModule(BootableModule,ConfigModule,EnvironmentModule,JdbcDataSourceModule,FlywayMigrationModule,ExposedDatabaseModule). It comes with a builder overload of the same name, which binds all of the module's members from what it needs, e.g.JdbcDataSourceModule(SqliteConfigSource, HikariPool(), bootable). Each builder takes theBootableModuleas its context, typed only asConfigModuleandAppServiceAcceptor: it reads its config from it and adds its services to it. KSP runs on the flavor's source set only, so the generated builders ship in the-inarajar.@DIModule(composed = true)and binds only its own members (composition).examples/wiring-inaraandexamples/server-ktor-db/inara, and Inara cases inboot's wiring tests.docs/wiring.adoc, plus README and CHANGELOG entries.How Kodein's features map to Inara
AppServiceAcceptor, whichBootableModuleimplements, and adds its own services to it (after this gist). The app adds only its own, withapp.addAppService { … }. The set lives in eachBootableModuleinstance, not in a global, so tests stay isolated. Forgetting one still compiles, and that service never starts. Adding a service after the set is read throws. A compile-time locator (proposal) would replace it.instanceOrNull, the builder takes a nullable parameter:BootableModule(configModule)reads the tiebreaker from config,BootableModule()falls back to anEmptyConfigModule, andstartOrderandtiebreakerparameters set them in code.BootableModuleextendsConfigModule(composed modules nest), and the app's module gets the config through it. The other modules take their context and theJdbcDataSourceModuleas parameters.Not covered
The database modules' own tests still exercise only Kodein and Metro. The env, MySQL and PostgreSQL Inara flavors compile, but nothing runs them.