pub(crate) use surrealdb_kvs::{Direction, TransactionBuilder, TransactionType, Val, consts, err};
pub(crate) mod export;
pub mod tasks;
mod clock;
pub(crate) mod ds;
#[cfg(test)]
pub(crate) mod compat;
pub(crate) mod index;
pub(crate) mod lightweight;
pub(crate) mod migration;
pub(crate) mod paging;
pub mod request;
pub(crate) mod slowlog;
#[cfg(test)]
pub(crate) mod test_support;
#[cfg(test)]
mod tests;
pub(crate) use consts::{
CHANGEFEED_GC_BATCH_SIZE, CHANGEFEED_GC_PASS_KEY_BUDGET, INDEX_COMPACTION_QUEUE_BATCH_SIZE,
INDEXING_BATCH_MAX_BYTES, INDEXING_BATCH_SIZE, INDEXING_PROBE_BATCH_SIZE, NORMAL_BATCH_SIZE,
RECLAIM_BATCH_SIZE, RECLAIM_PASS_ENTRY_QUOTA, RECLAIM_PASS_KEY_BUDGET,
};
pub use ds::{
Builder, Datastore, LiveQueryEngine, TransactionBuilderFactory, TransactionBuilderParts,
};
pub(crate) use err::Error;
pub use request::{Dialect, QueryRequest, QuerySource};
pub(crate) use surrealdb_datastore::IntoBytes;
pub(crate) use surrealdb_datastore::error::DatastoreError;
pub(crate) use surrealdb_datastore::{
TransactionConfig, TransactionFactory, cache, sequences, tasklease, tx, util, version,
};
pub(crate) use surrealdb_datastore::{
is_indeterminate_commit, is_retryable_transaction_conflict, is_shutdown_error, storage_error,
};
pub(crate) use tx::Transaction;
pub(crate) use crate::catalog::providers::CachePolicy;
pub(crate) fn is_conditional_write_conflict(err: &anyhow::Error) -> bool {
fn is_condition_error(e: &self::err::Error) -> bool {
matches!(
e,
self::err::Error::TransactionConditionNotMet
| self::err::Error::TransactionKeyAlreadyExists
)
}
storage_error(err).is_some_and(is_condition_error)
}
#[cfg(test)]
pub(crate) use surrealdb_datastore::testing;
#[cfg(test)]
mod retry_conflict_tests {
use super::is_retryable_transaction_conflict;
#[test]
fn retryable_transaction_conflict_accepts_direct_kvs_error() {
let err = anyhow::Error::new(super::Error::TransactionConflict("conflict".into()));
assert!(is_retryable_transaction_conflict(&err));
}
#[test]
fn retryable_transaction_conflict_accepts_wrapped_kvs_error() {
let err = anyhow::Error::new(crate::err::Error::Kvs(super::Error::TransactionConflict(
"conflict".into(),
)));
assert!(is_retryable_transaction_conflict(&err));
}
#[test]
fn retryable_transaction_conflict_rejects_non_retryable_errors() {
let err = anyhow::Error::new(super::Error::TransactionFinished);
assert!(!is_retryable_transaction_conflict(&err));
}
}