feat: optional SSE in REST protocol #176
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This adds support for SSE streaming on REST Protocol via an option, but is not enabled by default. When using
WithRESTServerSentEvents(), only streaming rpcs using REST protocol when request headerAcceptis set totext/event-streamare affected.When SSE is being used:
openis fireddatafield of the event.errorevents are generated when error encounteredcompleteevent is firedThere are SSE specific field configurations available for
eventidandretry. To support these fields, custom directives are parsed out of thegoogle.api.httpresponse_body annotation field, to configure these fields to be set as specifed for each data sent.SSE_EVENT=<field_name>will change the event name on the SSE to be derived from the field specifiedSSE_ID=<field_name>, will change the event id to be derived from the field specified. If this is not set no ID is specified, when it is the id field will be blank unless the attribute has a value on the rendered data.SSE_RETRY=<field_name>, will set the retry field based on the value, assuming it is all ascii numbers.SSE_OMITwill, if any of the above are set, omit the fields specified from the data json body.Related issue:
#161