services

package
v0.0.0-...-72edf46 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2025 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloseNATS

func CloseNATS(ctx context.Context) error

CloseNATS cleanly drains and closes the connection

func ConnectNATS

func ConnectNATS(url string) (*nats.Conn, nats.JetStreamContext, error)

ConnectNATS connects to NATS and initializes JetStream and streams. It returns the underlying Conn and JetStreamContext for advanced usage.

func DeleteAllFilesForUser

func DeleteAllFilesForUser(userID string) int

func DeleteFileMetadata

func DeleteFileMetadata(fileID, userID string) bool

func GetContentType

func GetContentType(extension string) string

GetContentType Helper function to determine the content type

func GetFileMetadata

func GetFileMetadata(fileID string) (models.FileMetadata, bool)

func GetFilePathsForUser

func GetFilePathsForUser(userID string) ([]string, error)

func GetStats

func GetStats() map[string]interface{}

func GetUserFileCount

func GetUserFileCount(userID string) (int64, error)

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 InitializeMinio(endpoint, accessKey, secretKey, bucket string, useSSL bool) error

func InitializePostgres

func InitializePostgres(connectionString string) error

InitializePostgres sets up PostgreSQL storage

func PublishEvent

func PublishEvent(subject string, payload interface{}) error

PublishEvent publishes an event via JetStream (durable, stored). subject e.g. "files.uploaded"

func PublishPlain

func PublishPlain(subject string, payload []byte) error

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")

func UpdateFileScanStatus

func UpdateFileScanStatus(id string, status string, now time.Time) error

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

func (s *MinioService) UploadFile(reader io.Reader, size int64, objectName, contentType string) error

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

Jump to

Keyboard shortcuts

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