Files
schreifuchs.ch/internal/components/images/resorce.go
T
schreifuchs fca1030e1a
/ publish (push) Successful in 3m9s
feat: limit image request
2026-03-07 20:26:53 +01:00

34 lines
626 B
Go

package images
import (
"os"
"github.com/valkey-io/valkey-go"
"golang.org/x/sync/semaphore"
)
type Options struct {
Width int // max width, 0 is unlimited
Height int // max Height, 0 is unlimited
Quality int // quality of the output jpeg
}
type Service struct {
fs fileSystem
cache valkey.Client
seph *semaphore.Weighted
}
func New(fs fileSystem, cache valkey.Client, maxConcurency int64) *Service {
return &Service{
fs: fs,
cache: cache,
seph: semaphore.NewWeighted(maxConcurency),
}
}
type fileSystem interface {
Read(path string) ([]byte, error)
Stat(path string) (os.FileInfo, error)
}