resource

package
Version: v0.5.4 Latest Latest
Warning

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

Go to latest
Published: May 18, 2018 License: BSD-3-Clause Imports: 3 Imported by: 17

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Get

func Get(id string) (interface{}, error)

Get gets the specified resource, id format is {type}:{id}"

func GetTypeFromID

func GetTypeFromID(id string) (string, error)

func Load

func Load(config *Config) error

Load specified resource into its corresponding Resource Manager

func RegisterManager

func RegisterManager(resourceType string, manager Manager) error

RegisterManager registers a resource manager for the specified type

Types

type Config

type Config struct {
	ID         string          `json:"id"`
	Compressed bool            `json:"compressed"`
	Data       json.RawMessage `json:"data"`
}

type Manager

type Manager interface {
	// LoadResources tells the manager to load the specified resource set
	LoadResource(config *Config) error

	// GetResource get the resource that corresponds to the specified id
	GetResource(id string) interface{}
}

ResourceManager interface

func GetManager

func GetManager(resourceType string) Manager

GetManager gets the manager for the specified resource type

type ResourcesConfig

type ResourcesConfig struct {
	Resources []*Config `json:"resources"`
}

Jump to

Keyboard shortcuts

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