-
Notifications
You must be signed in to change notification settings - Fork 656
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
Add async TCP echo example #2463
Conversation
438e2d1
to
e82a6c5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just leaking an EventLoopGroup
in a function is illegal (will get deinited without shutdown which is a lifecycle violation)
6989109
to
a734501
Compare
@weissi I updated this PR to use your newly landed singletons. |
a734501
to
a0766ec
Compare
a0766ec
to
dad3348
Compare
) { channel in | ||
channel.eventLoop.makeCompletedFuture { | ||
// We are using two simple handlers here to frame our messages with "\n" | ||
try channel.pipeline.syncOperations.addHandler(ByteToMessageHandler(NewlineDelimiterCoder())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all these try
s should be try!
s, they can't fail unless programmer error, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They could throw if the channel is closed while we add the handler. I don't wanna show adopters a try!
when it could fail in rare cases and I don't think the try
is too bad.
dad3348
to
c20b082
Compare
0776379
to
1fa2d5e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
# Motivation We introduced new async APIs to our bootstraps that make it easy to use NIO from Swift Concurrency. We should provide examples showing how to use those new APIs. In the future, we want to make those examples the primary ones and remove the non-async based ones. # Modification This PR introduces two new targets: `NIOTCPEchoServer` and `NIOTCPEchoClient`. Both targets are executable and provide either the server or client piece of the example. # Result New and shiny async example
5034078
to
bea684c
Compare
Motivation
We introduced new async APIs to our bootstraps that make it easy to use NIO from Swift Concurrency. We should provide examples showing how to use those new APIs. In the future, we want to make those examples the primary ones and remove the non-async based ones.
Modification
This PR introduces two new targets:
NIOTCPEchoServer
andNIOTCPEchoClient
. Both targets are executable and provide either the server or client piece of the example.Result
New and shiny async example