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"
|
||||
)
|
||||
|
||||
|
@ -35,6 +37,7 @@ type InboundJob struct {
|
|||
}
|
||||
|
||||
func (s *Storage) AddNewInboundJob(data []byte, source InboundJobSource, inboxOwner *string) {
|
||||
defer util.Untrace(util.Trace(&log.Logger))
|
||||
newJob := InboundJob{
|
||||
RawData: data,
|
||||
Source: source,
|
||||
|
@ -45,6 +48,7 @@ func (s *Storage) AddNewInboundJob(data []byte, source InboundJobSource, inboxOw
|
|||
|
||||
// Get the specified amount of jobs, sorted by age (oldest first)
|
||||
func (s *Storage) GetOldestInboundJobs(amount uint) ([]InboundJob, error) {
|
||||
defer util.Untrace(util.Trace(&log.Logger))
|
||||
jobs := []InboundJob{}
|
||||
switch err := s.db.Order("id asc, created_at asc").Limit(int(amount)).Find(jobs).Error; err {
|
||||
case gorm.ErrRecordNotFound:
|
||||
|
@ -57,6 +61,7 @@ func (s *Storage) GetOldestInboundJobs(amount uint) ([]InboundJob, error) {
|
|||
}
|
||||
|
||||
func (s *Storage) CompleteInboundJob(id uint) error {
|
||||
defer util.Untrace(util.Trace(&log.Logger))
|
||||
s.db.Delete(InboundJob{Model: gorm.Model{ID: id}})
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue