MCPcopy Create free account
hub / github.com/devaccuracy/ledgerforge / runTransactionPostCommitWorkWithHooks

Method runTransactionPostCommitWorkWithHooks

transaction.go:1112–1132  ·  view source on GitHub ↗

runTransactionPostCommitWorkWithHooks executes monitor checks, post-hooks, and post-transaction actions for persisted work items, optionally reusing a preloaded hook set.

(ctx context.Context, span trace.Span, orderedBalances []*model.Balance, postCommitWork []queuedBatchPostCommitWork, postHooks []*ledgerforgehooks.Hook)

Source from the content-addressed store, hash-verified

1110// runTransactionPostCommitWorkWithHooks executes monitor checks, post-hooks, and
1111// post-transaction actions for persisted work items, optionally reusing a preloaded hook set.
1112func (l *LedgerForge) runTransactionPostCommitWorkWithHooks(ctx context.Context, span trace.Span, orderedBalances []*model.Balance, postCommitWork []queuedBatchPostCommitWork, postHooks []*ledgerforgehooks.Hook) {
1113 for _, balance := range orderedBalances {
1114 go l.checkBalanceMonitors(ctx, balance)
1115 }
1116
1117 for _, work := range postCommitWork {
1118 if l.Hooks != nil {
1119 var err error
1120 if postHooks != nil {
1121 err = l.Hooks.ExecuteHooks(ctx, postHooks, ledgerforgehooks.PostTransaction, work.transaction.TransactionID, work.transaction)
1122 } else {
1123 err = l.Hooks.ExecutePostHooks(ctx, work.transaction.TransactionID, work.transaction)
1124 }
1125 if err != nil {
1126 span.RecordError(err)
1127 logrus.WithError(err).Error("post-transaction hooks failed")
1128 }
1129 }
1130 l.postTransactionActions(ctx, work.transaction, work.sourceBalance, work.destinationBalance)
1131 }
1132}
1133
1134// listHooksForExecution returns the current hook set for the requested type, or nil when
1135// hook execution is not configured for the current LedgerForge instance.

Calls 5

checkBalanceMonitorsMethod · 0.95
ExecuteHooksMethod · 0.65
ExecutePostHooksMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected