ssh: Add event_funs option for unified event callbacks#11034
Open
u3s wants to merge 3 commits into
Open
Conversation
Replace positional arguments in send_disconnect/6,7 and disconnect/4 with a single map carrying code, details, module, line, and state_name. This simplifies call sites and makes the disconnect context extensible for future enrichment (e.g. event callbacks). - send_disconnect/6,7 -> send_disconnect/2,3 with map argument - disconnect/4 -> disconnect/1 with map argument - Rename macros to uppercase: ?send_disconnect -> ?SEND_DISCONNECT, ?DISCONNECT -> ?DISCONNECT_CONTEXT - Update ssh_dbg disconnect tracing to match new arities - Fix variable shadowing bug in terminate/3 where Reason was rebound to "Internal error" - Update all call sites across ssh_connection_handler, ssh_transport, ssh_fsm_kexinit, ssh_fsm_userauth_client, ssh_fsm_userauth_server
?CT_LOG automatically prepends pid, module, line, and function name to log output, making manual inclusion of ?MODULE and ?LINE redundant. - Replace all 54 ct:log calls with ?CT_LOG - Remove duplicate ?MODULE/?LINE/?FUNCTION_NAME/self() from format strings and argument lists where ?CT_LOG provides them - Replace deprecated standalone catch expressions with try/catch and add ?CT_LOG for exception details including stacktrace
Contributor
CT Test Results 2 files 29 suites 26m 28s ⏱️ Results for commit 25fe31e. ♻️ This comment has been updated with latest results. To speed up review, make sure that you have read Contributing to Erlang/OTP and that all checks pass. See the TESTING and DEVELOPMENT HowTo guides for details about how to run test locally. Artifacts
// Erlang/OTP Github Action Bot |
Contributor
Author
|
relies on PR-11033, when it is merged and this PR is rebased we will only work on changes from d9ed3b2 Stuff skipped from PR-9157:
ping @alexandrejbr |
Introduce ssh_event module and event_funs option providing a map-based callback mechanism for observing SSH connection events. Event callbacks are fun/2 receiving (Event, Context) where Context includes connection_ref, connection_info, and role. Supported events: connected, disconnected, message_received. Legacy callbacks (connectfun, disconnectfun) are called alongside event_funs for backward compatibility. - New module ssh_event with process_event dispatcher - New option event_funs validated in ssh_options (map of fun/2) - connection_info_server/1 exported for internal event context - Legacy connectfun/3 bridged via ssh_event:connectfun/1 wrapper - Legacy disconnectfun/1 bridged via ssh_event:disconnectfun/1 Known TODOs: - [AP-5] event_funs_message_received test needs assertions - [AP-10] Skip legacy fun dispatch when default no-op - [AP-14] Reject legacy callbacks when event_funs configured Based on work by Alexandre Rodrigues (PR-9157), adapted to use the disconnect_context refactoring from PR-11033. Co-authored-by: Alexandre Rodrigues <alexandrejbr@live.com>
d9ed3b2 to
25fe31e
Compare
Contributor
Author
|
ping @alexandrejbr |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Introduce ssh_event module and event_funs option providing a
map-based callback mechanism for observing SSH connection events.
Event callbacks are fun/2 receiving (Event, Context) where Context
includes connection_ref, connection_info, and role.
Supported events: connected, disconnected, message_received.
Legacy callbacks (connectfun, disconnectfun) are called alongside
event_funs for backward compatibility.
Known TODOs:
Based on work by Alexandre Rodrigues (PR-9157), adapted to use
the disconnect_context refactoring from PR-11033.
Co-authored-by: Alexandre Rodrigues alexandrejbr@live.com