Skip to content

Bidirectional stream events #583

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

Merged
merged 14 commits into from
Jul 5, 2024

Conversation

akbashev
Copy link
Contributor

@akbashev akbashev commented Jul 4, 2024

Motivation

While working with my swift distributed actors showcase one of the points for me was to try openapi. As this is a chat client showcase, took me some time to realise that you can do bidirectional streaming. Think this is quite an important feature and not very discoverable, so to fill this gap—created two simple examples. Things to consider:

  • Basically copied and updated event-streams-_-example
  • For simplicity using just json lines.
  • Tried to be simple overall, e.g. there could be such things as heartbeat messages to keep/close connections, but think this should be done by whoever implements the clients.
  • Switched to AsyncHttpTransport, cause for URLSession you need a hack, see comment.
  • While playing switched to Hummingbird, can switch back to Vapor though.

Modifications

Working examples showing bidirectional streaming both for server and client.

Test Plan

I've tested myself, it's working, don't think examples are covered with tests.

akbashev and others added 3 commits July 4, 2024 11:03
Co-authored-by: Honza Dvorsky <[email protected]>
Co-authored-by: Honza Dvorsky <[email protected]>
@czechboy0
Copy link
Contributor

@swift-server-bot test this please

@czechboy0
Copy link
Contributor

@akbashev Please run ./scripts/run-swift-format.sh --fix and fix up the issues it's complaining about, then I can rerun the CI.

@akbashev
Copy link
Contributor Author

akbashev commented Jul 4, 2024

@akbashev Please run ./scripts/run-swift-format.sh --fix and fix up the issues it's complaining about, then I can rerun the CI.

Ah, while trying to figure out about streams and URLSession, completely forgot about swift-format. Just run and pushed fixes.

@czechboy0
Copy link
Contributor

@swift-server-bot test this please

@czechboy0
Copy link
Contributor

@swift-server-bot test this please

Copy link
Contributor

@czechboy0 czechboy0 left a comment

Choose a reason for hiding this comment

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

Thank you!

@czechboy0 czechboy0 merged commit c2b7366 into apple:main Jul 5, 2024
9 checks passed
@czechboy0 czechboy0 added the semver/none No version bump required. label Jul 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver/none No version bump required.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants