InsertKoinIO / koin

Koin - a pragmatic lightweight dependency injection framework for Kotlin & Kotlin Multiplatform
https://insert-koin.io
Apache License 2.0
8.89k stars 707 forks source link

Ktor 3.0 support #1716

Open lexa-diky opened 9 months ago

lexa-diky commented 9 months ago

Is your feature request related to a problem? Please describe. JB recently released Ktor 3.0.0-betta1. Currently Ktor does not support it, JB changed API. In particular access to monitor now done via Application not Environment, maybe there is more incompatibilities.

Describe the solution you'd like Separate ktor-3 module to have both ktor 2. and 3.

Target Koin project ktor

Nek-12 commented 8 months ago

Can second this, but I would prefer a simple dependency upgrade instead of separate artifact

Nek-12 commented 8 months ago

The workaround for now is to copy everything from the koin Ktor sources and fix the compile time error

lexa-diky commented 8 months ago

If koin goes with single module approach, it will break comp with ktor-2, and I guess bunch of people will not update for a while

Nek-12 commented 8 months ago

The only updates for the past months have been dependency updates... The whole library is 2 files

arnaudgiuliani commented 8 months ago

Yes, great topic coming đź‘Ť

Nek-12 commented 8 months ago

Can you please add ktor 3.0 support first before you refactor, add new stuff, and break something with the update you described in your article? @arnaudgiuliani

Changing one line of code, that is, so that we don't wait till Q4 2024 for this to get fixed

arnaudgiuliani commented 7 months ago

something I can setup for 3.6.0 - Q1 Seems that we need to separate both ktor & ktor3

FlyingYu-Z commented 3 months ago

Is there any solution now?

JoonasC commented 1 month ago

@arnaudgiuliani I would appreciate a solution for this, as I am currently unable to use SSE (server sent events) in my application due to it only being supported in Ktor 3.0.0. Let me know if I can speed up the work, maybe by making a PR?

fluxxion82 commented 3 weeks ago

I'm am interested in this as well and will be watching for updates.

Nek-12 commented 3 weeks ago

@fluxxion82 Just copy all sources of the Ktor module to your project. This hasn't been addressed in almost a year and the author has no intention of doing so.

KevinMeneses commented 2 weeks ago

it would be nice to get support for this

hashir1296 commented 1 week ago

Still waiting for this. No solutions of as of yet?

Nek-12 commented 1 week ago

Like I said, just copy and paste all sources of Koin-ktor module into your project and fix the breaking changes. Already using this approach in prod

hashir1296 commented 1 week ago

Like I said, just copy and paste all sources of Koin-ktor module into your project and fix the breaking changes. Already using this approach in prod

Pardon but can you please briefly describe what do you mean by this? Earlier we were using koin as:

install(Koin) {
        slf4jLogger()
        modules(appModule)
    }

How do i migrate from this?

hashir1296 commented 1 week ago

Like I said, just copy and paste all sources of Koin-ktor module into your project and fix the breaking changes. Already using this approach in prod

Pardon but can you please briefly describe what do you mean by this? Earlier we were using koin as:

install(Koin) {
        slf4jLogger()
        modules(appModule)
    }

How do i migrate from this?

Figured it out, basically

  1. Goto this link: https://github.com/InsertKoinIO/koin/tree/main/projects/ktor/koin-ktor
  2. Manually copy/paste all files under koin-ktor package (I copied only KoinPlugin)
  3. In your install block, use your koin plugin instead of ktor's

Warning: This is a workaround, with this:

  1. You will lose out on future Ktor or Koin updates
  2. You’ll need to keep an eye on both the Koin and Ktor projects for official updates that may render this workaround obsolete.