Documentation
¶
Index ¶
- func CloseNATS(ctx context.Context) error
- func ConnectNATS(url string) (*nats.Conn, nats.JetStreamContext, error)
- func DeleteAllFilesForUser(userID string) int
- func DeleteFileMetadata(fileID, userID string) bool
- func GetContentType(extension string) string
- func GetFileMetadata(fileID string) (models.FileMetadata, bool)
- func GetFilePathsForUser(userID string) ([]string, error)
- func GetStats() map[string]interface{}
- func GetUserFileCount(userID string) (int64, error)
- func GetUserFileMetadata(userID string) []models.FileMetadata
- func GetUserFileMetadataPage(userID string, limit, offset int) ([]models.FileMetadata, error)
- func InitializeMinio(endpoint, accessKey, secretKey, bucket string, useSSL bool) error
- func InitializePostgres(connectionString string) error
- func PublishEvent(subject string, payload interface{}) error
- func PublishPlain(subject string, payload []byte) error
- func SaveFileMetadata(metadata models.FileMetadata) error
- func SubscribeEvent(subject, durableName string, handler nats.MsgHandler) (*nats.Subscription, error)
- func UpdateFileScanStatus(id string, status string, now time.Time) error
- type MinioService
- func (m *MinioService) CheckConnection() error
- func (m *MinioService) DeleteFile(objectName string) error
- func (s *MinioService) DeleteObjectsByPrefix(prefix string) error
- func (m *MinioService) DownloadFile(objectName, localFilePath string) error
- func (m *MinioService) GetFileURL(objectName string) string
- func (s *MinioService) UploadFile(reader io.Reader, size int64, objectName, contentType string) error
- type PostgresStorage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConnectNATS ¶
ConnectNATS connects to NATS and initializes JetStream and streams. It returns the underlying Conn and JetStreamContext for advanced usage.
func DeleteAllFilesForUser ¶
func DeleteFileMetadata ¶
func GetContentType ¶
GetContentType Helper function to determine the content type
func GetFileMetadata ¶
func GetFileMetadata(fileID string) (models.FileMetadata, bool)
func GetFilePathsForUser ¶
func GetUserFileCount ¶
GetUserFileCount returns total number of files for a user
func GetUserFileMetadata ¶
func GetUserFileMetadata(userID string) []models.FileMetadata
func GetUserFileMetadataPage ¶
func GetUserFileMetadataPage(userID string, limit, offset int) ([]models.FileMetadata, error)
GetUserFileMetadataPage returns a paginated list of files for a user
func InitializeMinio ¶
func InitializePostgres ¶
InitializePostgres sets up PostgreSQL storage
func PublishEvent ¶
PublishEvent publishes an event via JetStream (durable, stored). subject e.g. "files.uploaded"
func PublishPlain ¶
PublishPlain publishes without JetStream (fire-and-forget). Keep this for compatibility, but prefer PublishEvent for critical events.
func SaveFileMetadata ¶
func SaveFileMetadata(metadata models.FileMetadata) error
func SubscribeEvent ¶
func SubscribeEvent(subject, durableName string, handler nats.MsgHandler) (*nats.Subscription, error)
SubscribeEvent creates a durable, ack-based consumer. handler receives the nats.Msg and is responsible to Ack() when done. durableName should be unique per consumer service (e.g., "file-service-preview-consumer")
Types ¶
type MinioService ¶
type MinioService struct {
// contains filtered or unexported fields
}
func GetMinioService ¶
func GetMinioService() *MinioService
func (*MinioService) CheckConnection ¶
func (m *MinioService) CheckConnection() error
CheckConnection Add this method for health checks
func (*MinioService) DeleteFile ¶
func (m *MinioService) DeleteFile(objectName string) error
func (*MinioService) DeleteObjectsByPrefix ¶
func (s *MinioService) DeleteObjectsByPrefix(prefix string) error
func (*MinioService) DownloadFile ¶
func (m *MinioService) DownloadFile(objectName, localFilePath string) error
func (*MinioService) GetFileURL ¶
func (m *MinioService) GetFileURL(objectName string) string
func (*MinioService) UploadFile ¶
type PostgresStorage ¶
type PostgresStorage struct {
// contains filtered or unexported fields
}
PostgresStorage handles PostgreSQL operations
func (*PostgresStorage) Connect ¶
func (p *PostgresStorage) Connect(connectionString string) error
Connect establishes connection to PostgreSQL