Skip to content

refactor: name the deliverBatch result type — DeliveryOutcome replaces Pair<OutboxEntry, DeliveryResult>#45

Merged
endrju19 merged 2 commits into
feature/kojak-73-kafka-deliver-batchfrom
refactor/delivery-outcome-type
May 14, 2026
Merged

refactor: name the deliverBatch result type — DeliveryOutcome replaces Pair<OutboxEntry, DeliveryResult>#45
endrju19 merged 2 commits into
feature/kojak-73-kafka-deliver-batchfrom
refactor/delivery-outcome-type

Conversation

@endrju19
Copy link
Copy Markdown
Collaborator

Summary

Replaces the anonymous tuple List<Pair<OutboxEntry, DeliveryResult>> on MessageDeliverer.deliverBatch with a named domain type List<DeliveryOutcome>. Same shape (two fields), better contract.

Why

The batch-delivery result is a domain concept, not a utility tuple — it deserves a name. Three concrete benefits:

Aspect Pair<OutboxEntry, DeliveryResult> DeliveryOutcome
Kotlin access pair.first / pair.second outcome.entry / outcome.result
Java access pair.getFirst() / pair.getSecond() outcome.getEntry() / outcome.getResult()
Extensibility Locked at 2 anonymous fields Optional attemptNumber, latencyMs, ... addable later
Domain modeling Tuple Named concept consistent with DeliveryResult / DeliveryInfo / MessageDeliverer

Why pre-release

Currently 0.2.0-SNAPSHOT, no external consumers. Renaming after release would be a breaking change in a public API. The cost now is ~30 minutes; the cost later is a major version bump.

Scope

  • New type: okapi-core/.../DeliveryOutcome.ktdata class DeliveryOutcome(val entry: OutboxEntry, val result: DeliveryResult)
  • Interface: MessageDeliverer.deliverBatch returns List<DeliveryOutcome>
  • CompositeMessageDeliverer: builds DeliveryOutcome instances; lookup map via .associate { it.entry to it.result }
  • KafkaMessageDeliverer: the public override constructs DeliveryOutcome on emission; the private SendOutcome sealed type is untouched
  • Tests: .first/.second.entry/.result; destructuring (entry, result) -> ... patterns unchanged (data-class componentN keeps working)
  • OutboxEntryProcessor: consumes via destructuring — zero changes

Base branch

Based on feature/kojak-73-kafka-deliver-batch (PR #40) — cumulative with that work. Merge order: PR #40 first, then this one.

Test plan

  • ./gradlew clean ktlintFormat ktlintCheck build -x :okapi-integration-tests:test — all modules build, full unit suite passes
  • :okapi-integration-tests:compileTestKotlin — integration test compiles against new signature

endrju19 added 2 commits May 14, 2026 11:49
…DeliveryOutcome on MessageDeliverer.deliverBatch

Public API cleanup: the per-entry batch-delivery report is now a named
domain type rather than an anonymous tuple. The result is the same shape
(two fields: entry + result), but with named accessors, Java-friendly
ergonomics, and room to grow.

Why now (pre-release):
- Named domain object > anonymous Pair in a public API — accessors
  (.entry / .result) carry meaning; Pair.first/Pair.second do not
- Java consumers: outcome.getEntry() / outcome.getResult() vs.
  pair.getFirst() / pair.getSecond() — consistent with the @JvmName
  effort already invested elsewhere
- Forward-compatible: optional fields (e.g. attemptNumber, latencyMs)
  can be added later without breaking callers; impossible with Pair
- Same shape across transports (Kafka, planned HTTP, planned RabbitMQ
  etc.) — extracting the abstraction now is cheaper than after release

Changes:
- New okapi-core type: DeliveryOutcome(entry, result)
- MessageDeliverer.deliverBatch signature: List<DeliveryOutcome>
- CompositeMessageDeliverer routing: builds DeliveryOutcome instances,
  uses .associate { it.entry to it.result } for lookup map
- KafkaMessageDeliverer override: constructs DeliveryOutcome on emission
- Tests updated: .first/.second → .entry/.result; destructuring
  (entry, result) patterns unchanged (data-class componentN works)

OutboxEntryProcessor consumes via destructuring — no change needed.
…fecycle intent

Per CLAUDE.md 'no redundant comments': first paragraph restated what
the signature and DeliveryResult subtypes already express. Second
paragraph (transient, never persisted) is the load-bearing insight.
@endrju19 endrju19 merged commit cf26f4c into feature/kojak-73-kafka-deliver-batch May 14, 2026
@endrju19 endrju19 deleted the refactor/delivery-outcome-type branch May 14, 2026 14:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants