|
SimCore
Shared transport-layer plumbing for the ADR-029 Train/IL/CTC RBC simulators
|
Public Member Functions | |
| __init__ (self, log, targets, message_size) | |
| ensure_connected (self) | |
| connected_sites (self) | |
| disconnect (self, site) | |
| send_all (self, payload) | |
| poll_recv (self, timeout=0.0) | |
Public Attributes | |
| log = log | |
| targets = targets | |
| message_size = message_size | |
| dict | sockets = {site: None for site in SITES} |
| sel = selectors.DefaultSelector() | |
Protected Member Functions | |
| _handshake (self, site) | |
| _close (self, site) | |
Definition at line 45 of file dual_link.py.
| simcore.dual_link.DualHomedLink.__init__ | ( | self, | |
| log, | |||
| targets, | |||
| message_size ) |
@param targets: {"WEST": (host, port), "EAST": (host, port)}
Definition at line 46 of file dual_link.py.
|
protected |
Definition at line 199 of file dual_link.py.
|
protected |
Definition at line 65 of file dual_link.py.
| simcore.dual_link.DualHomedLink.connected_sites | ( | self | ) |
Returns the list of currently-connected site names - generic transport-layer state a caller's own application layer can use for its own purposes (e.g. a "which site do I currently believe is reachable" heuristic); this module has no opinion on what that purpose is.
Definition at line 126 of file dual_link.py.
| simcore.dual_link.DualHomedLink.disconnect | ( | self, | |
| site ) |
Closes this site's connection right now, if open - the sim's own main loop reconnects it automatically on its next ensure_connected() call, per this project's reconnect-forever convention (this file's own header). Public wrapper around the same internal close a real send/recv failure already uses (_close) - a test-harness-triggered disconnect and a genuine network failure look identical from here on, deliberately: that is exactly the condition a disconnect test wants to reproduce.
Definition at line 134 of file dual_link.py.
| simcore.dual_link.DualHomedLink.ensure_connected | ( | self | ) |
Bounded (HANDSHAKE_BUDGET_S) HELLO/HELLO-ACK attempt for each not-yet-connected site, per call - short enough not to stall the sim's own overall pacing for long, retried forever (call this every loop iteration) until it succeeds, matching this project's own C-side reconnect-forever convention.
Definition at line 54 of file dual_link.py.
| simcore.dual_link.DualHomedLink.poll_recv | ( | self, | |
| timeout = 0.0 ) |
Yields (site, payload) for each ready socket - see this module's own header for the "one recv() == one datagram" note. Honors @timeout (actually sleeps for it) even while NEITHER site is connected yet, rather than returning instantly - a caller that relies on this call for its own loop's pacing (as every sim here does) would otherwise busy-loop, spamming reconnect attempts as fast as the CPU allows, whenever both sites are simultaneously down (selectors.BaseSelector.select() itself provides no timeout behavior at all when it has nothing registered to select on).
Definition at line 161 of file dual_link.py.
| simcore.dual_link.DualHomedLink.send_all | ( | self, | |
| payload ) |
Sends @payload to every currently-connected site - both sites must see identical inputs (mirrors this project's C-side broadcast-to-both-A-and-B convention), since only whichever site is ONLINE will actually act on it. Silently skips a not-yet- connected site; closes+reconnects on a genuine send failure.
Definition at line 145 of file dual_link.py.
| simcore.dual_link.DualHomedLink.log = log |
Definition at line 48 of file dual_link.py.
| simcore.dual_link.DualHomedLink.message_size = message_size |
Definition at line 50 of file dual_link.py.
| simcore.dual_link.DualHomedLink.sel = selectors.DefaultSelector() |
Definition at line 52 of file dual_link.py.
| dict simcore.dual_link.DualHomedLink.sockets = {site: None for site in SITES} |
Definition at line 51 of file dual_link.py.
| simcore.dual_link.DualHomedLink.targets = targets |
Definition at line 49 of file dual_link.py.