Transport error mode for server HTTP and GRPC APIs #690
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.
Proposed changes
Currently Centrifugo server API never returns transport level errors - for example it always returns 200 OK for HTTP API and never returns GRPC transport-level errors.
This PR adds an option to use transport-native error codes instead of Centrifugo
error
field in response. The motivation is make API friendly to integrate with network ecosystem - for automatic retries, better logging, etc.In current state PR does not modify Batch and Broadcast APIs which are quite special. For these two calls we can't introduce transport-level errors as the response actually includes results of different independent command execution. Most probably the best we can do is documenting this distinction.
Behaviour may be turned on globally:
"api_error_mode": "transport"
for HTTP"grpc_api_error_mode": "transport"
for GRPCAlso it may be used on per-request basis:
X-Centrifugo-Error-Mode: transport
for HTTPx-centrifugo-error-mode: transport
for GRPCExample
Before:
After: