Skip to content

Conversation

@fireboy1919
Copy link
Collaborator

Summary

  • Refactor serve module as standalone publishable artifact
  • Add micronaut-starter demo app with serve-only DI support
  • Rename ViaductServerProvider to ViaductProvider
  • Add Koin dependency injection integration to ktor-starter demo app
  • Implement KoinTenantCodeInjector for resolver instantiation via Koin

PUBLIC
feat(ktor-starter): add Koin DI integration with custom TenantCodeInjector

Implements Koin-based dependency injection for the ktor-starter demo app, demonstrating how to use a DI framework as the source of truth for resolver instantiation.

Key components:

  • Serve module extracted as standalone publishable artifact
  • Micronaut-starter demo app showing DI integration pattern
  • KoinTenantCodeInjector: implements TenantCodeInjector, delegates to Koin
  • viaductModule: registers Viaduct singleton configured with Koin-based DI
  • resolversModule: registers services and resolver factories
  • AsciiArtService/AsciiArtResolver: example of constructor injection

Test Plan

  • All existing tests pass
  • New ASCII art query test via Koin DI passes
  • ./gradlew build succeeds for ktor-starter
  • ./gradlew build succeeds for micronaut-starter

| || || || || || || || || |
| || || || || || || || || |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
GraphQL Data Pipeline Framework
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if i like "Data Pipeline Framework" -- how about "Data-Oriented Service Mesh"?


dependencyResolutionManagement {
repositories {
mavenLocal()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't think we should check this in.

response.status shouldBe HttpStatusCode.OK
// Verify we get ASCII art data (contains GraphQL framework text)
val body = response.bodyAsText()
body.contains("GraphQL Data Pipeline Framework") shouldBe true
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change here too if you change it.

@fireboy1919 fireboy1919 force-pushed the wphillips/ktor-koin-di branch 3 times, most recently from deec9e6 to 81a1337 Compare December 23, 2025 19:47
Rusty Phillips added 10 commits January 7, 2026 16:06
Add a new demo application demonstrating Micronaut integration with
Viaduct's serve module. Key features:

- MicronautServerProvider: Starts only Micronaut's ApplicationContext
  (DI container) without the HTTP server for fast development iteration
- MicronautTenantCodeInjector: Bridges Micronaut DI with Viaduct resolvers
- ViaductConfiguration: Factory for creating Viaduct bean with DI support

This enables fast startup times during development by avoiding full
Micronaut HTTP server initialization while still providing full
dependency injection for resolvers.

Structure:
- serve/MicronautServerProvider.kt - ViaductServer integration
- injector/ViaductConfiguration.kt - Viaduct bean factory
- injector/MicronautTenantCodeInjector.kt - DI bridge
- resolvers/ - Sample resolver implementations
…startup

Use ApplicationContext.builder().packages() to limit Micronaut's
classpath scanning to only the necessary packages:
- com.example.viadapp.injector (ViaductConfiguration, TenantCodeInjector)
- com.example.viadapp.resolvers (Resolver implementations)

This avoids loading controllers, filters, HTTP server components, and
other beans that aren't needed for serve mode, resulting in faster
startup times.
Move serve runtime code from gradle-plugins/application-plugin to a
standalone serve/ module that publishes com.airbnb.viaduct:serve artifact.

This enables micronaut-starter and other apps to depend on the serve
runtime classes (ViaductServerProvider, ViaductServerConfiguration)
when building in isolation with mavenLocal.

- Create serve/ module with viaduct-publishing convention
- Move serve source and test files from application-plugin
- Update application-plugin to depend on libs.viaduct.serve
- Add serve module to included-builds/core/settings.gradle.kts
- Add dependency substitution in root settings.gradle.kts
- Update micronaut-starter to use mavenLocal and correct version
- Rename ViaductServerProvider interface to ViaductProvider
- Rename MicronautServerProvider to MicronautViaductProvider
- Reorganize micronaut-starter with dev/production source sets:
  - Production code in src/main/kotlin/.../production/
  - Dev-only code in src/dev/kotlin/.../dev/
  - viaduct-serve dependency only included in dev builds
- Update version to 0.16.0-SNAPSHOT
- Add micronaut-starter to version sync scripts and tests
- Update documentation with new structure and build configuration
…ector

Implements Koin-based dependency injection for the ktor-starter demo app,
demonstrating how to use a DI framework as the source of truth for resolver
discovery and instantiation (analogous to Spring in starwars demo).

Key components:
- KoinTenantCodeInjector: implements TenantCodeInjector, delegates to Koin
- KoinTenantResolverClassFinder: returns resolvers from explicit set (no scanning)
- KoinTenantResolverClassFinderFactory: creates finders for packages
- viaductModule: registers Viaduct singleton configured with Koin-based DI
- resolversModule: registers services and resolver factories
- resolverClasses set: explicit registry for resolver discovery

Example implementation:
- AsciiArtService: loads ASCII art from resources
- AsciiArtResolver: uses constructor injection via Koin
- asciiArt query in GraphQL schema

To add a new resolver:
1. Add class to resolverClasses set
2. Register as factory in resolversModule
Remove KoinTenantResolverClassFinder and KoinTenantResolverClassFinderFactory.
Use Viaduct's default classpath scanning for resolver discovery.

Koin is now only used for instantiation via KoinTenantCodeInjector,
which enables constructor injection of dependencies into resolvers.
Register Koin instance itself in the module so it can be injected.
Use get() for all dependency injection rather than explicit getKoin() calls.
- Change tagline to "Data-Oriented Service Mesh"
- Remove mavenLocal() from repository configurations
Remove property-based injection that caused JVM signature clash between
the generated getter and the interface method getViaduct().
@fireboy1919 fireboy1919 force-pushed the wphillips/ktor-koin-di branch from 6da9289 to cf67faa Compare January 7, 2026 21:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants