Documentation ¶
Index ¶
- type Backend
- func (b *Backend) Clean() (files int, tokens int, err error)
- func (b *Backend) CountUploadFiles(uploadID string) (count int, err error)
- func (b *Backend) CountUserTokens(userID string) (count int, err error)
- func (b *Backend) CountUsers() (count int, err error)
- func (b *Backend) CreateFile(file *common.File) (err error)
- func (b *Backend) CreateSetting(setting *common.Setting) (err error)
- func (b *Backend) CreateToken(token *common.Token) (err error)
- func (b *Backend) CreateUpload(upload *common.Upload) (err error)
- func (b *Backend) CreateUser(user *common.User) (err error)
- func (b *Backend) DeleteRemovedUploads() (removed int, err error)
- func (b *Backend) DeleteSetting(key string) (err error)
- func (b *Backend) DeleteToken(tokenStr string) (deleted bool, err error)
- func (b *Backend) DeleteUser(userID string) (deleted bool, err error)
- func (b *Backend) Export(path string) (err error)
- func (b *Backend) ForEachFile(f func(file *common.File) error) (err error)
- func (b *Backend) ForEachRemovedFile(f func(file *common.File) error) (err error)
- func (b *Backend) ForEachSetting(f func(setting *common.Setting) error) (err error)
- func (b *Backend) ForEachToken(f func(token *common.Token) error) (err error)
- func (b *Backend) ForEachUpload(f func(upload *common.Upload) error) (err error)
- func (b *Backend) ForEachUploadFiles(uploadID string, f func(file *common.File) error) (err error)
- func (b *Backend) ForEachUploadUnscoped(f func(upload *common.Upload) error) (err error)
- func (b *Backend) ForEachUserUploads(userID string, tokenStr string, f func(upload *common.Upload) error) (err error)
- func (b *Backend) ForEachUsers(f func(user *common.User) error) (err error)
- func (b *Backend) GetFile(fileID string) (file *common.File, err error)
- func (b *Backend) GetFiles(uploadID string) (files []*common.File, err error)
- func (b *Backend) GetMetricsCollectors() []prometheus.Collector
- func (b *Backend) GetServerStatistics() (stats *common.ServerStats, err error)
- func (b *Backend) GetSetting(key string) (setting *common.Setting, err error)
- func (b *Backend) GetToken(tokenStr string) (token *common.Token, err error)
- func (b *Backend) GetTokens(userID string, pagingQuery *common.PagingQuery) (tokens []*common.Token, cursor *paginator.Cursor, err error)
- func (b *Backend) GetUpload(ID string) (upload *common.Upload, err error)
- func (b *Backend) GetUploadStatistics(userID *string, tokenStr *string) (uploads int, files int, size int64, err error)
- func (b *Backend) GetUploads(userID string, tokenStr string, withFiles bool, ...) (uploads []*common.Upload, cursor *paginator.Cursor, err error)
- func (b *Backend) GetUploadsSortedBySize(userID string, tokenStr string, withFiles bool, ...) (uploads []*common.Upload, cursor *paginator.Cursor, err error)
- func (b *Backend) GetUser(ID string) (user *common.User, err error)
- func (b *Backend) GetUserStatistics(userID string, tokenStr *string) (stats *common.UserStats, err error)
- func (b *Backend) GetUsers(provider string, withTokens bool, pagingQuery *common.PagingQuery) (users []*common.User, cursor *paginator.Cursor, err error)
- func (b *Backend) Import(path string, options *ImportOptions) (err error)
- func (b *Backend) RemoveExpiredUploads() (removed int, err error)
- func (b *Backend) RemoveFile(file *common.File) error
- func (b *Backend) RemoveUpload(uploadID string) (err error)
- func (b *Backend) RemoveUserUploads(userID string, tokenStr string) (removed int, err error)
- func (b *Backend) Shutdown() (err error)
- func (b *Backend) UpdateFile(file *common.File, status string) error
- func (b *Backend) UpdateFileStatus(file *common.File, oldStatus string, newStatus string) error
- func (b *Backend) UpdateSetting(key string, oldValue string, newValue string) (err error)
- func (b *Backend) UpdateUploadExpirationDate(upload *common.Upload) (err error)
- func (b *Backend) UpdateUser(user *common.User) (err error)
- type Config
- type GormLoggerAdapter
- func (l *GormLoggerAdapter) Error(ctx context.Context, msg string, data ...interface{})
- func (l *GormLoggerAdapter) Info(ctx context.Context, msg string, data ...interface{})
- func (l *GormLoggerAdapter) LogMode(level gorm_logger.LogLevel) gorm_logger.Interface
- func (l *GormLoggerAdapter) Trace(ctx context.Context, begin time.Time, fc func() (string, int64), err error)
- func (l *GormLoggerAdapter) Warn(ctx context.Context, msg string, data ...interface{})
- type ImportOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Backend ¶
type Backend struct { Config *Config // contains filtered or unexported fields }
Backend object
func NewBackend ¶
NewBackend instantiate a new File Data Backend from configuration passed as argument
func (*Backend) CountUploadFiles ¶
CountUploadFiles count how many files have been added to an upload
func (*Backend) CountUserTokens ¶
CountUserTokens count how many token a user has
func (*Backend) CountUsers ¶
CountUsers count the number of user in the DB
func (*Backend) CreateFile ¶
CreateFile persist a new file to the database
func (*Backend) CreateSetting ¶
CreateSetting create a new setting in DB
func (*Backend) CreateToken ¶
CreateToken create a new token in DB
func (*Backend) CreateUpload ¶
CreateUpload create a new upload in DB
func (*Backend) CreateUser ¶
CreateUser create a new user in DB
func (*Backend) DeleteRemovedUploads ¶
DeleteRemovedUploads delete upload and file metadata from the database once :
- The upload has been removed (soft delete) either manually or because it expired
- All the upload files have been deleted from the data backend (status Deleted)
func (*Backend) DeleteSetting ¶
DeleteSetting delete a setting from DB
func (*Backend) DeleteToken ¶
DeleteToken remove a token from the DB
func (*Backend) DeleteUser ¶
DeleteUser delete a user from the DB
func (*Backend) ForEachFile ¶
ForEachFile execute f for every file in the database
func (*Backend) ForEachRemovedFile ¶
ForEachRemovedFile execute f for each file with the status "removed"
func (*Backend) ForEachSetting ¶
ForEachSetting execute f for every setting in the database
func (*Backend) ForEachToken ¶
ForEachToken execute f for every token in the database
func (*Backend) ForEachUpload ¶
ForEachUpload execute f for every upload in the database
func (*Backend) ForEachUploadFiles ¶
ForEachUploadFiles execute f for each file of the upload
func (*Backend) ForEachUploadUnscoped ¶
ForEachUploadUnscoped execute f for every upload in the database even soft deleted ones
func (*Backend) ForEachUserUploads ¶
func (b *Backend) ForEachUserUploads(userID string, tokenStr string, f func(upload *common.Upload) error) (err error)
ForEachUserUploads execute f for all upload matching the user and token filters
func (*Backend) ForEachUsers ¶
ForEachUsers execute f for every user in the database
func (*Backend) GetMetricsCollectors ¶
func (b *Backend) GetMetricsCollectors() []prometheus.Collector
GetMetricsCollectors return Gorm metrics
func (*Backend) GetServerStatistics ¶
func (b *Backend) GetServerStatistics() (stats *common.ServerStats, err error)
GetServerStatistics return statistics about user all uploads
func (*Backend) GetSetting ¶
GetSetting get a setting from DB
func (*Backend) GetToken ¶
GetToken return a token from the DB ( return nil and non error if not found )
func (*Backend) GetTokens ¶
func (b *Backend) GetTokens(userID string, pagingQuery *common.PagingQuery) (tokens []*common.Token, cursor *paginator.Cursor, err error)
GetTokens return all tokens for a user
func (*Backend) GetUpload ¶
GetUpload return an upload from the DB ( return nil and no error if not found )
func (*Backend) GetUploadStatistics ¶
func (b *Backend) GetUploadStatistics(userID *string, tokenStr *string) (uploads int, files int, size int64, err error)
GetUploadStatistics return statistics about uploads for userID and tokenStr params : nil doesn't activate the filter, empty string enables the filter with an empty value to generate statistics about anonymous upload
func (*Backend) GetUploads ¶
func (b *Backend) GetUploads(userID string, tokenStr string, withFiles bool, pagingQuery *common.PagingQuery) (uploads []*common.Upload, cursor *paginator.Cursor, err error)
GetUploads return uploads from DB userID and tokenStr are filters set withFiles to also fetch the files
func (*Backend) GetUploadsSortedBySize ¶
func (b *Backend) GetUploadsSortedBySize(userID string, tokenStr string, withFiles bool, pagingQuery *common.PagingQuery) (uploads []*common.Upload, cursor *paginator.Cursor, err error)
GetUploadsSortedBySize return uploads from DB sorted by size userID and tokenStr are filters set withFiles to also fetch the files
func (*Backend) GetUserStatistics ¶
func (b *Backend) GetUserStatistics(userID string, tokenStr *string) (stats *common.UserStats, err error)
GetUserStatistics return statistics about user uploads for tokenStr params : nil doesn't activate the filter, empty string enables the filter with an empty value to generate statistics about upload without a token
func (*Backend) GetUsers ¶
func (b *Backend) GetUsers(provider string, withTokens bool, pagingQuery *common.PagingQuery) (users []*common.User, cursor *paginator.Cursor, err error)
GetUsers return all users provider is an optional filter
func (*Backend) Import ¶
func (b *Backend) Import(path string, options *ImportOptions) (err error)
Import imports metadata from a compressed binary file
func (*Backend) RemoveExpiredUploads ¶
RemoveExpiredUploads soft delete all expired uploads and remove all their files
func (*Backend) RemoveFile ¶
RemoveFile change the file status to removed The file will then be deleted from the data backend by the server and the status changed to deleted.
func (*Backend) RemoveUpload ¶
RemoveUpload soft delete upload ( just set upload.DeletedAt field ) and remove all files The upload metadata will still be present in the metadata database as well as all the files Until all the files are deleted from the data backend and
func (*Backend) RemoveUserUploads ¶
RemoveUserUploads deletes all uploads matching the user and token filters
func (*Backend) UpdateFile ¶
UpdateFile update a file in DB. Status ensure the file status has not changed since loaded
func (*Backend) UpdateFileStatus ¶
UpdateFileStatus update a file status in DB. oldStatus ensure the file status has not changed since loaded
func (*Backend) UpdateSetting ¶
UpdateSetting update a setting in DB
func (*Backend) UpdateUploadExpirationDate ¶
UpdateUploadExpirationDate updates an upload expiration date in DB
type Config ¶
type Config struct { Driver string ConnectionString string EraseFirst bool MaxOpenConns int MaxIdleConns int Debug bool SlowQueryThreshold string // Duration string // contains filtered or unexported fields }
Config metadata backend configuration
type GormLoggerAdapter ¶
type GormLoggerAdapter struct { SlowQueryThreshold time.Duration // contains filtered or unexported fields }
GormLoggerAdapter forward Gorm logs to a root-gg logger
func NewGormLoggerAdapter ¶
func NewGormLoggerAdapter(log *logger.Logger) *GormLoggerAdapter
NewGormLoggerAdapter create a new GormLoggerAdapter for a root-gg logger
func (*GormLoggerAdapter) Error ¶
func (l *GormLoggerAdapter) Error(ctx context.Context, msg string, data ...interface{})
Error print error messages
func (*GormLoggerAdapter) Info ¶
func (l *GormLoggerAdapter) Info(ctx context.Context, msg string, data ...interface{})
Info print info
func (*GormLoggerAdapter) LogMode ¶
func (l *GormLoggerAdapter) LogMode(level gorm_logger.LogLevel) gorm_logger.Interface
LogMode is not relevant as log level is managed by the root-gg logger level
type ImportOptions ¶
type ImportOptions struct {
IgnoreErrors bool
}
ImportOptions for metadata imports