Documentation
¶
Index ¶
- Constants
- Variables
- func DeleteImageStatus(imageUUID string) error
- func ExtractMetadata(image *models.Image, filePath string) error
- func GetImagePath(imageModel *models.Image, format string, size string) string
- func GetImageStatus(imageUUID string) (string, error)
- func GetImageStatusTimestamp(imageUUID string) (time.Time, error)
- func IsImageProcessingComplete(imageUUID string) bool
- func ProcessImage(image *models.Image) error
- func SetImageStatus(imageUUID string, status string) error
- func SetImageStatusTimestamp(imageUUID string, timestamp time.Time, currentStatus string) error
- type DeleteCacheFunc
- type GetCacheFunc
- type GetIntCacheFunc
- type ImageProcessor
- type ProcessJob
- type SetCacheFunc
Constants ¶
const ( SmallThumbnailSize = 200 MediumThumbnailSize = 500 )
Thumbnail sizes
const ( ImageStatusKeyFormat = "image:status:%s" // Format: image:status:<uuid> ImageStatusTimestampKeyFormat = "image:status:timestamp:%s" // Format: image:status:timestamp:<uuid> )
Cache key format for image processing status
const ( STATUS_PENDING = "pending" // Image is queued for processing STATUS_PROCESSING = "processing" // Image is currently being processed STATUS_COMPLETED = "completed" // Image processing is complete STATUS_FAILED = "failed" // Image processing failed )
Status constants for image processing
const ( PENDING_TTL = 30 * time.Minute // Längere Zeit für unverarbeitete Bilder PROCESSING_TTL = 30 * time.Minute // Längere Zeit für Bilder in Verarbeitung COMPLETED_TTL = 5 * time.Minute // Kurze Zeit für erfolgreich verarbeitete Bilder FAILED_TTL = 1 * time.Hour // Längere Zeit für fehlgeschlagene Bilder (für Fehleranalyse) )
TTL für verschiedene Status
Variables ¶
var ( // Processing limits to avoid overloading the server MaxWorkers = 3 Throttler = make(chan struct{}, MaxWorkers) // Image quality settings for WebP conversion - can be adjusted via config WebPQuality = 90 // Default quality for WebP conversion (1-100) SmallThumbSize = 200 MediumThumbSize = 500 // Directory Paths OriginalDir = "uploads/original" VariantsDir = "uploads/variants" // Tool availability flags IsPNGQuantAvailable = false IsJPEGOptimAvailable = false IsFFmpegAvailable = false // Function for database updates - can be mocked for testing UpdateImageRecordFunc = updateImageRecord )
Directory paths and worker settings
var ( SetCacheImplementation SetCacheFunc = cache.Set GetCacheImplementation GetCacheFunc = cache.Get GetIntCacheImplementation GetIntCacheFunc = cache.GetInt DeleteCacheImplementation DeleteCacheFunc = cache.Delete )
Default implementations that use the actual cache package
Functions ¶
func DeleteImageStatus ¶
DeleteImageStatus deletes all status entries for an image from the cache
func ExtractMetadata ¶
ExtractMetadata extracts EXIF metadata from an image file
func GetImagePath ¶
GetImagePath returns the path to a specific image variant based on format and size.
func GetImageStatus ¶
GetImageStatus retrieves the processing status of an image from the cache
func GetImageStatusTimestamp ¶
GetImageStatusTimestamp gets the timestamp when the status was set
func IsImageProcessingComplete ¶
IsImageProcessingComplete checks if image processing is complete using cache and DB fallback.
func ProcessImage ¶
ProcessImage queues an image for processing (convenience function)
func SetImageStatus ¶
SetImageStatus sets the processing status of an image in the cache
Types ¶
type DeleteCacheFunc ¶
Function types for cache operations (for dependency injection in tests)
type GetCacheFunc ¶
Function types for cache operations (for dependency injection in tests)
type GetIntCacheFunc ¶
Function types for cache operations (for dependency injection in tests)
type ImageProcessor ¶
type ImageProcessor struct {
// contains filtered or unexported fields
}
ImageProcessor handles image processing with a worker pool
func GetProcessor ¶
func GetProcessor() *ImageProcessor
GetProcessor returns the singleton image processor instance
func (*ImageProcessor) EnqueueImage ¶
func (p *ImageProcessor) EnqueueImage(image *models.Image) error
EnqueueImage adds an image to the processing queue
func (*ImageProcessor) Stop ¶
func (p *ImageProcessor) Stop()
Stop gracefully shuts down the worker pool
type ProcessJob ¶
ProcessJob represents a single image processing job