mirror of
https://github.com/elyby/chrly.git
synced 2024-11-26 16:51:59 +05:30
Simplify health checkers initialization
This commit is contained in:
parent
3f81a0c18a
commit
f58b980948
4
Gopkg.lock
generated
4
Gopkg.lock
generated
@ -65,7 +65,7 @@
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
digest = "1:c6d147728b7bf08b508b13c4547edfd72f900a2b8467b8a7e86d525badef268b"
|
||||
digest = "1:8c9f13aac9e92f3754ea591b39ada87b9f89f1e75c4b90ccbd0b1084069c436f"
|
||||
name = "github.com/goava/di"
|
||||
packages = [
|
||||
".",
|
||||
@ -73,7 +73,7 @@
|
||||
"internal/stacktrace",
|
||||
]
|
||||
pruneopts = ""
|
||||
revision = "30d61f45552a08a92f8aa54eaad3e7495f091260"
|
||||
revision = "1eb6eb721bf050edff0efbf15c31636def701b4b"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:65c7ed49d9f36dd4752e43013323fa9229db60b29aa4f5a75aaecda3130c74e2"
|
||||
|
@ -76,7 +76,7 @@ func newHandlerFactory(
|
||||
|
||||
// Resolve health checkers last, because all the services required by the application
|
||||
// must first be initialized and each of them can publish its own checkers
|
||||
var healthCheckers []namedHealthCheckerInterface
|
||||
var healthCheckers []*namedHealthChecker
|
||||
if container.Has(&healthCheckers) {
|
||||
if err := container.Resolve(&healthCheckers); err != nil {
|
||||
return nil, err
|
||||
@ -84,7 +84,7 @@ func newHandlerFactory(
|
||||
|
||||
checkersOptions := make([]healthcheck.Option, len(healthCheckers))
|
||||
for i, checker := range healthCheckers {
|
||||
checkersOptions[i] = healthcheck.WithChecker(checker.GetName(), checker.GetChecker())
|
||||
checkersOptions[i] = healthcheck.WithChecker(checker.Name, checker.Checker)
|
||||
}
|
||||
|
||||
router.Handle("/healthcheck", healthcheck.Handler()).Methods("GET")
|
||||
@ -142,20 +142,7 @@ func mount(router *mux.Router, path string, handler http.Handler) {
|
||||
)
|
||||
}
|
||||
|
||||
type namedHealthCheckerInterface interface {
|
||||
GetName() string
|
||||
GetChecker() healthcheck.Checker
|
||||
}
|
||||
|
||||
type namedHealthChecker struct {
|
||||
Name string
|
||||
Checker healthcheck.Checker
|
||||
}
|
||||
|
||||
func (c *namedHealthChecker) GetName() string {
|
||||
return c.Name
|
||||
}
|
||||
|
||||
func (c *namedHealthChecker) GetChecker() healthcheck.Checker {
|
||||
return c.Checker
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ func newMojangTexturesBatchUUIDsProvider(
|
||||
config.GetDuration("healthcheck.mojang_batch_uuids_provider_cool_down_duration"),
|
||||
),
|
||||
}
|
||||
}, di.As(new(namedHealthCheckerInterface)), di.WithName("mojangBatchUuidsProviderResponseChecker")); err != nil {
|
||||
}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@ -103,7 +103,7 @@ func newMojangTexturesBatchUUIDsProvider(
|
||||
config.GetInt("healthcheck.mojang_batch_uuids_provider_queue_length_limit"),
|
||||
),
|
||||
}
|
||||
}, di.As(new(namedHealthCheckerInterface)), di.WithName("mojangBatchUuidsProviderQueueLengthChecker")); err != nil {
|
||||
}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
@ -227,7 +227,7 @@ func (ctx *Skinsystem) signedTexturesHandler(response http.ResponseWriter, reque
|
||||
}
|
||||
|
||||
responseData.Props = append(responseData.Props, &mojang.Property{
|
||||
Name: getStringOrDefault(ctx.TexturesExtraParamName, "chrly"),
|
||||
Name: getStringOrDefault(ctx.TexturesExtraParamName, "chrly"), // TODO: extract to the default param value
|
||||
Value: getStringOrDefault(ctx.TexturesExtraParamValue, "how do you tame a horse in Minecraft?"),
|
||||
})
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user