Expand description
crafty-client — client handles for talking to a crafty cluster (client-api).
Two layers over a shared crafty_proto wire contract (client-api):
- In-process (L1): embed a node and use its
crafty_actor::NodeHandledirectly (propose/query) — no serialization, no network. - Remote (L2):
RemoteClientspeakspostcardover anycrafty_nettransport (live QUIC/HTTP/3 with client mTLS, or the in-memoryLocalNetworkin tests). A follower transparently forwards to the leader server-side (client-routing), so a client can connect to any node; the built-inRetryPolicyadds failover + leader-follow for elections and downed nodes.
TypedClient wraps either layer with a
StateMachine’s command/query/response types.
Re-exports§
pub use crafty_core;pub use crafty_net;pub use crafty_proto;
Structs§
- InMemory
Saga Journal - In-memory journal for unit tests.
- InMemory
TwoPhase Journal - In-memory 2PC journal (tests and single-process coordinators).
- Keyed
Batch Step - One keyed write in a
propose_keyed_batch. - Remote
Client - A remote client that talks to a crafty cluster over any
Transport(live QUIC/HTTP/3 in production, the in-memoryLocalNetworkin tests). - Resume
Saga Opts - Hooks for
resume_saga(journal required). - Resume
TwoPhase Opts - Hooks for
resume_cross_shard_2pc. - Retry
Policy - How a
RemoteClientretries across nodes and elections (backlog F4). - RunSaga
Opts - Optional hooks for
run_saga. - RunTwo
Phase Opts - Hooks for
propose_cross_shard_2pc. - Saga
Journal Record - Durable saga progress (journal value).
- Saga
Plan - Ordered cross-shard write plan executed by
run_saga. - Saga
Step - One forward step with a compensating keyed write on the same shard.
- TwoPhase
Journal Record - Client-side durable progress for cross-shard 2PC resume.
- Typed
Client - A strongly-typed view over any
Client, carrying aStateMachine’s command/query/response types so callers work with real Rust values instead ofpostcardbyte vectors.
Enums§
- Batch
Error - Why a multi-shard batch stopped early.
- Client
Error - Why a client request could not be completed.
- Saga
Error - Why a saga could not finish cleanly.
- Saga
Event - Lifecycle events for metrics / logging (see cross-shard-transactions ADR).
- Saga
Journal Error - Journal persistence failure.
- Saga
Journal Phase - Journal phase for resume / observability.
- Saga
Outcome - Outcome of a saga run.
- TwoPhase
Error - Why a cross-shard 2PC attempt failed.
- TwoPhase
Event - Lifecycle events for metrics / logging (see cross-shard-transactions ADR).
- TwoPhase
Journal Error - Journal persistence failure.
Traits§
- Client
- A cluster client: submit an application-encoded write (
propose) or linearizable read (query) and get the application-encoded response back. - Keyed
Client - Extension of
Clientfor shard-aware multi-Raft routing (write-sharding-multi-raft). - Saga
Journal - Object-safe saga journal (Redis, group-0 side channel, in-memory tests).
- TwoPhase
Client - Extension of
KeyedClientfor limited cross-shard 2PC. - TwoPhase
Journal - Optional journal hook for
propose_cross_shard_2pc/resume_cross_shard_2pc.
Functions§
- decode_
journal_ record - Decode a
SagaJournalRecord. - decode_
two_ phase_ journal_ record - Postcard-decode a
TwoPhaseJournalRecord. - encode_
journal_ record - Encode a
SagaJournalRecordfor external stores. - encode_
two_ phase_ journal_ record - Postcard-encode a
TwoPhaseJournalRecordfor Meta-Raft / Redis storage. - propose_
cross_ shard_ 2pc - Execute prepare-all then commit-all, aborting prepared steps on prepare failure.
- propose_
cross_ shard_ 2pc_ with_ opts - Like
propose_cross_shard_2pcwith an optional client journal. - propose_
keyed_ batch - Propose each step to its owning Raft group in order. Not atomic across groups — if a later step fails, earlier writes remain committed (saga-style callers must compensate explicitly).
- resume_
cross_ shard_ 2pc - Continue a cross-shard 2PC after partial progress or coordinator restart.
- resume_
saga - Continue a saga from its durable journal record.
- run_
saga - Execute
planforward; on failure run compensators in reverse for committed steps.