pub struct SequenceServer { /* private fields */ }
Expand description
Server components should use class to guarantee clients see all messages sent by the server prior to system suspension. After creating a |SequenceServer| server components should call |manage| to start this management.
Then server components should use the |MessageSendTracker| returned from |get_message_tracker| to record when messages are sent and deposit hanging-GET requests for batons. Batons are sent to the client whenever the system starts to suspend (as indicated by a SuspendStarted callback from SystemActivityGovernor) AND messages count of sent messages is greater than the last time a baton was sent to a the client AND a hanging-GET request is pending.
Implementations§
Source§impl SequenceServer
impl SequenceServer
Sourcepub async fn new(sag: ActivityGovernorProxy) -> Self
pub async fn new(sag: ActivityGovernorProxy) -> Self
Creates a SequenceServer, but does not kick off its logic. |manage| MUST be called to start monitoring for suspend and managing baton hand- offs.
Sourcepub fn manage(
self,
) -> (Arc<Mutex<MessageSendTracker>>, impl Future<Output = Result<Self, Error>>)
pub fn manage( self, ) -> (Arc<Mutex<MessageSendTracker>>, impl Future<Output = Result<Self, Error>>)
Returns a future which manages baton passing and a reference to the |MessageSendTracker| clients use to report message sends. The returned future must be polled for as long as batons need to be delivered. The future returns, yielding the |SequenceServer| if the channel to ActivityGovernor passed to |new| closes.
To stop managing batons, simply drop the future. The |MessageSendTracker| should not be used after the future returns.