pub struct AccountSyncer { /* private fields */ }Expand description
Account syncer - handles syncing clearinghouse state to upstream API
Implementations§
Source§impl AccountSyncer
impl AccountSyncer
Sourcepub fn new(config: AccountSyncerConfig) -> Result<Self, SyncError>
pub fn new(config: AccountSyncerConfig) -> Result<Self, SyncError>
Create a new account syncer with the given configuration
Sourcepub fn should_sync(&self) -> bool
pub fn should_sync(&self) -> bool
Check if it’s time to sync (based on interval)
Sourcepub fn set_metrics_snapshot(
&mut self,
snapshot: Option<PerformanceMetricsSnapshot>,
)
pub fn set_metrics_snapshot( &mut self, snapshot: Option<PerformanceMetricsSnapshot>, )
Set the latest performance metrics snapshot for sync metadata.
Sourcepub async fn sync(
&mut self,
account_state: &AccountState,
stop_bot: bool,
stop_reason: &str,
) -> Result<SyncResult, SyncError>
pub async fn sync( &mut self, account_state: &AccountState, stop_bot: bool, stop_reason: &str, ) -> Result<SyncResult, SyncError>
Sync account state to upstream API
Returns the PnL from the upstream API on success
Sourcepub async fn shutdown_sync(
&mut self,
account_state: &AccountState,
stop_reason: &str,
) -> Result<SyncResult, SyncError>
pub async fn shutdown_sync( &mut self, account_state: &AccountState, stop_reason: &str, ) -> Result<SyncResult, SyncError>
Perform final sync on shutdown (with stop_bot=true)
Trait Implementations§
Source§impl AccountSync for AccountSyncer
impl AccountSync for AccountSyncer
Source§fn should_sync(&self) -> bool
fn should_sync(&self) -> bool
Check if it’s time to sync based on interval
Source§fn set_metrics_snapshot(&mut self, snapshot: Option<PerformanceMetricsSnapshot>)
fn set_metrics_snapshot(&mut self, snapshot: Option<PerformanceMetricsSnapshot>)
Set the latest performance metrics snapshot to include in sync metadata.
Source§fn sync<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
account_state: &'life1 AccountState,
stop_bot: bool,
stop_reason: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<AccountSyncResult, SyncError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn sync<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
account_state: &'life1 AccountState,
stop_bot: bool,
stop_reason: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<AccountSyncResult, SyncError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Sync account state to upstream
Source§fn shutdown_sync<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
account_state: &'life1 AccountState,
stop_reason: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<AccountSyncResult, SyncError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn shutdown_sync<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
account_state: &'life1 AccountState,
stop_reason: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<AccountSyncResult, SyncError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Perform final sync on shutdown
Auto Trait Implementations§
impl !RefUnwindSafe for AccountSyncer
impl !UnwindSafe for AccountSyncer
impl Freeze for AccountSyncer
impl Send for AccountSyncer
impl Sync for AccountSyncer
impl Unpin for AccountSyncer
impl UnsafeUnpin for AccountSyncer
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