Documentation ¶
Index ¶
- Constants
- Variables
- func CheckStatus(ctx context.Context) (time.Duration, error)
- func GetAsset(context, name string) (*model.Asset, error)
- func InitDynamicAssetFS(fsURL string) error
- func ListAssets() (map[string][]*model.Asset, error)
- func RegisterCustomExternals(opts []model.AssetOption, maxTryCount int) error
- func RemoveAsset(context, name string) error
- type AferoFS
- func (a *AferoFS) Add(context, name string, asset *model.Asset) error
- func (a *AferoFS) CheckStatus(_ context.Context) (time.Duration, error)
- func (a *AferoFS) Get(context, name string) ([]byte, error)
- func (a *AferoFS) GetAssetFolderName(context, name string) string
- func (a *AferoFS) List() (map[string][]*model.Asset, error)
- func (a *AferoFS) Remove(context, name string) error
- type AssetsFS
- type SwiftFS
- func (s *SwiftFS) Add(context, name string, asset *model.Asset) error
- func (s *SwiftFS) CheckStatus(ctx context.Context) (time.Duration, error)
- func (s *SwiftFS) Get(context, name string) ([]byte, error)
- func (s *SwiftFS) List() (map[string][]*model.Asset, error)
- func (s *SwiftFS) Remove(context, name string) error
Constants ¶
const DynamicAssetsContainerName = "__dyn-assets__"
DynamicAssetsContainerName is the Swift container name for dynamic assets
const DynamicAssetsFolderName = "dyn-assets"
DynamicAssetsFolderName is the folder name for dynamic assets
Variables ¶
var ErrDynAssetNotFound = errors.New("Dynamic asset was not found")
ErrDynAssetNotFound is the error returned when a dynamic asset cannot be found.
Functions ¶
func CheckStatus ¶
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 InitDynamicAssetFS ¶
InitDynamicAssetFS initializes the dynamic asset FS.
func ListAssets ¶
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 ¶
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 (*AferoFS) CheckStatus ¶
func (*AferoFS) GetAssetFolderName ¶
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.