Processors - AssetProcessor
Author: Edwin Zhan, proofread by AI
Introduction
see server/internal/processors/asset_processor.go
AssetProcessor
depends on multiple services and storage systems. It is the core component responsible for handling all Assets
uploaded, scanned, or synced by users. Many sub-processors are implemented as member functions of the AssetProcessor
struct. They're responsible for more specific asset processing depending on different types of assets.
ProcessPhoto
ProcessVideo
ProcessAudio
Each has a different workflow, which will be shown on this page later.
Currently, AssetProcessor
depends on the following backend services:
MLService
AssetService
What does AssetProcessor
care about, and what does it not care about?
Care
TaskInfo:
It needs information passed by the task, like filename, filepath, filehash, owner ID, upload timestamp, etc.File:
It needs anio.Reader
to process assets as streams. Ideally, onlyio.Reader
should appear in all processing steps.
Don't Care
Task Enqueue and Dequeue:
It doesn't care about how tasks are managed; only context will be passed through all processing functions to allow aTask
to be gracefully stopped.Database Operations:
It doesn't care about how the DB is operated; it always should callAssetService
to update the database.Storage:
It doesn't care about and should not be able to do anything withStorage
or the file system, except reading queued files from thefilepath
passed through byTask
.
Workflow
The top-level workflow for AssetProcessor
is really simple.
- Read the asset's basic attributes from task info.
- Call
AssetService
to create a new DB record for the asset. - Open an
io.Reader
forsub-processors
from the staged file. - Pass the
io.Reader
tosub-processors
.