persistSingleTransactionExecutionWork atomically persists one prepared transaction, its updated balances, and any lineage outbox using the shared execution work shape.
(ctx context.Context, work queuedBatchPostCommitWork)
| 1277 | // persistSingleTransactionExecutionWork atomically persists one prepared transaction, its |
| 1278 | // updated balances, and any lineage outbox using the shared execution work shape. |
| 1279 | func (l *LedgerForge) persistSingleTransactionExecutionWork(ctx context.Context, work queuedBatchPostCommitWork) (queuedBatchPostCommitWork, error) { |
| 1280 | ctx, span := tracer.Start(ctx, "PersistSingleTransactionExecutionWork") |
| 1281 | defer span.End() |
| 1282 | |
| 1283 | transaction, err := l.datasource.RecordTransactionWithBalancesAndOutbox(ctx, work.transaction, work.sourceBalance, work.destinationBalance, work.outbox) |
| 1284 | if err != nil { |
| 1285 | span.RecordError(err) |
| 1286 | return queuedBatchPostCommitWork{}, l.logAndRecordError(span, "failed to persist transaction with balances", err) |
| 1287 | } |
| 1288 | |
| 1289 | work.transaction = transaction |
| 1290 | span.AddEvent("Transaction and balances persisted atomically", trace.WithAttributes( |
| 1291 | attribute.String("transaction.id", transaction.TransactionID), |
| 1292 | attribute.Bool("lineage.outbox_created", work.outbox != nil), |
| 1293 | )) |
| 1294 | |
| 1295 | return work, nil |
| 1296 | } |
| 1297 | |
| 1298 | func (l *LedgerForge) prepareTransactionOutbox(ctx context.Context, transaction *model.Transaction, sourceBalance, destinationBalance *model.Balance) *model.LineageOutbox { |
| 1299 | if transaction.Status != StatusApplied && transaction.Status != StatusInflight { |
no test coverage detected