Make Mojang profiles provider cancellable

This commit is contained in:
ErickSkrauch
2024-02-07 01:36:18 +01:00
parent 10c11bc060
commit bc4d714112
12 changed files with 320 additions and 204 deletions

View File

@@ -1,5 +1,7 @@
package mojang
import "context"
type MojangUuidsStorage interface {
// The second argument must be returned as a incoming username in case,
// when cached result indicates that there is no Mojang user with provided username
@@ -13,7 +15,7 @@ type UuidsProviderWithCache struct {
Storage MojangUuidsStorage
}
func (p *UuidsProviderWithCache) GetUuid(username string) (*ProfileInfo, error) {
func (p *UuidsProviderWithCache) GetUuid(ctx context.Context, username string) (*ProfileInfo, error) {
uuid, foundUsername, err := p.Storage.GetUuidForMojangUsername(username)
if err != nil {
return nil, err
@@ -27,7 +29,7 @@ func (p *UuidsProviderWithCache) GetUuid(username string) (*ProfileInfo, error)
return nil, nil
}
profile, err := p.Provider.GetUuid(username)
profile, err := p.Provider.GetUuid(ctx, username)
if err != nil {
return nil, err
}