@@ -286,12 +286,14 @@ class SessionExt {
286
286
// / @brief Create default option settings.
287
287
static CacheOptions create_default () { return {}; }
288
288
};
289
- // @brief Settings allowing matching Subscribers to detect lost samples and optionally ask for retransimission.
289
+
290
+ // / @brief Settings allowing matching Subscribers to detect lost samples and optionally ask for retransimission.
290
291
struct SampleMissDetectionOptions {
291
- // The period of publisher heartbeats in ms, which can be used by ``AdvancedSubscriber`` for missed sample
292
- // detection (if heartbeat-based recovery is enabled). If this value is unset, the subscribers will only be
293
- // notified about missed samples if they opt to send periodic queries.
292
+ // / The period of publisher heartbeats in ms, which can be used by ``AdvancedSubscriber`` for missed sample
293
+ // / detection (if heartbeat-based recovery is enabled).
294
+ // / Otherwise, missed samples will be retransmitted based on Advanced Subscriber queries.
294
295
std::optional<uint64_t > heartbeat_period_ms = {};
296
+
295
297
// / @brief Create default option settings.
296
298
static SampleMissDetectionOptions create_default () { return {}; }
297
299
};
@@ -392,14 +394,32 @@ class SessionExt {
392
394
struct RecoveryOptions {
393
395
// / @name Fields
394
396
395
- // / @brief Period for queries for not yet received Samples.
396
- // /
397
- // / These queries allow to retrieve the last Sample(s) if the last Sample(s) is/are lost.
398
- // / So it is useful for sporadic publications but useless for periodic publications
399
- // / with a period smaller or equal to this period.
400
- // / If unset, the subscriber will be instead notified about missed samples through ``AdvancedPublisher``
401
- // / heartbeats (if enabled on publisher side).
402
- std::optional<uint64_t > periodic_queries_period_ms = {};
397
+ // / @brief Option tag for Heartbeat-based last sample detection.
398
+ struct Heartbeat {};
399
+
400
+ // / @brief Settings for periodic queries-based last sample detection.
401
+ struct PeriodicQueriesOptions {
402
+ // / @name Fields
403
+
404
+ // / @brief Period for queries for not yet received Samples.
405
+ // /
406
+ // / These queries allow to retrieve the last Sample(s) if the last Sample(s) is/are lost.
407
+ // / So it is useful for sporadic publications but useless for periodic publications
408
+ // / with a period smaller or equal to this period.
409
+ uint64_t period_ms = 1000 ;
410
+
411
+ // / @name Methods
412
+
413
+ // / @brief Create default option settings.
414
+ static PeriodicQueriesOptions create_default () { return {}; };
415
+ };
416
+
417
+ // / @brief Setting for detecting last sample(s) miss.
418
+ // / Note that it does not affect intermediate sample miss detection/retrieval (which is performed
419
+ // / automatically as long as recovery is enabled). If this option is disabled, subscriber will be unable to
420
+ // / detect/request retransmission of missed sample until it receives a more recent one from the same
421
+ // / publisher.
422
+ std::optional<std::variant<Heartbeat, PeriodicQueriesOptions>> last_sample_miss_detection = {};
403
423
404
424
// / @name Methods
405
425
@@ -443,12 +463,18 @@ class SessionExt {
443
463
}
444
464
if (this ->recovery .has_value ()) {
445
465
opts.recovery .is_enabled = true ;
446
- if (this ->recovery ->periodic_queries_period_ms .has_value ()) {
447
- // treat 0 as very small delay
448
- opts.recovery .periodic_queries_period_ms =
449
- std::max<uint64_t >(1 , this ->recovery ->periodic_queries_period_ms .value ());
450
- } else {
451
- opts.recovery .periodic_queries_period_ms = 0 ;
466
+ if (this ->recovery ->last_sample_miss_detection .has_value ()) {
467
+ opts.recovery .last_sample_miss_detection .is_enabled = true ;
468
+ if (std::holds_alternative<RecoveryOptions::Heartbeat>(
469
+ this ->recovery ->last_sample_miss_detection .value ())) {
470
+ opts.recovery .last_sample_miss_detection .periodic_queries_period_ms = 0 ;
471
+ } else {
472
+ // treat 0 as very small delay
473
+ opts.recovery .last_sample_miss_detection .periodic_queries_period_ms =
474
+ std::max<uint64_t >(1 , std::get<RecoveryOptions::PeriodicQueriesOptions>(
475
+ this ->recovery ->last_sample_miss_detection .value ())
476
+ .period_ms );
477
+ }
452
478
}
453
479
}
454
480
opts.query_timeout_ms = this ->query_timeout_ms ;
0 commit comments