Gábor Török
02/28/2025, 6:48 PMDefaultHttpBuildCacheServiceFactory
and HttpBuildCacheRequestCustomizer
.
my question is: is there a more straightforward way to do this? see my current implementation for the factory in the thread.Gábor Török
02/28/2025, 6:50 PMclass FallbackBuildCacheServiceFactory(
private val httpBuildCacheServiceFactory: DefaultHttpBuildCacheServiceFactory,
): BuildCacheServiceFactory<FallbackBuildCache> {
@Inject
constructor(
sslContextFactory: SslContextFactory,
requestCustomizer: HttpBuildCacheRequestCustomizer,
httpClientHelperFactory: HttpClientHelper.Factory,
): this(DefaultHttpBuildCacheServiceFactory(sslContextFactory, requestCustomizer, httpClientHelperFactory))
override fun createBuildCacheService(
configuration: FallbackBuildCache,
describer: BuildCacheServiceFactory.Describer,
): BuildCacheService {
return FallbackBuildCacheService(
devCache = httpBuildCacheServiceFactory.createBuildCacheService(
configuration.devCache!!,
describer,
),
prodCache = httpBuildCacheServiceFactory.createBuildCacheService(
configuration.prodCache!!,
describer,
),
)
}
}
it needs to create an instance of DefaultHttpBuildCacheServiceFactory
to be able to initialize the http caches that will be used with the fallback.Vampire
02/28/2025, 11:13 PMGábor Török
02/28/2025, 11:40 PMVampire
02/28/2025, 11:50 PMGábor Török
03/03/2025, 6:20 PMVampire
03/04/2025, 1:58 AMDefaultHttpBuildCacheServiceFactory
to be able to initialize the http caches that will be used with the fallback.
Why?
Can't you do it something like
open class FallbackBuildCache : BuildCache {
var devCache: HttpBuildCache? = null
var prodCache: HttpBuildCache? = null
override fun isEnabled(): Boolean = true
override fun setEnabled(enabled: Boolean) = Unit
override fun isPush(): Boolean = false
override fun setPush(enabled: Boolean) = Unit
}
class FallbackBuildCacheService(devCache: BuildCacheService, prodCache: BuildCacheService) : BuildCacheService {
override fun load(key: BuildCacheKey, reader: BuildCacheEntryReader): Boolean = TODO("Not yet implemented")
override fun store(key: BuildCacheKey, writer: BuildCacheEntryWriter) = TODO("Not yet implemented")
override fun close() = TODO("Not yet implemented")
}
class FallbackBuildCacheServiceFactory(
private val httpBuildCacheServiceFactory: BuildCacheServiceFactory<HttpBuildCache>,
) : BuildCacheServiceFactory<FallbackBuildCache> {
override fun createBuildCacheService(
configuration: FallbackBuildCache,
describer: BuildCacheServiceFactory.Describer,
): BuildCacheService {
return FallbackBuildCacheService(
devCache = httpBuildCacheServiceFactory.createBuildCacheService(
configuration.devCache!!,
describer,
),
prodCache = httpBuildCacheServiceFactory.createBuildCacheService(
configuration.prodCache!!,
describer,
),
)
}
}
buildCache {
registerBuildCacheService<FallbackBuildCache>(FallbackBuildCacheServiceFactory::class)
remote<FallbackBuildCache> {
devCache = remote<HttpBuildCache> {
url = uri("...")
}
prodCache = remote<HttpBuildCache>() {
url = uri("...")
}
}
}
?Gábor Török
03/04/2025, 2:22 AMBuildCacheServiceFactory<HttpBuildCache>
:
Unable to determine constructor argument #1: missing parameter of type BuildCacheServiceFactory, or no service of type BuildCacheServiceFactory<HttpBuildCache>.
Vampire
03/04/2025, 2:28 AMremote
call order, I see. 😞Vampire
03/04/2025, 2:30 AMPUT
and GET
request.