STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
fsw::elodin::SubscriptionTracker Class Reference

#include <SubscriptionTracker.hpp>

Collaboration diagram for fsw::elodin::SubscriptionTracker:
[legend]

Public Types

using Table = std::pair<uint8_t, uint8_t>
using Clock = std::chrono::steady_clock

Public Member Functions

 SubscriptionTracker (std::chrono::milliseconds retry_after=std::chrono::seconds(1))
uint8_t assign (Table table)
 The request id to subscribe table under.
Table rejected (uint8_t request_id, Clock::time_point now)
 The DB refused the subscription sent under request_id.
std::vector< Table > due (Clock::time_point now)
 Refused tables whose wait is over; each is forgotten here until rejected again.
size_t refused () const
 Tables currently waiting to be asked for again.
void reset ()
 A new connection: every subscription is sent afresh.

Private Attributes

std::chrono::milliseconds retry_after_
uint8_t next_id_ = 1
std::map< uint8_t, Table > by_id_
std::map< Table, Clock::time_point > retry_at_

Detailed Description

Definition at line 36 of file SubscriptionTracker.hpp.

Member Typedef Documentation

◆ Clock

using fsw::elodin::SubscriptionTracker::Clock = std::chrono::steady_clock

Definition at line 39 of file SubscriptionTracker.hpp.

◆ Table

using fsw::elodin::SubscriptionTracker::Table = std::pair<uint8_t, uint8_t>

Definition at line 38 of file SubscriptionTracker.hpp.

Constructor & Destructor Documentation

◆ SubscriptionTracker()

fsw::elodin::SubscriptionTracker::SubscriptionTracker ( std::chrono::milliseconds retry_after = std::chrono::seconds(1))
inlineexplicit

Definition at line 41 of file SubscriptionTracker.hpp.

References retry_after_.

Member Function Documentation

◆ assign()

uint8_t fsw::elodin::SubscriptionTracker::assign ( Table table)
inline

The request id to subscribe table under.

Ids rotate through 1..254: 0 is what untracked subscriptions use, and 255 is the backend's subscription fence.

Definition at line 49 of file SubscriptionTracker.hpp.

References by_id_, and next_id_.

Referenced by main(), test_accepted_table_is_never_asked_for_twice(), test_ids_rotate_and_skip_0_and_255(), test_refused_table_is_asked_for_again(), and test_reset_forgets_everything().

◆ due()

std::vector< Table > fsw::elodin::SubscriptionTracker::due ( Clock::time_point now)
inline

Refused tables whose wait is over; each is forgotten here until rejected again.

Definition at line 71 of file SubscriptionTracker.hpp.

References retry_at_.

Referenced by main(), test_accepted_table_is_never_asked_for_twice(), test_refused_table_is_asked_for_again(), and test_reset_forgets_everything().

◆ refused()

size_t fsw::elodin::SubscriptionTracker::refused ( ) const
inline

Tables currently waiting to be asked for again.

Definition at line 85 of file SubscriptionTracker.hpp.

References retry_at_.

Referenced by test_accepted_table_is_never_asked_for_twice(), test_refused_table_is_asked_for_again(), and test_unknown_request_id_names_nothing().

◆ rejected()

Table fsw::elodin::SubscriptionTracker::rejected ( uint8_t request_id,
Clock::time_point now )
inline

The DB refused the subscription sent under request_id.

Returns the table it was for, so the caller can say which; {0, 0} for an id this tracker did not hand out.

Definition at line 60 of file SubscriptionTracker.hpp.

References by_id_, retry_after_, and retry_at_.

Referenced by main(), test_refused_table_is_asked_for_again(), test_reset_forgets_everything(), and test_unknown_request_id_names_nothing().

◆ reset()

void fsw::elodin::SubscriptionTracker::reset ( )
inline

A new connection: every subscription is sent afresh.

Definition at line 90 of file SubscriptionTracker.hpp.

References by_id_, and retry_at_.

Referenced by main(), and test_reset_forgets_everything().

Member Data Documentation

◆ by_id_

std::map<uint8_t, Table> fsw::elodin::SubscriptionTracker::by_id_
private

Definition at line 98 of file SubscriptionTracker.hpp.

Referenced by assign(), rejected(), and reset().

◆ next_id_

uint8_t fsw::elodin::SubscriptionTracker::next_id_ = 1
private

Definition at line 97 of file SubscriptionTracker.hpp.

Referenced by assign().

◆ retry_after_

std::chrono::milliseconds fsw::elodin::SubscriptionTracker::retry_after_
private

Definition at line 96 of file SubscriptionTracker.hpp.

Referenced by rejected(), and SubscriptionTracker().

◆ retry_at_

std::map<Table, Clock::time_point> fsw::elodin::SubscriptionTracker::retry_at_
private

Definition at line 99 of file SubscriptionTracker.hpp.

Referenced by due(), refused(), rejected(), and reset().


The documentation for this class was generated from the following file: