mirror of
https://github.com/elyby/chrly.git
synced 2025-05-31 14:11:51 +05:30
Go, Go Context! Added context transfer literally everywhere
This commit is contained in:
@@ -5,9 +5,9 @@ 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
|
||||
GetUuidForMojangUsername(username string) (foundUuid string, foundUsername string, err error)
|
||||
GetUuidForMojangUsername(ctx context.Context, username string) (foundUuid string, foundUsername string, err error)
|
||||
// An empty uuid value can be passed if the corresponding account has not been found
|
||||
StoreMojangUuid(username string, uuid string) error
|
||||
StoreMojangUuid(ctx context.Context, username string, uuid string) error
|
||||
}
|
||||
|
||||
type UuidsProviderWithCache struct {
|
||||
@@ -16,7 +16,7 @@ type UuidsProviderWithCache struct {
|
||||
}
|
||||
|
||||
func (p *UuidsProviderWithCache) GetUuid(ctx context.Context, username string) (*ProfileInfo, error) {
|
||||
uuid, foundUsername, err := p.Storage.GetUuidForMojangUsername(username)
|
||||
uuid, foundUsername, err := p.Storage.GetUuidForMojangUsername(ctx, username)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -41,7 +41,7 @@ func (p *UuidsProviderWithCache) GetUuid(ctx context.Context, username string) (
|
||||
wellCasedUsername = profile.Name
|
||||
}
|
||||
|
||||
_ = p.Storage.StoreMojangUuid(wellCasedUsername, freshUuid)
|
||||
_ = p.Storage.StoreMojangUuid(ctx, wellCasedUsername, freshUuid)
|
||||
|
||||
return profile, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user