@@ -1207,11 +1207,17 @@ pub trait OnionMessageProvider {
1207
1207
///
1208
1208
/// # Requirements
1209
1209
///
1210
- /// See [`process_pending_events`] for requirements around event processing.
1211
- ///
1212
1210
/// When using this trait, [`process_pending_events`] will call [`handle_event`] for each pending
1213
- /// event since the last invocation. The handler must either act upon the event immediately
1214
- /// or preserve it for later handling.
1211
+ /// event since the last invocation.
1212
+ ///
1213
+ /// In order to ensure no [`Event`]s are lost, implementors of this trait will persist [`Event`]s
1214
+ /// and replay any unhandled events on startup. An [`Event`] is considered handled when
1215
+ /// [`process_pending_events`] returns, thus handlers MUST fully handle [`Event`]s and persist any
1216
+ /// relevant changes to disk *before* returning.
1217
+ ///
1218
+ /// Further, because an application may crash between an [`Event`] being handled and the
1219
+ /// implementor of this trait being re-serialized, [`Event`] handling must be idempotent - in
1220
+ /// effect, [`Event`]s may be replayed.
1215
1221
///
1216
1222
/// Note, handlers may call back into the provider and thus deadlocking must be avoided. Be sure to
1217
1223
/// consult the provider's documentation on the implication of processing events and how a handler
@@ -1228,9 +1234,7 @@ pub trait OnionMessageProvider {
1228
1234
pub trait EventsProvider {
1229
1235
/// Processes any events generated since the last call using the given event handler.
1230
1236
///
1231
- /// Subsequent calls must only process new events. However, handlers must be capable of handling
1232
- /// duplicate events across process restarts. This may occur if the provider was recovered from
1233
- /// an old state (i.e., it hadn't been successfully persisted after processing pending events).
1237
+ /// See the trait-level documentation for requirements.
1234
1238
fn process_pending_events < H : Deref > ( & self , handler : H ) where H :: Target : EventHandler ;
1235
1239
}
1236
1240
0 commit comments