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.
ProcessPhotoProcessVideoProcessAudio
Each has a different workflow, which will be shown on this page later.
Currently, AssetProcessor depends on the following backend services:
MLServiceAssetService
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.Readerto process assets as streams. Ideally, onlyio.Readershould 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 aTaskto be gracefully stopped.Database Operations:It doesn't care about how the DB is operated; it always should callAssetServiceto update the database.Storage:It doesn't care about and should not be able to do anything withStorageor the file system, except reading queued files from thefilepathpassed through byTask.
Workflow
The top-level workflow for AssetProcessor is really simple.
- Read the asset's basic attributes from task info.
- Call
AssetServiceto create a new DB record for the asset. - Open an
io.Readerforsub-processorsfrom the staged file. - Pass the
io.Readertosub-processors.
