assetservice

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2024 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TopicAssetSaved = "asset_service.asset_saved"
)

Variables

This section is empty.

Functions

func NewFileService

func NewFileService(workingDirectory string, log *slog.Logger) fileService

func NewHTTPClient

func NewHTTPClient() *httpClientImpl

Types

type Asset

type Asset struct {
	// URL is the url where this asset was found
	URL string
	// Content is the text content of the asset
	Content string
	// Namespace is the namespace folder where this file should be stored (e.g. raw, optimized, source code)
	Namespace string
	// ContentType is the type of the content of this file
	ContentType string
	// Parent is the asset that loaded the current asset, nil if it doesn't exist. (e.g. html page loading a js script)
	Parent *Asset

	// Path is the path where this asset was stored
	Path string
}

func (Asset) GetParentURL

func (a Asset) GetParentURL() *string

type AssetService

type AssetService interface {
	AsyncSaveAsset(ctx context.Context, asset Asset)
	AsyncFetchAndSave(ctx context.Context, req AsyncFetchAndSaveRequest)
}

func NewAssetService

func NewAssetService(cfg AssetServiceConfig) AssetService

type AssetServiceConfig

type AssetServiceConfig struct {
	EventBus         eventbus.EventBus
	SaveConcurrency  int
	FetchConcurrency int
	Logger           *slog.Logger
	FileService      fileService
	HTTPClient       httpClient
}

type AsyncFetchAndSaveRequest

type AsyncFetchAndSaveRequest struct {
	URL         string
	ParentURL   *string
	ContentType string
	Namespace   string
}

type EventAssetSaved

type EventAssetSaved struct {
	Asset Asset
}

Jump to

Keyboard shortcuts

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