53 lines
1.4 KiB
Go
53 lines
1.4 KiB
Go
package image
|
|
|
|
import (
|
|
"io"
|
|
"time"
|
|
)
|
|
|
|
type VariantRepository interface {
|
|
List() ([]Variant, error)
|
|
Get(name string) (Variant, error)
|
|
Create(variant Variant) (Variant, error)
|
|
Update(variant Variant) (Variant, error)
|
|
Delete(name string) error
|
|
}
|
|
|
|
type VariantFileRepository interface {
|
|
Find(variantName string, sourceName string) (VariantFile, bool, error)
|
|
Save(file VariantFile) (VariantFile, error)
|
|
ListByVariant(variantName string) ([]VariantFile, error)
|
|
ListBySource(sourceName string) ([]VariantFile, error)
|
|
Delete(id uint32) error
|
|
Totals() (map[string]VariantFileTotals, error)
|
|
TotalsBySource() (map[string]VariantFileTotals, error)
|
|
}
|
|
|
|
type VariantCacheRepository interface {
|
|
UnusedTotals(filter UnusedFilter) (VariantFileTotals, error)
|
|
TopSources(limit int) ([]SourceTotals, error)
|
|
ListPage(filter VariantFileFilter, afterID uint32, limit int) ([]VariantFile, error)
|
|
}
|
|
|
|
type VariantUsageRepository interface {
|
|
Record(batch VariantUsageBatch) error
|
|
RejectedSince(day time.Time) (int, error)
|
|
}
|
|
|
|
type VariantUsageTracker interface {
|
|
RecordHit(variantName string, sourceName string)
|
|
RecordRejection()
|
|
Flush() error
|
|
}
|
|
|
|
type RenderedVariant struct {
|
|
Content []byte
|
|
ContentType string
|
|
}
|
|
|
|
type VariantRenderer interface {
|
|
DeclaredSize(source io.Reader) (width int, height int, err error)
|
|
Render(source io.Reader, settings VariantSettings) (RenderedVariant, error)
|
|
EncodableFormats() []VariantFormat
|
|
}
|