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>>
Subscribe a client to a workspace
Sourcepub fn unsubscribe(&self, workspace_id: Uuid, client_id: Uuid) -> Result<()>
pub fn unsubscribe(&self, workspace_id: Uuid, client_id: Uuid) -> Result<()>
Unsubscribe a client from a workspace
Sourcepub fn publish_change(&self, event: ChangeEvent) -> Result<()>
pub fn publish_change(&self, event: ChangeEvent) -> Result<()>
Publish a change event
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 fn update_state(&self, workspace_id: Uuid, new_state: Value) -> Result<()>
pub fn update_state(&self, workspace_id: Uuid, new_state: Value) -> Result<()>
Update 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.
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
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
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
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 !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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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