Documentation
¶
Index ¶
- Constants
- Variables
- type ImageRef
- type LocalStore
- func (s *LocalStore) DeleteAd(adID int) error
- func (s *LocalStore) DeleteUserAccount(userID int) error
- func (s *LocalStore) Get(adID, index int, suffix string) ([]byte, error)
- func (s *LocalStore) GetUserAccount(userID int) ([]byte, error)
- func (s *LocalStore) ListAd(adID int) ([]ImageRef, error)
- func (s *LocalStore) PresignGet(adID, index int, suffix string, expiry time.Duration) (string, error)
- func (s *LocalStore) PresignGetUserAccount(userID int, expiry time.Duration) (string, error)
- func (s *LocalStore) PresignPut(adID, index int, suffix string, expiry time.Duration) (string, error)
- func (s *LocalStore) PresignPutUserAccount(userID int, expiry time.Duration) (string, error)
- func (s *LocalStore) Put(adID, index int, suffix string, data []byte) error
- func (s *LocalStore) PutUserAccount(userID int, data []byte) error
- func (s *LocalStore) Stat(adID, index int, suffix string) (bool, error)
- func (s *LocalStore) StatUserAccount(userID int) (bool, error)
- type MinioStore
- func (s *MinioStore) DeleteAd(adID int) error
- func (s *MinioStore) DeleteUserAccount(userID int) error
- func (s *MinioStore) Get(adID, index int, suffix string) ([]byte, error)
- func (s *MinioStore) GetUserAccount(userID int) ([]byte, error)
- func (s *MinioStore) ListAd(adID int) ([]ImageRef, error)
- func (s *MinioStore) PresignGet(adID, index int, suffix string, expiry time.Duration) (string, error)
- func (s *MinioStore) PresignGetUserAccount(userID int, expiry time.Duration) (string, error)
- func (s *MinioStore) PresignPut(adID, index int, suffix string, expiry time.Duration) (string, error)
- func (s *MinioStore) PresignPutUserAccount(userID int, expiry time.Duration) (string, error)
- func (s *MinioStore) Put(adID, index int, suffix string, data []byte) error
- func (s *MinioStore) PutUserAccount(userID int, data []byte) error
- func (s *MinioStore) Stat(adID, index int, suffix string) (bool, error)
- func (s *MinioStore) StatUserAccount(userID int) (bool, error)
- type Store
- type URLCache
- func (c *URLCache) InvalidateGetURL(adID, index int, suffix string)
- func (c *URLCache) InvalidateUserAccountURL(userID int)
- func (c *URLCache) ReusedGetURL(adID, index int, suffix string, expiry time.Duration) (string, error)
- func (c *URLCache) ReusedGetUserAccountURL(userID int, expiry time.Duration) (string, error)
Constants ¶
const ( ImageExt = "jpg" ImageMIME = "image/jpeg" )
Variables ¶
var ImageSizes = []string{"160w", "480w", "1200w"}
ImageSizes are the JPEG derivative suffixes stored per ad image.
Functions ¶
This section is empty.
Types ¶
type LocalStore ¶
type LocalStore struct {
// contains filtered or unexported fields
}
LocalStore writes ad images under baseDir/{adID}/{index}-{suffix}.jpg.
func NewLocal ¶
func NewLocal(baseDir string) *LocalStore
func (*LocalStore) DeleteAd ¶
func (s *LocalStore) DeleteAd(adID int) error
func (*LocalStore) DeleteUserAccount ¶
func (s *LocalStore) DeleteUserAccount(userID int) error
func (*LocalStore) GetUserAccount ¶
func (s *LocalStore) GetUserAccount(userID int) ([]byte, error)
func (*LocalStore) PresignGet ¶
func (*LocalStore) PresignGetUserAccount ¶
func (*LocalStore) PresignPut ¶
func (*LocalStore) PresignPutUserAccount ¶
func (*LocalStore) Put ¶
func (s *LocalStore) Put(adID, index int, suffix string, data []byte) error
func (*LocalStore) PutUserAccount ¶
func (s *LocalStore) PutUserAccount(userID int, data []byte) error
func (*LocalStore) StatUserAccount ¶
func (s *LocalStore) StatUserAccount(userID int) (bool, error)
type MinioStore ¶
type MinioStore struct {
// contains filtered or unexported fields
}
MinioStore stores ad images in a MinIO bucket.
func NewMinio ¶
func NewMinio() (*MinioStore, error)
NewMinio connects to MinIO, ensures the bucket exists, and returns a store.
func (*MinioStore) DeleteAd ¶
func (s *MinioStore) DeleteAd(adID int) error
func (*MinioStore) DeleteUserAccount ¶
func (s *MinioStore) DeleteUserAccount(userID int) error
func (*MinioStore) GetUserAccount ¶
func (s *MinioStore) GetUserAccount(userID int) ([]byte, error)
func (*MinioStore) PresignGet ¶
func (*MinioStore) PresignGetUserAccount ¶
func (*MinioStore) PresignPut ¶
func (*MinioStore) PresignPutUserAccount ¶
func (*MinioStore) Put ¶
func (s *MinioStore) Put(adID, index int, suffix string, data []byte) error
func (*MinioStore) PutUserAccount ¶
func (s *MinioStore) PutUserAccount(userID int, data []byte) error
func (*MinioStore) StatUserAccount ¶
func (s *MinioStore) StatUserAccount(userID int) (bool, error)
type Store ¶
type Store interface {
Put(adID, index int, suffix string, data []byte) error
Get(adID, index int, suffix string) ([]byte, error)
Stat(adID, index int, suffix string) (bool, error)
ListAd(adID int) ([]ImageRef, error)
DeleteAd(adID int) error
PresignPut(adID, index int, suffix string,
expiry time.Duration) (string, error)
PresignGet(adID, index int, suffix string,
expiry time.Duration) (string, error)
PutUserAccount(userID int, data []byte) error
GetUserAccount(userID int) ([]byte, error)
StatUserAccount(userID int) (bool, error)
DeleteUserAccount(userID int) error
PresignPutUserAccount(userID int, expiry time.Duration) (string, error)
PresignGetUserAccount(userID int, expiry time.Duration) (string, error)
}
Store persists ad image files in MinIO. LocalStore exists for tests only.
func NewDefault ¶
NewDefault returns a MinIO-backed image store. MINIO_* env vars must be set.
type URLCache ¶
type URLCache struct {
// contains filtered or unexported fields
}
URLCache reuses PresignGet URLs for the signature lifetime (TTL = expiry).
func NewURLCache ¶
func (*URLCache) InvalidateGetURL ¶
InvalidateGetURL drops a cached GET URL.
func (*URLCache) InvalidateUserAccountURL ¶
InvalidateUserAccountURL drops a cached user account picture GET URL.