dynamic

package
v0.0.0-...-a7c217f Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: AGPL-3.0 Imports: 21 Imported by: 4

Documentation

Index

Constants

View Source
const DynamicAssetsContainerName = "__dyn-assets__"

DynamicAssetsContainerName is the Swift container name for dynamic assets

View Source
const DynamicAssetsFolderName = "dyn-assets"

DynamicAssetsFolderName is the folder name for dynamic assets

Variables

View Source
var ErrDynAssetNotFound = errors.New("Dynamic asset was not found")

ErrDynAssetNotFound is the error returned when a dynamic asset cannot be found.

Functions

func CheckStatus

func CheckStatus(ctx context.Context) (time.Duration, error)

CheckStatus checks that the FS for dynamic asset is available, or returns an error if it is not the case. It also returns the latency.

func GetAsset

func GetAsset(context, name string) (*model.Asset, error)

GetAsset retrieves a raw asset from the dynamic FS and builds a fs.Asset

func InitDynamicAssetFS

func InitDynamicAssetFS(fsURL string) error

InitDynamicAssetFS initializes the dynamic asset FS.

func ListAssets

func ListAssets() (map[string][]*model.Asset, error)

ListAssets returns the list of the dynamic assets.

func RegisterCustomExternals

func RegisterCustomExternals(opts []model.AssetOption, maxTryCount int) error

RegisterCustomExternals ensures that the assets are in the Swift, and load them from their source if they are not yet available.

func RemoveAsset

func RemoveAsset(context, name string) error

RemoveAsset removes a dynamic asset from Swift

Types

type AferoFS

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

AferoFS is a wrapper around the spf13/afero filesystem.

It can be setup with two differents drivers:

  • [NewInMemory] use the in-memory driver. It should be used only for the tests as nothing is persisted.
  • NewOsFS use the OsFs driver. It will save the assets on the host filesystem.

func NewInMemoryFS

func NewInMemoryFS() *AferoFS

NewInMemoryFS instantiate a new AferoFS with the in-memeory driver.

This implementation loose every data after being clean up so it should be only used for the tests.

func NewOsFS

func NewOsFS(rootPath string) (*AferoFS, error)

NewOsFS instantiate a new AferoFS with the OsFS driver.

func (*AferoFS) Add

func (a *AferoFS) Add(context, name string, asset *model.Asset) error

func (*AferoFS) CheckStatus

func (a *AferoFS) CheckStatus(_ context.Context) (time.Duration, error)

func (*AferoFS) Get

func (a *AferoFS) Get(context, name string) ([]byte, error)

func (*AferoFS) GetAssetFolderName

func (a *AferoFS) GetAssetFolderName(context, name string) string

func (*AferoFS) List

func (a *AferoFS) List() (map[string][]*model.Asset, error)

func (*AferoFS) Remove

func (a *AferoFS) Remove(context, name string) error

type AssetsFS

type AssetsFS interface {
	Add(string, string, *model.Asset) error
	Get(string, string) ([]byte, error)
	Remove(string, string) error
	List() (map[string][]*model.Asset, error)
	CheckStatus(ctx context.Context) (time.Duration, error)
}

AssetsFS is the interface implemented by all the implementations handling assets.

At the moment there two separate implementations: - SwiftFS allowing to manage assets via an OpenStack Swift API. - AferoFS with NewOsFS allowing to manage assets directly on the host filesystem. - AferoFS with [NewInMemory] allowing to manage assets directly in a in-memory session.

type SwiftFS

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

SwiftFS is the Swift implementation of AssetsFS.

It save and fetch assets into/from any OpenStack Swift compatible API.

func NewSwiftFS

func NewSwiftFS() (*SwiftFS, error)

NewSwiftFS instantiate a new SwiftFS.

func (*SwiftFS) Add

func (s *SwiftFS) Add(context, name string, asset *model.Asset) error

func (*SwiftFS) CheckStatus

func (s *SwiftFS) CheckStatus(ctx context.Context) (time.Duration, error)

func (*SwiftFS) Get

func (s *SwiftFS) Get(context, name string) ([]byte, error)

func (*SwiftFS) List

func (s *SwiftFS) List() (map[string][]*model.Asset, error)

func (*SwiftFS) Remove

func (s *SwiftFS) Remove(context, name string) error

Jump to

Keyboard shortcuts

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