-
Notifications
You must be signed in to change notification settings - Fork 1
feat: Connection and Upload Managers use config from Config Manager #280
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: ndd-dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,26 +25,33 @@ class ConnectionManager: | |
|
|
||
| def __init__( | ||
| self, | ||
| *, | ||
| timeout: float = 5.0, | ||
| check_interval: float = 10.0, | ||
| offline_mode: bool = False, | ||
| ) -> None: | ||
| """Initialize the connection manager. | ||
|
|
||
| Args: | ||
| emitter: Event emitter for broadcasting connection state | ||
| config_manager: Config to resolve for Connection Manager | ||
| timeout: Timeout in seconds for connectivity checks | ||
| check_interval: Seconds between connectivity checks | ||
| offline_mode: Daemon is in offline mode; skip connectivity checks | ||
| """ | ||
| self._timeout = timeout | ||
| self._check_interval = check_interval | ||
| self._is_connected = False | ||
| self._running = False | ||
| self._checker_thread: threading.Thread | None = None | ||
| self._offline_mode = offline_mode | ||
|
|
||
| emitter.emit(Emitter.IS_CONNECTED, self._is_connected) | ||
|
|
||
| def start(self) -> None: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We just have to remember to execute start during integration |
||
| """Start the connection monitoring thread.""" | ||
| if self._offline_mode: | ||
| logger.info("ConnectionManager in offline mode") | ||
| return | ||
| if self._running: | ||
| logger.warning("ConnectionManager already running") | ||
| return | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit or lets note down or create a task in backlog |
||
|
|
@@ -64,6 +71,9 @@ def stop(self, timeout: float = 5.0) -> None: | |
| Args: | ||
| timeout: Maximum time to wait for thread to stop | ||
| """ | ||
| if self._offline_mode: | ||
| logger.info("ConnectionManager in offline mode") | ||
| return | ||
| if not self._running: | ||
| logger.warning("ConnectionManager not running") | ||
| return | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This assumes that StateManager init before ConnectionManager. This is a race condition risk. The pyee.EventEmitter is a standard pub/sub pattern - events are NOT queued. If no listener is registered when the event fires, it's lost.
We need to make sure that StateManager gets the right state at init/start, can even directly read from config, if event is lost no problem.