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

Allow the usage of a callback for Listen and ListenPacket #56

Merged
merged 2 commits into from
Aug 12, 2020

Conversation

jdesgats
Copy link
Contributor

The ListenConfig approach added recently works well if all the connections are similar, but when different configs are required for specific connections, it quickly gets very cumbersome to use.

This new approach allows arbitrary callbacks to be used for each connection.

Note that this approach (as well as the ListenConfig one) have one drawback: if the connection customization logic changes, from one version to the next, the listening sockets will still be inherited and untouched. In this case a full service restart is necessary as the code doesn't attempt to cope with this situation.

Sometimes, it is useful to customize the listening connections, while
the `ListenConfig` object allows to do this to some extent, it has the
limitation to be shared by all connections managed by an Upgrader
object.

This is a problem if only some particular connections have to be customized
in a specific way.

This commit adds new methods where the user has to provide callbacks that
are responsible to open the connection when needed.
…thods

Removes the code duplication introduced by these new methods. Now the old
`Listen`/`ListenPacket` methods are just using the `WithCallback` variants
under the hood.
Copy link
Contributor

@lmb lmb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks!

@lmb lmb merged commit 77aba94 into master Aug 12, 2020
@lmb lmb deleted the listen-with-callback branch August 12, 2020 15:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants