pub struct SyncEngine { /* private fields */ }Expand description
Sync engine for managing real-time synchronization
Implementations§
Source§impl SyncEngine
impl SyncEngine
Sourcepub fn with_db(event_bus: Arc<EventBus>, db: Pool<Sqlite>) -> Self
pub fn with_db(event_bus: Arc<EventBus>, db: Pool<Sqlite>) -> Self
Create a new sync engine with database support for state snapshots
Sourcepub fn with_integration(
event_bus: Arc<EventBus>,
db: Pool<Sqlite>,
core_bridge: Arc<CoreBridge>,
workspace_service: Arc<WorkspaceService>,
) -> Self
pub fn with_integration( event_bus: Arc<EventBus>, db: Pool<Sqlite>, core_bridge: Arc<CoreBridge>, workspace_service: Arc<WorkspaceService>, ) -> Self
Create a new sync engine with full integration
Sourcepub fn subscribe(
&self,
workspace_id: Uuid,
client_id: Uuid,
) -> Result<Receiver<ChangeEvent>>
pub fn subscribe( &self, workspace_id: Uuid, client_id: Uuid, ) -> Result<Receiver<ChangeEvent>>
Sourcepub fn publish_change(&self, event: ChangeEvent) -> Result<()>
pub fn publish_change(&self, event: ChangeEvent) -> Result<()>
Sourcepub fn get_state(&self, workspace_id: Uuid) -> Option<SyncState>
pub fn get_state(&self, workspace_id: Uuid) -> Option<SyncState>
Get current state for a workspace
Sourcepub async fn get_full_workspace_state(
&self,
workspace_id: Uuid,
) -> Result<Option<Value>>
pub async fn get_full_workspace_state( &self, workspace_id: Uuid, ) -> Result<Option<Value>>
Get full workspace state for a workspace
Uses CoreBridge to get the complete workspace state including all mocks.
§Errors
Returns an error if the workspace cannot be retrieved.
Sourcepub async fn load_state_snapshot(
&self,
workspace_id: Uuid,
version: Option<i64>,
) -> Result<Option<SyncState>>
pub async fn load_state_snapshot( &self, workspace_id: Uuid, version: Option<i64>, ) -> Result<Option<SyncState>>
Load state snapshot from database
§Errors
Returns an error if the database is not available or the query fails.
Sourcepub async fn record_state_change(
&self,
workspace_id: Uuid,
change_type: &str,
change_data: Value,
version: i64,
user_id: Uuid,
) -> Result<()>
pub async fn record_state_change( &self, workspace_id: Uuid, change_type: &str, change_data: Value, version: i64, user_id: Uuid, ) -> Result<()>
Record a state change for incremental sync
§Errors
Returns an error if the database is not available or the insert fails.
Sourcepub async fn get_state_changes_since(
&self,
workspace_id: Uuid,
since_version: i64,
) -> Result<Vec<Value>>
pub async fn get_state_changes_since( &self, workspace_id: Uuid, since_version: i64, ) -> Result<Vec<Value>>
Get state changes since a specific version
§Errors
Returns an error if the database is not available or the query fails.
Sourcepub fn get_connections(&self, workspace_id: Uuid) -> Vec<Uuid>
pub fn get_connections(&self, workspace_id: Uuid) -> Vec<Uuid>
Get connected clients for a workspace
Sourcepub fn connection_count(&self) -> usize
pub fn connection_count(&self) -> usize
Get total number of connections
Sourcepub fn has_connections(&self, workspace_id: Uuid) -> bool
pub fn has_connections(&self, workspace_id: Uuid) -> bool
Check if a workspace has any active connections
Sourcepub fn cleanup_inactive(&self)
pub fn cleanup_inactive(&self)
Clean up inactive workspaces (no connections)
Auto Trait Implementations§
impl Freeze for SyncEngine
impl !RefUnwindSafe for SyncEngine
impl Send for SyncEngine
impl Sync for SyncEngine
impl Unpin for SyncEngine
impl UnsafeUnpin for SyncEngine
impl !UnwindSafe for SyncEngine
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more