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

refactor(sse): DataStream: more intuitive colocation and interface #298

Merged
merged 2 commits into from
Dec 14, 2024

Conversation

kanarus
Copy link
Member

@kanarus kanarus commented Dec 14, 2024

DataStream, the core type for streaming response, before lived in typed module unintuitively, and its interface is so too due to some confusion around the type of stream item ( T v.s. Result<T> ) and the conversion ( Into<String> ).

This PR migrates it into sse::{DataStream, Data}:

  • Place DataStream in new module named sse. This is intuitive.
  • And refactor it to have more clear interface to asynchronously send T items.
  • Use Data trait instead of Into<String> for data conversion. This makes the context clear.

In addition, this PR eliminates a double-boxing of previous SSE implementation.

@kanarus kanarus merged commit b93fc60 into v0.21 Dec 14, 2024
3 checks passed
@kanarus kanarus deleted the refactor/sse branch December 14, 2024 19:05
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.

1 participant