Better tracing
Not done yet, still need to add them to just about every other function
This commit is contained in:
parent
83f47d17be
commit
529d106351
13 changed files with 148 additions and 22 deletions
|
@ -1,6 +1,8 @@
|
|||
package storage
|
||||
|
||||
import (
|
||||
"github.com/rs/zerolog/log"
|
||||
"gitlab.com/mstarongitlab/linstrom/util"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
|
@ -13,6 +15,7 @@ type OutboundJob struct {
|
|||
}
|
||||
|
||||
func (s *Storage) AddNewOutboundJob(data []byte, targetDomain string, targetUrl string) {
|
||||
defer util.Untrace(util.Trace(&log.Logger))
|
||||
newJob := OutboundJob{
|
||||
Data: data,
|
||||
TargetServer: targetDomain,
|
||||
|
@ -23,6 +26,7 @@ func (s *Storage) AddNewOutboundJob(data []byte, targetDomain string, targetUrl
|
|||
|
||||
// Get the specified amount of jobs, sorted by age (oldest first)
|
||||
func (s *Storage) GetOldestOutboundJobs(amount uint) ([]OutboundJob, error) {
|
||||
defer util.Untrace(util.Trace(&log.Logger))
|
||||
jobs := []OutboundJob{}
|
||||
err := s.db.Order("id asc, created_at asc").Limit(int(amount)).Find(jobs).Error
|
||||
switch err {
|
||||
|
@ -36,8 +40,13 @@ func (s *Storage) GetOldestOutboundJobs(amount uint) ([]OutboundJob, error) {
|
|||
}
|
||||
|
||||
func (s *Storage) GetOutboundJobsForDomain(domain string, amount uint) ([]OutboundJob, error) {
|
||||
defer util.Untrace(util.Trace(&log.Logger))
|
||||
jobs := []OutboundJob{}
|
||||
err := s.db.Where("target_server = ?", domain).Order("id asc, created_at asc").Limit(int(amount)).Find(jobs).Error
|
||||
err := s.db.Where("target_server = ?", domain).
|
||||
Order("id asc, created_at asc").
|
||||
Limit(int(amount)).
|
||||
Find(jobs).
|
||||
Error
|
||||
switch err {
|
||||
case gorm.ErrRecordNotFound:
|
||||
return nil, ErrEntryNotFound
|
||||
|
@ -49,6 +58,7 @@ func (s *Storage) GetOutboundJobsForDomain(domain string, amount uint) ([]Outbou
|
|||
}
|
||||
|
||||
func (s *Storage) CompleteOutboundJob(id uint) error {
|
||||
defer util.Untrace(util.Trace(&log.Logger))
|
||||
s.db.Delete(OutboundJob{Model: gorm.Model{ID: id}})
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue