Skip to content
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

ConnectionHooks trait for user-provided callbacks on connection hooks #36

Open
mempirate opened this issue Nov 20, 2023 · 0 comments
Open
Assignees
Labels
A-socket Area: Sockets C-feature Category: Feature

Comments

@mempirate
Copy link
Contributor

mempirate commented Nov 20, 2023

Context

There is currently no way to track the full lifecycle of individual connections. We should have some way for users to track those, which we can do with "hooks" or "callbacks".

Implementation

We should add a trait ConnectionHooks that a user can implement for their own structs and provide to the sockets. The connection hooks exposes the following methods that will be called at various points in the connection lifecycle:

  • on_connection(remote_addr, auth_token): a new connection was created (or recreated). On the server side, this will inject the authentication token (replaces Authenticator trait).
  • on_disconnect(remote_addr, error): a connection was disconnected with a transient failure (error & endpoint will be injected). The connection will be retried.
  • on_termination(remote_addr, error): a connection encountered a fatal error and will not be retried.

These methods will allow implementers to track the complete lifecycle of any connections.

@mempirate mempirate added C-feature Category: Feature A-socket Area: Sockets labels Nov 20, 2023
@mempirate mempirate self-assigned this Nov 20, 2023
@mempirate mempirate added this to the v0.1.2-alpha milestone Nov 23, 2023
@mempirate mempirate removed this from the v0.1.2-alpha milestone Jan 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-socket Area: Sockets C-feature Category: Feature
Projects
None yet
Development

No branches or pull requests

1 participant