assets

package
v0.14.4 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2018 License: AGPL-3.0 Imports: 10 Imported by: 30

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterType

func RegisterType(name AssetType, manageAsSet bool, reader AssetReader)

RegisterType registers a new asset type for use with this cache

Types

type AssetCache

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

AssetCache fetches and caches assets for the engine

func NewAssetCache

func NewAssetCache(maxSize int64, pruneItems int) *AssetCache

NewAssetCache creates a new asset cache

func (*AssetCache) Include

func (c *AssetCache) Include(data json.RawMessage) error

Include loads assets from the given raw JSON into the cache

func (*AssetCache) Shutdown

func (c *AssetCache) Shutdown()

Shutdown shuts down this asset cache

type AssetReader

type AssetReader func(data json.RawMessage) (interface{}, error)

AssetReader is a function capable of reading an asset type from JSON

type AssetServer

type AssetServer interface {
	IsTypeSupported(AssetType) bool
	GetAsset(AssetType, string) (interface{}, error)
}

AssetServer describes the asset server we'll fetch missing assets from

func NewAssetServer

func NewAssetServer(authToken string, typeURLs map[AssetType]string, httpClient *utils.HTTPClient, cache *AssetCache) AssetServer

NewAssetServer creates a new asset server

func ReadAssetServer

func ReadAssetServer(authToken string, httpClient *utils.HTTPClient, cache *AssetCache, data json.RawMessage) (AssetServer, error)

ReadAssetServer reads an asset server fronm the given JSON

type AssetType

type AssetType string

AssetType is the unique slug for an asset type

type MockAssetServer

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

func NewMockAssetServer

func NewMockAssetServer(typeURLs map[AssetType]string, cache *AssetCache) *MockAssetServer

NewMockAssetServer creates a new mocked asset server for testing

func (*MockAssetServer) GetAsset

func (s *MockAssetServer) GetAsset(itemType AssetType, itemUUID string) (interface{}, error)

GetAsset returns either a single item or the set of items

func (*MockAssetServer) IsTypeSupported

func (s *MockAssetServer) IsTypeSupported(itemType AssetType) bool

IsTypeSupported returns whether the given asset item type is supported

func (*MockAssetServer) MarshalJSON

func (s *MockAssetServer) MarshalJSON() ([]byte, error)

MarshalJSON marshals this mock asset server into JSON

func (*MockAssetServer) MockResponse

func (s *MockAssetServer) MockResponse(url string, response json.RawMessage)

func (*MockAssetServer) MockedRequests

func (s *MockAssetServer) MockedRequests() []string

Jump to

Keyboard shortcuts

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