Documentation
¶
Index ¶
- type BinDao
- func (d *BinDao) Delete(bin *ds.Bin) (err error)
- func (d *BinDao) GenerateId() string
- func (d *BinDao) GetAll() (bins []ds.Bin, err error)
- func (d *BinDao) GetByBytes(limit int) (bins []ds.Bin, err error)
- func (d *BinDao) GetByCreated(limit int) (bins []ds.Bin, err error)
- func (d *BinDao) GetByDownloads(limit int) (bins []ds.Bin, err error)
- func (d *BinDao) GetByFiles(limit int) (bins []ds.Bin, err error)
- func (d *BinDao) GetByID(id string) (bin ds.Bin, found bool, err error)
- func (d *BinDao) GetLastUpdated(limit int) (bins []ds.Bin, err error)
- func (d *BinDao) GetPendingDelete() (bins []ds.Bin, err error)
- func (d *BinDao) Insert(bin *ds.Bin) (err error)
- func (d *BinDao) RegisterDownload(bin *ds.Bin) (err error)
- func (d *BinDao) RegisterUpdate(bin *ds.Bin) (err error)
- func (d *BinDao) Update(bin *ds.Bin) (err error)
- func (d *BinDao) Upsert(bin *ds.Bin) (err error)
- func (d *BinDao) ValidateInput(bin *ds.Bin) error
- type ClientDao
- func (c *ClientDao) Ban(IPsToBan []string, banByRemoteAddr string) (err error)
- func (c *ClientDao) Cleanup(days uint64) (count int64, err error)
- func (c *ClientDao) GetASNWithStats(limit int) (asns []ds.AutonomousSystem, err error)
- func (c *ClientDao) GetAll() (clients []ds.Client, err error)
- func (c *ClientDao) GetByBannedAt(limit int) (clients []ds.Client, err error)
- func (c *ClientDao) GetByBytesUploaded(limit int) (clients []ds.Client, err error)
- func (c *ClientDao) GetByCountry(limit int) (countries []ds.ClientByCountry, err error)
- func (c *ClientDao) GetByFilesUploaded(limit int) (clients []ds.Client, err error)
- func (c *ClientDao) GetByIP(ip net.IP) (client ds.Client, found bool, err error)
- func (c *ClientDao) GetByLastActiveAt(limit int) (clients []ds.Client, err error)
- func (c *ClientDao) GetByNetwork(limit int) (networks []ds.ClientByNetwork, err error)
- func (c *ClientDao) GetByRemoteAddr(remoteAddr string) (client ds.Client, found bool, err error)
- func (c *ClientDao) GetByRequests(limit int) (clients []ds.Client, err error)
- func (c *ClientDao) Update(client *ds.Client) (err error)
- type DAO
- func (dao DAO) Bin() *BinDao
- func (dao DAO) Client() *ClientDao
- func (dao DAO) Close() error
- func (dao DAO) CreateSchema() error
- func (dao DAO) File() *FileDao
- func (dao DAO) FileContent() *FileContentDao
- func (dao DAO) Metrics() *MetricsDao
- func (dao DAO) ResetDB() error
- func (dao *DAO) SetMetrics(m DBMetricsObserver)
- func (dao DAO) Stats() sql.DBStats
- func (dao DAO) Status() bool
- func (dao DAO) Transaction() *TransactionDao
- type DBConfig
- type DBMetricsObserver
- type FileContentDao
- func (d *FileContentDao) BlockContent(sha256 string) (retErr error)
- func (d *FileContentDao) Delete(sha256 string) error
- func (d *FileContentDao) DeleteFileReferences(sha256 string) error
- func (d *FileContentDao) GetAll() ([]ds.FileContent, error)
- func (d *FileContentDao) GetBlocked(limit int) (contents []ds.FileByChecksum, err error)
- func (d *FileContentDao) GetByCreated(limit int) (contents []ds.FileByChecksum, err error)
- func (d *FileContentDao) GetBySHA256(sha256 string) (*ds.FileContent, error)
- func (d *FileContentDao) GetPendingDelete() ([]ds.FileContent, error)
- func (d *FileContentDao) InsertOrIncrement(content *ds.FileContent) error
- func (d *FileContentDao) UnblockContent(sha256 string) error
- func (d *FileContentDao) Update(content *ds.FileContent) error
- type FileDao
- func (d *FileDao) CountBySHA256(sha256 string) (int, error)
- func (d *FileDao) Delete(file *ds.File) (err error)
- func (d *FileDao) FileByChecksum(sha256 string) (files []ds.File, err error)
- func (d *FileDao) FilesByBytes(limit int) (files []ds.FileByChecksum, err error)
- func (d *FileDao) FilesByBytesTotal(limit int) (files []ds.FileByChecksum, err error)
- func (d *FileDao) FilesByChecksum(limit int) (files []ds.FileByChecksum, err error)
- func (d *FileDao) GetAll(available bool) (files []ds.File, err error)
- func (d *FileDao) GetByBin(id string, inStorage bool) (files []ds.File, err error)
- func (d *FileDao) GetByBytes(limit int) (files []ds.File, err error)
- func (d *FileDao) GetByCreated(limit int) (files []ds.File, err error)
- func (d *FileDao) GetByID(id int) (file ds.File, found bool, err error)
- func (d *FileDao) GetByName(bin string, filename string) (file ds.File, found bool, err error)
- func (d *FileDao) GetByUpdated(limit int) (files []ds.File, err error)
- func (d *FileDao) GetByUpdates(limit int) (files []ds.File, err error)
- func (d *FileDao) GetTopDownloads(limit int) (files []ds.File, err error)
- func (d *FileDao) Insert(file *ds.File) (err error)
- func (d *FileDao) IsAvailableForDownload(fileId int) (bool, error)
- func (d *FileDao) RegisterDownload(file *ds.File) (err error)
- func (d *FileDao) Update(file *ds.File) (err error)
- func (d *FileDao) ValidateInput(file *ds.File) error
- type MetricsDao
- type PostgresStats
- type TransactionDao
- func (d *TransactionDao) Cleanup(retention uint64) (count int64, err error)
- func (d *TransactionDao) GetByBin(bin string) (transactions []ds.Transaction, err error)
- func (d *TransactionDao) GetByIP(ip string) (transactions []ds.Transaction, err error)
- func (d *TransactionDao) Insert(t *ds.Transaction) (err error)
- func (d *TransactionDao) Register(r *http.Request, bin string, filename string, timestamp time.Time, ...) (transaction *ds.Transaction, err error)
- func (d *TransactionDao) Update(t *ds.Transaction) (err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BinDao ¶
type BinDao struct {
// contains filtered or unexported fields
}
func (*BinDao) GenerateId ¶
func (*BinDao) GetByDownloads ¶
func (*BinDao) GetLastUpdated ¶
type ClientDao ¶
type ClientDao struct {
// contains filtered or unexported fields
}
func (*ClientDao) GetASNWithStats ¶
func (c *ClientDao) GetASNWithStats(limit int) (asns []ds.AutonomousSystem, err error)
func (*ClientDao) GetByBannedAt ¶
func (*ClientDao) GetByBytesUploaded ¶
func (*ClientDao) GetByCountry ¶
func (c *ClientDao) GetByCountry(limit int) (countries []ds.ClientByCountry, err error)
func (*ClientDao) GetByFilesUploaded ¶
func (*ClientDao) GetByLastActiveAt ¶
func (*ClientDao) GetByNetwork ¶
func (c *ClientDao) GetByNetwork(limit int) (networks []ds.ClientByNetwork, err error)
func (*ClientDao) GetByRemoteAddr ¶
func (*ClientDao) GetByRequests ¶
type DAO ¶
type DAO struct {
// contains filtered or unexported fields
}
func (DAO) CreateSchema ¶
func (DAO) FileContent ¶
func (dao DAO) FileContent() *FileContentDao
func (DAO) Metrics ¶
func (dao DAO) Metrics() *MetricsDao
func (*DAO) SetMetrics ¶ added in v0.0.3
func (dao *DAO) SetMetrics(m DBMetricsObserver)
SetMetrics sets the metrics observer for database operations.
func (DAO) Transaction ¶
func (dao DAO) Transaction() *TransactionDao
type DBMetricsObserver ¶ added in v0.0.3
type DBMetricsObserver interface {
ObserveDBQuery(operation string, duration time.Duration)
IncrDBQueryError(operation string)
}
DBMetricsObserver allows DAO to report metrics without importing the ds package.
type FileContentDao ¶
type FileContentDao struct {
// contains filtered or unexported fields
}
func (*FileContentDao) BlockContent ¶
func (d *FileContentDao) BlockContent(sha256 string) (retErr error)
BlockContent marks content as blocked and soft-deletes all file references
func (*FileContentDao) Delete ¶
func (d *FileContentDao) Delete(sha256 string) error
Delete removes a file content record from the database
func (*FileContentDao) DeleteFileReferences ¶
func (d *FileContentDao) DeleteFileReferences(sha256 string) error
DeleteFileReferences soft-deletes all file references for a given SHA256 without blocking the content
func (*FileContentDao) GetAll ¶
func (d *FileContentDao) GetAll() ([]ds.FileContent, error)
GetAll returns all file content records
func (*FileContentDao) GetBlocked ¶
func (d *FileContentDao) GetBlocked(limit int) (contents []ds.FileByChecksum, err error)
func (*FileContentDao) GetByCreated ¶
func (d *FileContentDao) GetByCreated(limit int) (contents []ds.FileByChecksum, err error)
func (*FileContentDao) GetBySHA256 ¶
func (d *FileContentDao) GetBySHA256(sha256 string) (*ds.FileContent, error)
GetBySHA256 retrieves a file content record by its SHA256 hash
func (*FileContentDao) GetPendingDelete ¶
func (d *FileContentDao) GetPendingDelete() ([]ds.FileContent, error)
GetPendingDelete returns file content records that have zero active references (active = file exists AND file not deleted AND bin not deleted AND bin not expired) and still in storage
func (*FileContentDao) InsertOrIncrement ¶
func (d *FileContentDao) InsertOrIncrement(content *ds.FileContent) error
InsertOrIncrement inserts a new file content record or updates last_referenced_at if it already exists
func (*FileContentDao) UnblockContent ¶
func (d *FileContentDao) UnblockContent(sha256 string) error
UnblockContent unblocks content by setting blocked = false
func (*FileContentDao) Update ¶
func (d *FileContentDao) Update(content *ds.FileContent) error
Update modifies an existing file content record
type FileDao ¶
type FileDao struct {
// contains filtered or unexported fields
}
func (*FileDao) CountBySHA256 ¶
CountBySHA256 returns the count of active file references with the given SHA256 (active = file not deleted AND bin not deleted AND bin not expired)
func (*FileDao) FileByChecksum ¶
func (*FileDao) FilesByBytes ¶
func (d *FileDao) FilesByBytes(limit int) (files []ds.FileByChecksum, err error)
func (*FileDao) FilesByBytesTotal ¶
func (d *FileDao) FilesByBytesTotal(limit int) (files []ds.FileByChecksum, err error)
func (*FileDao) FilesByChecksum ¶
func (d *FileDao) FilesByChecksum(limit int) (files []ds.FileByChecksum, err error)
func (*FileDao) GetByCreated ¶
func (*FileDao) GetByUpdated ¶
func (*FileDao) GetByUpdates ¶
func (*FileDao) GetTopDownloads ¶
func (*FileDao) IsAvailableForDownload ¶
IsAvailableForDownload checks if a file is available for download by verifying: - The file is not deleted - The bin is not deleted - The bin has not expired - The file content exists in storage
type MetricsDao ¶
type MetricsDao struct {
// contains filtered or unexported fields
}
func (*MetricsDao) PostgresStats ¶ added in v0.0.3
func (d *MetricsDao) PostgresStats() (stats PostgresStats, retErr error)
func (*MetricsDao) StorageBytesAllocated ¶
func (d *MetricsDao) StorageBytesAllocated() (totalBytes uint64)
func (*MetricsDao) UpdateMetrics ¶
func (d *MetricsDao) UpdateMetrics(metrics *ds.Metrics) (retErr error)
type PostgresStats ¶ added in v0.0.3
type PostgresStats struct {
Version string `json:"version"`
ServerStartedAt time.Time `json:"server_started_at"`
ServerUptime string `json:"server_uptime"`
DatabaseSize uint64 `json:"database_size"`
DatabaseSizeReadable string `json:"database_size_readable"`
ActiveConnections int `json:"active_connections"`
TxCommitted int64 `json:"tx_committed"`
TxRolledBack int64 `json:"tx_rolled_back"`
CacheHitRatio float64 `json:"cache_hit_ratio"`
CacheHitRatioReadable string `json:"cache_hit_ratio_readable"`
TotalLiveTuples int64 `json:"total_live_tuples"`
TotalDeadTuples int64 `json:"total_dead_tuples"`
DeadTupleRatio float64 `json:"dead_tuple_ratio"`
DeadTupleRatioReadable string `json:"dead_tuple_ratio_readable"`
TransactionIDAge int64 `json:"transaction_id_age"`
}
type TransactionDao ¶
type TransactionDao struct {
// contains filtered or unexported fields
}
func (*TransactionDao) Cleanup ¶
func (d *TransactionDao) Cleanup(retention uint64) (count int64, err error)
func (*TransactionDao) GetByBin ¶
func (d *TransactionDao) GetByBin(bin string) (transactions []ds.Transaction, err error)
func (*TransactionDao) GetByIP ¶
func (d *TransactionDao) GetByIP(ip string) (transactions []ds.Transaction, err error)
func (*TransactionDao) Insert ¶
func (d *TransactionDao) Insert(t *ds.Transaction) (err error)
func (*TransactionDao) Update ¶
func (d *TransactionDao) Update(t *ds.Transaction) (err error)