feat: Add Koin module for clustering network service
This commit introduces a Koin module, `clusterNetworkModule`, to provide instances for network-related dependencies for the clustering feature.
Specifically, it provides:
- An `OkHttpClient` instance with a 5-second connection timeout.
- A `Retrofit` instance configured with a base URL ("http://labai.polinema.ac.id:5050/"), the provided `OkHttpClient`, and `GsonConverterFactory`.
- A `ClusteringService` instance created by the `Retrofit` instance.
This commit is contained in:
parent
6a103f7680
commit
acc732871f
|
|
@ -0,0 +1,26 @@
|
||||||
|
package com.syaroful.agrilinkvocpro.growth_recipe_feature.di
|
||||||
|
|
||||||
|
import com.syaroful.agrilinkvocpro.growth_recipe_feature.data.network.ClusteringService
|
||||||
|
import okhttp3.OkHttpClient
|
||||||
|
import org.koin.dsl.module
|
||||||
|
import retrofit2.Retrofit
|
||||||
|
import retrofit2.converter.gson.GsonConverterFactory
|
||||||
|
import java.util.concurrent.TimeUnit
|
||||||
|
|
||||||
|
val clusterNetworkModule = module {
|
||||||
|
single {
|
||||||
|
OkHttpClient.Builder()
|
||||||
|
.connectTimeout(5, TimeUnit.SECONDS)
|
||||||
|
.build()
|
||||||
|
}
|
||||||
|
|
||||||
|
single {
|
||||||
|
Retrofit.Builder()
|
||||||
|
.baseUrl("http://labai.polinema.ac.id:5050/")
|
||||||
|
.client(get())
|
||||||
|
.addConverterFactory(GsonConverterFactory.create())
|
||||||
|
.build()
|
||||||
|
}
|
||||||
|
|
||||||
|
single<ClusteringService> { get<Retrofit>().create(ClusteringService::class.java) }
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user