storagerepo

package
v2.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 1, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrBucketDoesNotExist = errors.New("requested bucket does not exist")

Functions

This section is empty.

Types

type Bucket

type Bucket string
const (
	BucketMainApp     Bucket = "main-app"
	BucketStaticFiles Bucket = "static-files"
)

func ParseBucket

func ParseBucket(raw string) (Bucket, error)

func (Bucket) String

func (b Bucket) String() string

type ImageFile

type ImageFile struct {
	ID    int
	Sizes []ImageFileSize
}

type ImageFileSize

type ImageFileSize struct {
	Size      string
	Height    int
	Width     int
	ObjectKey string
}

type MockNotifierService

type MockNotifierService struct {
	mock.Mock
}

MockNotifierService is a mock of NotifierService interface

func NewMockNotifierService

func NewMockNotifierService() *MockNotifierService

func (*MockNotifierService) CreateNotification

func (m *MockNotifierService) CreateNotification(ctx context.Context, notification domain.Notification) error

func (*MockNotifierService) GetNotifications

func (m *MockNotifierService) GetNotifications(ctx context.Context, profileID int, onlyUnread bool) ([]*domain.Notification, error)

func (*MockNotifierService) MarkNotificationRead

func (m *MockNotifierService) MarkNotificationRead(ctx context.Context, notificationID int, profileID *int) error

func (*MockNotifierService) MarkNotificationUnread

func (m *MockNotifierService) MarkNotificationUnread(ctx context.Context, notificationID int, profileID *int) error

func (*MockNotifierService) SSESubscribe

func (m *MockNotifierService) SSESubscribe(ctx context.Context, topic string, handler ssepubsub.MessageHandler) error

func (*MockNotifierService) SSEUnsubscribe

func (m *MockNotifierService) SSEUnsubscribe(ctx context.Context, topic string) error

type MockStorageClient

type MockStorageClient struct {
	mock.Mock
}

MockStorageClient is a mock implementation of the StorageClientInterface.

func NewMockStorageClient

func NewMockStorageClient() *MockStorageClient

NewMockStorageClient creates a new instance of MockStorageClient.

func (*MockStorageClient) CreateBucket

func (msc *MockStorageClient) CreateBucket(bucketName string, location string) error

func (*MockStorageClient) DeleteFile

func (msc *MockStorageClient) DeleteFile(bucket Bucket, objectName string) error

func (*MockStorageClient) GetImageObjectFromFile

func (msc *MockStorageClient) GetImageObjectFromFile(file *ImageFile) (*domain.Photo, error)

func (*MockStorageClient) GetImageObjectsFromFiles

func (msc *MockStorageClient) GetImageObjectsFromFiles(files []*ImageFile) ([]domain.Photo, error)

func (*MockStorageClient) GetPresignedURL

func (msc *MockStorageClient) GetPresignedURL(bucket Bucket, objectName string, expiry time.Duration) (string, error)

func (*MockStorageClient) UploadFile

func (msc *MockStorageClient) UploadFile(bucket Bucket, objectName string, fileStream io.Reader) (*int, error)

type NoImagesInFiles

type NoImagesInFiles struct {
	Message string
}

func (*NoImagesInFiles) Error

func (e *NoImagesInFiles) Error() string

Error implements the error interface

type StorageClient

type StorageClient struct {
	// contains filtered or unexported fields
}

func NewStorageClient

func NewStorageClient(cfg *config.Config, db *sql.DB, dialect string) *StorageClient

func (*StorageClient) CreateBucket

func (sc *StorageClient) CreateBucket(bucketName string, location string) error

func (*StorageClient) DeleteFile

func (sc *StorageClient) DeleteFile(bucket Bucket, objectName string) error

func (*StorageClient) GetImageObjectFromFile

func (sc *StorageClient) GetImageObjectFromFile(image *ImageFile) (*domain.Photo, error)

TODO: GetImageObjectFromFile and GetImageObjectsFromFiles can be standardized to return a specific file object. Expiration can also be parametrized if necessary. getPhotoObjectFromFile generates a signed URL for a single file.

func (*StorageClient) GetImageObjectsFromFiles

func (sc *StorageClient) GetImageObjectsFromFiles(
	files []*ImageFile,
) ([]domain.Photo, error)

func (*StorageClient) GetPresignedURL

func (sc *StorageClient) GetPresignedURL(bucket Bucket, objectName string, expiry time.Duration) (string, error)

func (*StorageClient) UploadFile

func (sc *StorageClient) UploadFile(bucket Bucket, objectName string, fileStream io.Reader) (*int, error)

type StorageClientInterface

type StorageClientInterface interface {
	CreateBucket(bucketName string, location string) error
	UploadFile(bucket Bucket, objectName string, fileStream io.Reader) (*int, error)
	DeleteFile(bucket Bucket, objectName string) error
	GetPresignedURL(bucket Bucket, objectName string, expiry time.Duration) (string, error)
	GetImageObjectFromFile(file *ImageFile) (*domain.Photo, error)
	GetImageObjectsFromFiles(files []*ImageFile) ([]domain.Photo, error)
}

StorageClientInterface defines the interface for the storage client.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL