Skip to main content

crafty_client/
lib.rs

1//! `crafty-client` — client handles for talking to a crafty cluster (client-api).
2//!
3//! Two layers over a shared [`crafty_proto`] wire contract (client-api):
4//!
5//! * **In-process (L1):** embed a node and use its `crafty_actor::NodeHandle`
6//!   directly (`propose`/`query`) — no serialization, no network.
7//! * **Remote (L2):** [`RemoteClient`] speaks `postcard` over any
8//!   [`crafty_net`] transport (live QUIC/HTTP/3 with client mTLS, or the
9//!   in-memory `LocalNetwork` in tests). A follower transparently forwards to
10//!   the leader server-side (client-routing), so a client can connect to any node; the
11//!   built-in [`RetryPolicy`] adds failover + leader-follow for elections and
12//!   downed nodes.
13//!
14//! [`TypedClient`] wraps either layer with a
15//! [`StateMachine`](crafty_core::StateMachine)'s command/query/response types.
16
17pub use {crafty_core, crafty_net, crafty_proto};
18
19mod batch;
20mod error;
21mod remote;
22mod saga;
23mod two_phase;
24mod typed;
25
26pub use batch::{BatchError, KeyedBatchStep, propose_keyed_batch};
27pub use error::ClientError;
28pub use remote::{Client, KeyedClient, RemoteClient, RetryPolicy};
29pub use saga::{
30    InMemorySagaJournal, ResumeSagaOpts, RunSagaOpts, SagaError, SagaEvent, SagaJournal,
31    SagaJournalError, SagaJournalPhase, SagaJournalRecord, SagaOutcome, SagaPlan, SagaStep,
32    decode_journal_record, encode_journal_record, resume_saga, run_saga,
33};
34pub use two_phase::{
35    InMemoryTwoPhaseJournal, ResumeTwoPhaseOpts, RunTwoPhaseOpts, TwoPhaseClient, TwoPhaseError,
36    TwoPhaseEvent, TwoPhaseJournal, TwoPhaseJournalError, TwoPhaseJournalRecord,
37    decode_two_phase_journal_record, encode_two_phase_journal_record, propose_cross_shard_2pc,
38    propose_cross_shard_2pc_with_opts, resume_cross_shard_2pc,
39};
40pub use typed::TypedClient;