Trending

World technology news

→
Illustrative archive photograph of a developer writing code with unit tests.
crates.ioIn-depth report

Kernable SDK 0.4.1 publishes a Rust API for event-sourced business logic

The release documents separate Rust types for commands, events, queries, and aggregate state.

·crates.io
Reading progress0%

An SDK for event-sourced applications

Kernable SDK 0.4.1 was recorded on crates.io at 15:05:46 UTC on November 29 and has a separate Linux documentation build on Docs.rs. The interface is aimed at writing event-sourced business logic in Rust. Public types include `Aggregate`, `CommandContext`, `NewEvent`, `StoredEvent`, and `Query`. They give applications separate places to express responsibilities around event-derived state. The business still determines how a partial cancellation differs from a complete cancellation, for example.

A command requests a change

Consider an appointment that a dispatcher wants to move. The request is a command. The application checks whether the slot is available and the appointment can still change. An accepted command can produce an event describing the changed time. A rejected command leaves the schedule at its prior state. Test the stored event, the resulting appointment state, and what happens if the same request arrives again.

Rebuild state from a short history

A sequence might create an appointment, change its time, and then cancel it. The rules used to fold that history should produce a reproducible result. A function that reads the current wall clock during reconstruction can give different answers on different days. Store the relevant decision time in the event. The SDK's `FoldEvent` type is one part of the documented API surface. A three-event fixture makes the expected final state explicit.

Observe queries as well as events

A list of upcoming appointments is a query view rather than the event history itself. Test when a cancelled item leaves the view. If the stored event and query are updated at different times, define the expected delay. An empty list alone cannot prove the cancellation applied, as the appointment may never have existed. Compare the event identity with the visible list.

Check upgrade behavior with an old fixture

Retain a short history produced by the previous version. Give it to the upgraded application using the same business rules and compare event order and final state. If a field is renamed, document how existing events are interpreted. The Docs.rs build establishes the published API, while a fixture from the application establishes whether its own stored records can be read.

A reproducible acceptance record

A fixture can try to create the same appointment twice, accept one time change, then reject a change after cancellation. Record the event count, sequence numbers, and final state. Those observations let a reviewer distinguish the business contract from a successful API call. They also leave concrete evidence for comparing a later version using the same inputs. Retain the input sequence with the test result. A mismatch after an update can then be traced to its first changed event or projected view.

Archive photo · Joonspoon / Wikimedia Commons ↗ · CC BY-SA 4.0

Sources and verification
Be the first reader ✎ Write a comment

Reader discussion

Discussion prompt

Which bottleneck would you expect as this solution scales?

No comments yet. Be the first to contribute.

Write a comment

Comments are real visitor contributions. Repeated, link-heavy or abusive submissions may be limited.