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

Open
wants to merge 16 commits into
base: main
Choose a base branch
from

Conversation

hugoaguirre
Copy link

@hugoaguirre hugoaguirre commented Nov 15, 2024

OK

curl -X POST -H "Accept: text/event-stream" http://localhost:3400/streamy -d '{"data":5}'
data: {"count":0}\n\n
data: {"count":1}\n\n
data: {"count":2}\n\n
data: {"count":3}\n\n
data: {"count":4}\n\n
data: {"result": "done: 5, streamed: 5 times"}\n\n

ERROR

curl -X POST -H "Accept: text/event-stream" http://localhost:3400/streamy -d '{"data":5}'                                                                       
data: {"message": {"count":0}}\n\n
data: {"message": {"count":1}}\n\n
data: {"message": {"count":2}}\n\n
data: {"message": {"count":3}}\n\n
data: {"message": {"count":4}}\n\n
data: {"error": {"status": "INTERNAL", "message": "stream flow error", "details": "this is a dummy error"}}\n\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
go/genkit/servers.go Outdated Show resolved Hide resolved
@hugoaguirre hugoaguirre force-pushed the haguirre/changeStreamFlowSSE branch from c7b91b2 to ebb72b8 Compare November 25, 2024 18:57
@hugoaguirre hugoaguirre marked this pull request as ready for review November 26, 2024 20:54
@hugoaguirre hugoaguirre linked an issue Nov 28, 2024 that may be closed by this pull request
@apascal07 apascal07 self-requested a review December 2, 2024 17:33
@hugoaguirre hugoaguirre self-assigned this Dec 11, 2024
body: JSON.stringify(test.post),
} as RequestInit;

await fetchData(`${url}/${test.path}`, fetchopts);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I wonder if it would be better to use genkit/client library here for the test?

Copy link
Author

Choose a reason for hiding this comment

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

Ah, good idea. Could you illuminate me on why using genkit/client would be better for this? Is it for compatibility reasons?

Using the raw request, we can inspect headers and response payloads to ensure the proper formatting.


# TODO: add more test cases

app: flow_server
Copy link
Collaborator

Choose a reason for hiding this comment

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

you're not testing the streamed data?

Copy link
Author

Choose a reason for hiding this comment

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

Yes. My understanding is that this file should be used for test cases for the flow server, unless this label is for something else that I'm not aware of.

Should I change it to something more specific? e.g. app: stream_flows

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think Pavel means that you're not consuming the whole stream, just one chunk. Now that I think about it, you do need to consume the stream so you can check the final response.

Copy link
Author

Choose a reason for hiding this comment

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

Got it. I'll add the expected stream values and test against them 😄

@hugoaguirre hugoaguirre force-pushed the haguirre/changeStreamFlowSSE branch from 6043a56 to cb99b3c Compare December 20, 2024 22:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

[Go] Update streaming flows to server-sent events (SSE)
3 participants