resources

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2025 License: Apache-2.0 Imports: 17 Imported by: 2

Documentation

Index

Constants

View Source
const (
	MetadataRoot = "root"
	MetadataPath = "path"
	MetadataType = "type"
)
View Source
const BatchSize = 100
View Source
const JsonName = "resource.manifest"

Variables

This section is empty.

Functions

func AddFilesystem

func AddFilesystem(name string, filesystem fs.FS)

func GetFilesystem

func GetFilesystem(name string) fs.FS

func GetSupportedResourceTypes

func GetSupportedResourceTypes() []string

func KeyFromPath

func KeyFromPath(p string) string

func Load

func Load(ctx finch.Context, handles ...ResourceHandle)

func LoadData

func LoadData(ctx finch.Context, key string, metadata *Metadata) ([]byte, error)

func LoadManifest

func LoadManifest(ctx finch.Context, p string)

func RegisterSystem

func RegisterSystem(system ResourceSystem)

Types

type Manifest

type Manifest map[string]*Metadata

func GenerateManifest

func GenerateManifest(ctx finch.Context, root string) Manifest

func GetManifest

func GetManifest() Manifest

type Metadata

type Metadata struct {
	Root       string
	Path       string
	Type       string
	Properties map[string]any
}

func (Metadata) MarshalJSON

func (m Metadata) MarshalJSON() ([]byte, error)

func (*Metadata) UnmarshalJSON

func (m *Metadata) UnmarshalJSON(data []byte) error

type ResourceHandle

type ResourceHandle string

ResourceHandle provides an accessor for information about a specific resource, including its key, metadata, and loaded state.

ResourceHandles are used throughout the resource management framework to reference and manage individual resources. They encapsulate the resource key and provide methods to access associated metadata and check if the resource is currently loaded.

func (ResourceHandle) IsLoaded

func (r ResourceHandle) IsLoaded() bool

func (ResourceHandle) Key

func (r ResourceHandle) Key() string

func (ResourceHandle) Metadata

func (r ResourceHandle) Metadata() (*Metadata, bool)

type ResourceSystem

type ResourceSystem interface {
	ResourceTypes() []string
	Type() ResourceSystemType

	Load(ctx finch.Context, handle ResourceHandle) error
	Unload(ctx finch.Context, handle ResourceHandle) error
	GetDependencies(ctx finch.Context, handle ResourceHandle) []ResourceHandle

	GenerateMetadata(ctx finch.Context, key string, metadata *Metadata) error
	IsLoaded(handle ResourceHandle) bool
}

ResourceSystem defines a system that can load and manage resources of specific types.

Each ResourceSystem must implement this interface to be registered and used within the resource management framework. ResourceSystems are responsible for loading, unloading, and providing metadata properties for resources of the types they support. The resource management framework loads large numbers of resources in batches, so ResourceSystems should be designed to handle concurrent load requests efficiently.

func GetSystem

func GetSystem(st ResourceSystemType) ResourceSystem

func SystemForType

func SystemForType(rt string) ResourceSystem

type ResourceSystemType

type ResourceSystemType uint64

func NewResourceSystemKey

func NewResourceSystemKey[T ResourceSystem]() ResourceSystemType

Jump to

Keyboard shortcuts

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