You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor: require callbacks at construction time to prevent leaky abstraction bugs (#570)
This refactor prevents the class of bug where Start/Reconnect could be called
without callbacks configured, resulting in frozen output display.
Changes:
- Add ManagerCallbacks struct to ManagerOptions for construction-time callbacks
- Add ErrManagerNotConfigured sentinel error returned by Start/StartWithResume/Reconnect
- Add runtime guards that check the 'configured' flag before starting
- Log warning when monitor-bell fails in Reconnect instead of silent ignore
- Propagate configuration errors in ReconnectInstance instead of masking them
- Deprecate Set*Callback methods (kept for backward compatibility)
- Remove dead code: RecoverSession() and configureInstanceCallbacks()
- Add comprehensive tests for guard behavior
Copy file name to clipboardExpand all lines: CHANGELOG.md
+12Lines changed: 12 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,6 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
8
8
## [Unreleased]
9
9
10
+
### Changed
11
+
12
+
-**Instance Manager Callbacks Required at Construction** - Callbacks (OnStateChange, OnMetrics, OnTimeout, OnBell) are now passed via `ManagerCallbacks` struct in `ManagerOptions` at construction time, rather than being set separately via setter methods. This prevents the "leaky abstraction" bug where `Start()`/`Reconnect()` could be called without callbacks configured. The callback setter methods are now deprecated.
13
+
14
+
-**Runtime Guards on Instance Lifecycle Methods** - `Start()`, `StartWithResume()`, and `Reconnect()` now return `ErrManagerNotConfigured` if the Manager was not properly constructed via `NewManagerWithDeps`. This provides defense-in-depth against misconfigured managers.
15
+
16
+
-**Improved Error Handling** - The `Reconnect()` method now logs a warning if enabling monitor-bell fails, instead of silently ignoring the error. The `ReconnectInstance()` fallback logic now properly propagates configuration errors instead of masking them.
17
+
18
+
### Removed
19
+
20
+
-**Dead Code Cleanup** - Removed unused `RecoverSession()` method from orchestrator that had duplicate (and incomplete) callback configuration code, which was missing the metrics callback. Also removed the now-unused `configureInstanceCallbacks()` method since callbacks are configured at construction time.
0 commit comments