outbox for gateways

This commit is contained in:
Stephan D
2026-02-18 01:35:28 +01:00
parent 974caf286c
commit 69531cee73
221 changed files with 12172 additions and 782 deletions

View File

@@ -31,7 +31,7 @@ func NewPostingLines(logger mlogger.Logger, db *mongo.Database) (storage.Posting
},
}
if err := repo.CreateIndex(entryIndex); err != nil {
logger.Error("failed to ensure posting lines entry index", zap.Error(err))
logger.Error("Failed to ensure posting lines entry index", zap.Error(err))
return nil, err
}
@@ -43,12 +43,12 @@ func NewPostingLines(logger mlogger.Logger, db *mongo.Database) (storage.Posting
},
}
if err := repo.CreateIndex(accountIndex); err != nil {
logger.Error("failed to ensure posting lines account index", zap.Error(err))
logger.Error("Failed to ensure posting lines account index", zap.Error(err))
return nil, err
}
childLogger := logger.Named(model.PostingLinesCollection)
childLogger.Debug("posting lines store initialised", zap.String("collection", model.PostingLinesCollection))
childLogger.Debug("Posting lines store initialised", zap.String("collection", model.PostingLinesCollection))
return &postingLinesStore{
logger: childLogger,
@@ -58,31 +58,31 @@ func NewPostingLines(logger mlogger.Logger, db *mongo.Database) (storage.Posting
func (p *postingLinesStore) CreateMany(ctx context.Context, lines []*model.PostingLine) error {
if len(lines) == 0 {
p.logger.Warn("attempt to create empty posting lines array")
p.logger.Warn("Attempt to create empty posting lines array")
return nil
}
storables := make([]storable.Storable, len(lines))
for i, line := range lines {
if line == nil {
p.logger.Warn("attempt to create nil posting line")
p.logger.Warn("Attempt to create nil posting line")
return merrors.InvalidArgument("postingLinesStore: nil posting line")
}
storables[i] = line
}
if err := p.repo.InsertMany(ctx, storables); err != nil {
p.logger.Warn("failed to create posting lines", zap.Error(err), zap.Int("count", len(lines)))
p.logger.Warn("Failed to create posting lines", zap.Error(err), zap.Int("count", len(lines)))
return err
}
p.logger.Debug("posting lines created", zap.Int("count", len(lines)))
p.logger.Debug("Posting lines created", zap.Int("count", len(lines)))
return nil
}
func (p *postingLinesStore) ListByJournalEntry(ctx context.Context, entryRef bson.ObjectID) ([]*model.PostingLine, error) {
if entryRef.IsZero() {
p.logger.Warn("attempt to list posting lines with zero entry ID")
p.logger.Warn("Attempt to list posting lines with zero entry ID")
return nil, merrors.InvalidArgument("postingLinesStore: zero entry ID")
}
@@ -98,17 +98,17 @@ func (p *postingLinesStore) ListByJournalEntry(ctx context.Context, entryRef bso
return nil
})
if err != nil {
p.logger.Warn("failed to list posting lines by entry", zap.Error(err), mzap.ObjRef("entry_ref", entryRef))
p.logger.Warn("Failed to list posting lines by entry", zap.Error(err), mzap.ObjRef("entry_ref", entryRef))
return nil, err
}
p.logger.Debug("listed posting lines by entry", zap.Int("count", len(lines)), mzap.ObjRef("entry_ref", entryRef))
p.logger.Debug("Listed posting lines by entry", zap.Int("count", len(lines)), mzap.ObjRef("entry_ref", entryRef))
return lines, nil
}
func (p *postingLinesStore) ListByAccount(ctx context.Context, accountRef bson.ObjectID, limit int, offset int) ([]*model.PostingLine, error) {
if accountRef.IsZero() {
p.logger.Warn("attempt to list posting lines with zero account ID")
p.logger.Warn("Attempt to list posting lines with zero account ID")
return nil, merrors.InvalidArgument("postingLinesStore: zero account ID")
}
@@ -130,10 +130,10 @@ func (p *postingLinesStore) ListByAccount(ctx context.Context, accountRef bson.O
return nil
})
if err != nil {
p.logger.Warn("failed to list posting lines by account", zap.Error(err), mzap.AccRef(accountRef))
p.logger.Warn("Failed to list posting lines by account", zap.Error(err), mzap.AccRef(accountRef))
return nil, err
}
p.logger.Debug("listed posting lines by account", zap.Int("count", len(lines)), mzap.AccRef(accountRef))
p.logger.Debug("Listed posting lines by account", zap.Int("count", len(lines)), mzap.AccRef(accountRef))
return lines, nil
}