Skip to content

Commit fd77985

Browse files
committed
move ReplayError to mod Replay
1 parent 69e8213 commit fd77985

2 files changed

Lines changed: 17 additions & 19 deletions

File tree

crates/datastore/src/locking_tx_datastore/datastore.rs

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ use spacetimedb_lib::{ConnectionId, Identity};
3333
use spacetimedb_paths::server::SnapshotDirPath;
3434
use spacetimedb_primitives::{ColId, ColList, ConstraintId, IndexId, SequenceId, TableId, ViewId};
3535
use spacetimedb_sats::memory_usage::MemoryUsage;
36-
use spacetimedb_sats::{bsatn, AlgebraicValue, ProductValue};
36+
use spacetimedb_sats::{AlgebraicValue, ProductValue};
3737
use spacetimedb_schema::table_name::TableName;
3838
use spacetimedb_schema::{
3939
reducer_name::ReducerName,
@@ -48,7 +48,6 @@ use spacetimedb_table::{
4848
use std::borrow::Cow;
4949
use std::sync::Arc;
5050
use std::time::{Duration, Instant};
51-
use thiserror::Error;
5251

5352
pub type Result<T> = std::result::Result<T, DatastoreError>;
5453

@@ -999,18 +998,6 @@ impl Locking {
999998
}
1000999
}
10011000

1002-
#[derive(Debug, Error)]
1003-
pub enum ReplayError {
1004-
#[error("Expected tx offset {expected}, encountered {encountered}")]
1005-
InvalidOffset { expected: u64, encountered: u64 },
1006-
#[error(transparent)]
1007-
Decode(#[from] bsatn::DecodeError),
1008-
#[error(transparent)]
1009-
Db(#[from] DatastoreError),
1010-
#[error(transparent)]
1011-
Any(#[from] anyhow::Error),
1012-
}
1013-
10141001
/// Construct a [`Metadata`] from the given [`RowRef`],
10151002
/// reading only the columns necessary to construct the value.
10161003
fn metadata_from_row(row: RowRef<'_>) -> Result<Metadata> {
@@ -1041,7 +1028,6 @@ pub(crate) mod tests {
10411028
};
10421029
use crate::traits::{IsolationLevel, MutTx};
10431030
use crate::Result;
1044-
use bsatn::to_vec;
10451031
use core::{fmt, mem};
10461032
use itertools::Itertools;
10471033
use pretty_assertions::{assert_eq, assert_matches};
@@ -1053,7 +1039,7 @@ pub(crate) mod tests {
10531039
use spacetimedb_lib::{resolved_type_via_v9, ScheduleAt, TimeDuration};
10541040
use spacetimedb_primitives::{col_list, ArgId, ColId, ScheduleId, ViewId};
10551041
use spacetimedb_sats::algebraic_value::ser::value_serialize;
1056-
use spacetimedb_sats::bsatn::ToBsatn;
1042+
use spacetimedb_sats::bsatn::{to_vec, ToBsatn};
10571043
use spacetimedb_sats::layout::RowTypeLayout;
10581044
use spacetimedb_sats::raw_identifier::RawIdentifier;
10591045
use spacetimedb_sats::{product, AlgebraicType, GroundSpacetimeType, SumTypeVariant, SumValue};

crates/datastore/src/locking_tx_datastore/replay.rs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
use super::committed_state::CommittedState;
22
use super::datastore::{Locking, Result};
33
use crate::db_metrics::DB_METRICS;
4-
use crate::error::{IndexError, TableError};
5-
use crate::locking_tx_datastore::datastore::ReplayError;
4+
use crate::error::{DatastoreError, IndexError, TableError};
65
use crate::locking_tx_datastore::state_view::{iter_st_column_for_table, StateView};
76
use crate::system_tables::{
87
is_built_in_meta_row, StColumnRow, StFields as _, StTableFields, StTableRow, ST_COLUMN_ID, ST_TABLE_ID,
@@ -20,13 +19,14 @@ use spacetimedb_lib::Identity;
2019
use spacetimedb_primitives::{ColId, ColList, TableId};
2120
use spacetimedb_sats::algebraic_value::de::ValueDeserializer;
2221
use spacetimedb_sats::buffer::BufReader;
23-
use spacetimedb_sats::{AlgebraicValue, Deserialize, ProductValue};
22+
use spacetimedb_sats::{bsatn, AlgebraicValue, Deserialize, ProductValue};
2423
use spacetimedb_schema::schema::{ColumnSchema, TableSchema};
2524
use spacetimedb_schema::table_name::TableName;
2625
use spacetimedb_table::indexes::RowPointer;
2726
use spacetimedb_table::table::{InsertError, RowRef};
2827
use std::cell::RefCell;
2928
use std::sync::Arc;
29+
use thiserror::Error;
3030

3131
pub fn apply_history(
3232
datastore: &Locking,
@@ -90,6 +90,18 @@ pub struct ApplyHistoryCounters {
9090
pub replay_commitlog_num_commits: IntGauge,
9191
}
9292

93+
#[derive(Debug, Error)]
94+
pub enum ReplayError {
95+
#[error("Expected tx offset {expected}, encountered {encountered}")]
96+
InvalidOffset { expected: u64, encountered: u64 },
97+
#[error(transparent)]
98+
Decode(#[from] bsatn::DecodeError),
99+
#[error(transparent)]
100+
Db(#[from] DatastoreError),
101+
#[error(transparent)]
102+
Any(#[from] anyhow::Error),
103+
}
104+
93105
/// A [`spacetimedb_commitlog::Decoder`] suitable for replaying a transaction
94106
/// history into the database state.
95107
pub struct Replay<F> {

0 commit comments

Comments
 (0)