mirror of
https://github.com/elyby/chrly.git
synced 2024-11-30 02:32:19 +05:30
31 lines
630 B
Go
31 lines
630 B
Go
package eventsubscribers
|
|
|
|
import (
|
|
"context"
|
|
"sync"
|
|
|
|
"github.com/etherlabsio/healthcheck"
|
|
|
|
"github.com/elyby/chrly/api/mojang"
|
|
)
|
|
|
|
func MojangBatchUuidsProviderChecker(dispatcher Subscriber) healthcheck.CheckerFunc {
|
|
var mutex sync.Mutex
|
|
var lastCallErr error // TODO: need to reset this value after some time
|
|
dispatcher.Subscribe(
|
|
"mojang_textures:batch_uuids_provider:result",
|
|
func(usernames []string, profiles []*mojang.ProfileInfo, err error) {
|
|
mutex.Lock()
|
|
lastCallErr = err
|
|
mutex.Unlock()
|
|
},
|
|
)
|
|
|
|
return func(ctx context.Context) error {
|
|
mutex.Lock()
|
|
defer mutex.Unlock()
|
|
|
|
return lastCallErr
|
|
}
|
|
}
|