Μετάβαση στο περιεχόμενο

buildIdempotencyAttributes

Αυτό το περιεχόμενο δεν είναι ακόμη διαθέσιμο στη γλώσσα σου.

buildIdempotencyAttributes(context): Record<string, boolean>

Defined in: packages/pipeline-idempotency/src/helpers/build-attributes.ts:57

The idempotency decision of one execution as flat attributes: idempotency.replayed once IdempotencyBehavior decided whether to replay, and idempotency.ownership_lost: true only when the claim was lost while the handler ran. {} when the behavior did not run. The key is never included: it carries the tenant, the principal and the client’s operation id.

The result is plain data and needs no telemetry package: put it on a span, a log line, an audit record or a metric label (bounded values only).

IPipelineContext

The pipeline execution, read after IdempotencyBehavior ran.

Record<string, boolean>

The attributes; empty when the behavior did not run.

Span attributes

With AttributesBehavior of @cqrs-ddd/pipeline-opentelemetry:

createPipeline({
  globalBehaviors: {
    before: [TraceBehavior, [AttributesBehavior, { factories: [buildIdempotencyAttributes] }]],
  },
});

Audit metadata

audit() is declared outside idempotent(), so the record is built after its decision:

@pipeline.wrap(
  { kind: 'command' },
  audit({ action: 'order.create', metadata: buildIdempotencyAttributes }),
  idempotent({ keyFactory }),
)

A log line from a custom behavior, after the chain ran

async handle(context: IPipelineContext, next: NextDelegate) {
  try {
    return await next();
  } finally {
    this.logger.log({ request: context.requestName, ...buildIdempotencyAttributes(context) });
  }
}