mojangtextures

package
v0.0.0-...-ad31fdb Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 22, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var HttpClient = &http.Client{
	Transport: &http.Transport{
		MaxIdleConnsPerHost: 1024,
	},
}

Functions

This section is empty.

Types

type BatchUuidsProvider

type BatchUuidsProvider struct {
	// contains filtered or unexported fields
}

func NewBatchUuidsProvider

func NewBatchUuidsProvider(
	context context.Context,
	strategy BatchUuidsProviderStrategy,
	emitter Emitter,
) *BatchUuidsProvider

func (*BatchUuidsProvider) GetUuid

func (ctx *BatchUuidsProvider) GetUuid(username string) (*mojang.ProfileInfo, error)

type BatchUuidsProviderStrategy

type BatchUuidsProviderStrategy interface {
	Queue(job *job)
	GetJobs(abort context.Context) <-chan *JobsIteration
}

type Emitter

type Emitter interface {
	dispatcher.Emitter
}

type FullBusStrategy

type FullBusStrategy struct {
	Delay time.Duration
	Batch int
	// contains filtered or unexported fields
}

func NewFullBusStrategy

func NewFullBusStrategy(delay time.Duration, batch int) *FullBusStrategy

func (*FullBusStrategy) GetJobs

func (ctx *FullBusStrategy) GetJobs(abort context.Context) <-chan *JobsIteration

Формально, это описание логики водителя маршрутки xD

func (*FullBusStrategy) Queue

func (ctx *FullBusStrategy) Queue(job *job)

type InMemoryTexturesStorage

type InMemoryTexturesStorage struct {
	GCPeriod time.Duration
	Duration time.Duration
	// contains filtered or unexported fields
}

func NewInMemoryTexturesStorage

func NewInMemoryTexturesStorage() *InMemoryTexturesStorage

func (*InMemoryTexturesStorage) GetTextures

func (*InMemoryTexturesStorage) Stop

func (s *InMemoryTexturesStorage) Stop()

func (*InMemoryTexturesStorage) StoreTextures

func (s *InMemoryTexturesStorage) StoreTextures(uuid string, textures *mojang.SignedTexturesResponse)

type JobsIteration

type JobsIteration struct {
	Jobs  []*job
	Queue int
	// contains filtered or unexported fields
}

func (*JobsIteration) Done

func (j *JobsIteration) Done()

type MojangApiTexturesProvider

type MojangApiTexturesProvider struct {
	Emitter
}

func (*MojangApiTexturesProvider) GetTextures

type NilProvider

type NilProvider struct {
}

func (*NilProvider) GetForUsername

func (p *NilProvider) GetForUsername(username string) (*mojang.SignedTexturesResponse, error)

type PeriodicStrategy

type PeriodicStrategy struct {
	Delay time.Duration
	Batch int
	// contains filtered or unexported fields
}

func NewPeriodicStrategy

func NewPeriodicStrategy(delay time.Duration, batch int) *PeriodicStrategy

func (*PeriodicStrategy) GetJobs

func (ctx *PeriodicStrategy) GetJobs(abort context.Context) <-chan *JobsIteration

func (*PeriodicStrategy) Queue

func (ctx *PeriodicStrategy) Queue(job *job)

type Provider

type Provider struct {
	Emitter
	UUIDsProvider
	TexturesProvider
	Storage
	// contains filtered or unexported fields
}

func (Provider) AddListener

func (c Provider) AddListener(username string, resultChan chan *broadcastResult) bool

Returns a boolean value, which will be true if the passed username didn't exist before

func (Provider) BroadcastAndRemove

func (c Provider) BroadcastAndRemove(username string, result *broadcastResult)

func (*Provider) GetForUsername

func (ctx *Provider) GetForUsername(username string) (*mojang.SignedTexturesResponse, error)

type RemoteApiUuidsProvider

type RemoteApiUuidsProvider struct {
	Emitter
	Url URL
}

func (*RemoteApiUuidsProvider) GetUuid

func (ctx *RemoteApiUuidsProvider) GetUuid(username string) (*mojang.ProfileInfo, error)

type SeparatedStorage

type SeparatedStorage struct {
	UUIDsStorage
	TexturesStorage
}

SeparatedStorage allows you to use separate storage engines to satisfy the Storage interface

func (*SeparatedStorage) GetTextures

func (s *SeparatedStorage) GetTextures(uuid string) (*mojang.SignedTexturesResponse, error)

func (*SeparatedStorage) GetUuid

func (s *SeparatedStorage) GetUuid(username string) (string, bool, error)

func (*SeparatedStorage) StoreTextures

func (s *SeparatedStorage) StoreTextures(uuid string, textures *mojang.SignedTexturesResponse)

func (*SeparatedStorage) StoreUuid

func (s *SeparatedStorage) StoreUuid(username string, uuid string) error

type Storage

type Storage interface {
	UUIDsStorage
	TexturesStorage
}

type TexturesProvider

type TexturesProvider interface {
	GetTextures(uuid string) (*mojang.SignedTexturesResponse, error)
}

type TexturesStorage

type TexturesStorage interface {
	// Error should not have nil value only if the repository failed to determine if there are any textures
	// for this uuid or not at all. If there is information about the absence of textures, nil nil should be returned
	GetTextures(uuid string) (*mojang.SignedTexturesResponse, error)
	// The nil value can be passed when there are no textures for the corresponding uuid and we know about it
	StoreTextures(uuid string, textures *mojang.SignedTexturesResponse)
}

TexturesStorage is a Mojang's textures storage, used as a values cache to avoid 429 errors

type UUIDsProvider

type UUIDsProvider interface {
	GetUuid(username string) (*mojang.ProfileInfo, error)
}

type UUIDsStorage

type UUIDsStorage interface {
	// The second argument indicates whether a record was found in the storage,
	// since depending on it, the empty value must be interpreted as "no cached record"
	// or "value cached and has an empty value"
	GetUuid(username string) (uuid string, found bool, err error)
	// An empty uuid value can be passed if the corresponding account has not been found
	StoreUuid(username string, uuid string) error
}

UUIDsStorage is a key-value storage of Mojang usernames pairs to its UUIDs, used to reduce the load on the account information queue

type UnexpectedRemoteApiResponse

type UnexpectedRemoteApiResponse struct {
	Response *http.Response
}

func (*UnexpectedRemoteApiResponse) Error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL