Implemented health checker for textures provider from Mojang's API

This commit is contained in:
ErickSkrauch
2020-04-30 23:16:22 +03:00
parent 2ea094bbf6
commit 4c21fc5c90
7 changed files with 111 additions and 24 deletions

View File

@@ -189,6 +189,7 @@ func newMojangTexturesBatchUUIDsProviderFullBusStrategy(config *viper.Viper) *mo
}
func newMojangTexturesRemoteUUIDsProvider(
container *di.Container,
config *viper.Viper,
emitter mojangtextures.Emitter,
) (*mojangtextures.RemoteApiUuidsProvider, error) {
@@ -197,6 +198,20 @@ func newMojangTexturesRemoteUUIDsProvider(
return nil, fmt.Errorf("unable to parse remote url: %w", err)
}
if err := container.Provide(func(emitter es.Subscriber, config *viper.Viper) *namedHealthChecker {
config.SetDefault("healthcheck.mojang_api_textures_provider_cool_down_duration", time.Minute+10*time.Second)
return &namedHealthChecker{
Name: "mojang-api-textures-provider-response-checker",
Checker: es.MojangApiTexturesProviderResponseChecker(
emitter,
config.GetDuration("healthcheck.mojang_api_textures_provider_cool_down_duration"),
),
}
}); err != nil {
return nil, err
}
return &mojangtextures.RemoteApiUuidsProvider{
Emitter: emitter,
Url: *remoteUrl,