Request Handling
Overview
Extend Apps leverage gRPC and gRPC-Gateway as core technologies to support robust, scalable, and customizable backend services within the AccelByte ecosystem. These technologies provide a high-performance framework for defining APIs, handling any client-server or any server-server communication, and exposing gRPC services as RESTful endpoints when needed.
Understanding how gRPC requests are processed in Extend Apps is essential for developers who want to override existing service logic or implement new functionality.
gRPC Request Handling
The following guides walk you through service definition, client/server setup, and request handling logic for languages supported by Extend:
- Overview for gRPC on .NET (C#)
- gRPC Basics Tutorial for Go
- gRPC Basics Tutorial for Java
- gRPC Basics Tutorial for Python
gRPC Error Handling
Refer to these official resources for best practices:
To ensure proper error handling and to provide clients with meaningful feedback, it’s recommended to use specific gRPC status codes when appropriate and to include detailed error messages wherever possible.
When implementing gRPC methods, it is important to handle errors appropriately. If an exception is thrown within a method implementation, it will result in a 13 INTERNAL
gRPC status code (or 500 Internal Server Error
in HTTP).
gRPC Error Handling with gRPC-Gateway
Extend Apps surfaces gRPC errors in a structured way, especially when paired with gRPC-Gateway. These errors are mapped to standard HTTP status codes to ensure compatibility with RESTful clients.
gRPC to HTTP Status Code Mapping
gRPC Code | HTTP Status Code |
---|---|
0 OK | 200 OK |
1 CANCELLED | 499 - |
2 UNKNOWN | 500 Internal Server Error |
3 INVALID_ARGUMENT | 400 Bad Request |
4 DEADLINE_EXCEEDED | 504 Gateway Timeout |
5 NOT_FOUND | 404 Not Found |
6 ALREADY_EXISTS | 409 Conflict |
7 PERMISSION_DENIED | 403 Forbidden |
8 RESOURCE_EXHAUSTED | 429 Too Many Requests |
9 FAILED_PRECONDITION | 400 Bad Request |
10 ABORTED | 409 Conflict |
11 OUT_OF_RANGE | 400 Bad Request |
12 UNIMPLEMENTED | 501 Not Implemented |
13 INTERNAL | 500 Internal Server Error |
14 UNAVAILABLE | 503 Service Unavailable |
15 DATA_LOSS | 500 Internal Server Error |
16 UNAUTHENTICATED | 401 Unauthorized |
For full implementation details, refer to gRPC-Gateway errors.go.
A 500 Internal Server Error
can be retried multiple times by the client, depending on the client's retry logic configuration. It is important to account for this when designing services, as excessive retries could lead to performance bottlenecks or unintended side effects if not properly handled.