Skip to content

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

Open
@mempirate

Description

@mempirate

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.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions