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

breaking(go): update flow streaming protocol to SSE #1316

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

hugoaguirre
Copy link

@hugoaguirre hugoaguirre commented Nov 15, 2024

curl -X POST -H "Accept: text/event-stream" http://localhost:3400/streamy -d '{"data":5}'
data: {"count":0}

data: {"count":1}

data: {"count":2}

data: {"count":3}

data: {"count":4}

data: {"result": "done: 5, streamed: 5 times"}\n

Copy link

google-cla bot commented Nov 15, 2024

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@pavelgj pavelgj changed the title [Go] Update flow streaming protocol to SSE breaking(go): update flow streaming protocol to SSE Nov 18, 2024
w.Header().Set("Content-Type", "text/plain")
w.Header().Set("Transfer-Encoding", "chunked")
// Stream results are newline-separated JSON.
callback = func(ctx context.Context, msg json.RawMessage) error {
_, err := fmt.Fprintf(w, "%s\n", msg)
_, err := fmt.Fprintf(w, "data: %s\n\n", msg)
Copy link
Collaborator

Choose a reason for hiding this comment

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

this needs to be wrapped in a {"message": ...} object.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
_, err := fmt.Fprintf(w, "data: %s\n\n", msg)
_, err := fmt.Fprintf(w, "data: {"message": %s}\n\n", msg)

Copy link
Author

Choose a reason for hiding this comment

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

Thanks Pavel, adding the changes now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

2 participants