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

Add support for server sent events via response asStream #781

Merged
merged 26 commits into from
Dec 18, 2020

Conversation

adamsmo
Copy link
Contributor

@adamsmo adamsmo commented Dec 3, 2020

Before submitting pull request:

  • Check if the project compiles by running sbt compile
  • Verify docs compilation by running sbt compileDocs
  • Check if tests pass by running sbt test
  • Format code by running sbt scalafmt

docs are still WIP, but the implementation is finished

@adamsmo adamsmo marked this pull request as ready for review December 9, 2020 16:30
def decodeSSE: Flow[ByteString, ServerSentEvent, NotUsed] =
//todo decide on max frame length
Framing
.delimiter(ByteString("\n\n"), maximumFrameLength = Int.MaxValue, allowTruncation = true)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

maximumFrameLength can be parameter accepted by decodeSSE method

Copy link
Member

Choose a reason for hiding this comment

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

Is there anything specified by the SSE standard? Maximum message size? If not, we should make this configurable, with some reasonable default - maybe taken from other impls?

)

object ServerSentEvent {
def parseEvent(event: List[String]): ServerSentEvent = {
Copy link
Member

Choose a reason for hiding this comment

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

maybe add some tests?
it's not possible for parsing to fail - there are no invalid inputs?

@adamw
Copy link
Member

adamw commented Dec 17, 2020

@adamsmo Are you planning to continue working on this PR, or should I take over? :)

@adamsmo
Copy link
Contributor Author

adamsmo commented Dec 17, 2020

Please take over, responding to your last comment

maybe add some tests?
it's not possible for parsing to fail - there are no invalid inputs?

It should not be possible for parsing to fail, as it ignores any value with not recognized label. If the line does not contain any : it is treated as a line with label and no value, and if the label is unknown, it is ignored.

I think I do not have push permission to this branch after I was removed from the SML organization

@adamw adamw merged commit 57396d5 into master Dec 18, 2020
@mergify mergify bot deleted the server-sent-events branch December 18, 2020 15:13
@adamw
Copy link
Member

adamw commented Dec 18, 2020

Released in 3.0.0-RC13

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