Skip to content

💰 Currency / PublicAPI / Batching

🎯 Purpose

The Batching folder provides a supported helper for grouping multiple currency operations into a single emitted batch event when supported by the composed service.

This is a convenience layer over internal batching behaviour and does not expose internal types.


⚠️ Important Notes

  • Batching is an optional capability
  • This helper does not enable batching
  • Behaviour depends on the composed service stack
  • Batching affects event emission only
  • Atomicity is not provided

🧩 What Lives Here

CurrencyBatching

  • Begin a batch using BeginBatch(...)
  • Control emission via a handle:

  • Emit() — emit the batch

  • Cancel() — discard the batch
  • Dispose() — ensure cleanup

🧠 Usage Guidance

Mental model

  • Batching is a capability, not a guarantee
  • This helper groups event emission, not execution behaviour
  • Operations still execute normally when batching is not supported

If batching is not supported:

  • The handle acts as a no-op

Usage pattern

using var batch = CurrencyBatching.BeginBatch(svc);

var r1 = svc.Debit(owner, gold, new Money(10));
if (!r1.Success) { batch.Cancel(); return; }

var r2 = svc.Credit(owner, gems, new Money(1));
if (!r2.Success) { batch.Cancel(); return; }

batch.Emit();

🧪 Diagnostics

  • Multiple events may indicate batching is not enabled in the service stack
  • Missing batch events may indicate capability is not present

🚫 Internal Use Only

This helper is part of the public API surface.

Do not:

  • Depend on internal batching implementations
  • Assume batching behaviour is always present

🧹 Safe to Remove

This folder may be removed if batching helpers are not required.

Currency will continue to operate without batch grouping.


  • PublicAPI / Helpers — composition (CurrencyFactories.WithBatchEvents)
  • PublicAPI / Transactions — higher-level operation grouping
  • Internal — batch implementation