Overview
I'm requesting the addition of a /batch endpoint to the Midaz API to enable efficient processing of multiple API requests in a single HTTP call. The Go SDK already includes a comprehensive HTTP batch processor implementation (pkg/concurrent/http_batch.go), but it currently can't be fully utilized without a corresponding server-side endpoint.
Current Situation
- The SDK includes an implemented
HTTPBatchProcessor in pkg/concurrent/http_batch.go
- This processor is designed to send multiple requests to a
/batch endpoint
- Currently, there is no
/batch endpoint on the Midaz API
- Without this endpoint, batch operations fall back to individual requests, adding overhead and reducing performance
Benefits of a Batch Endpoint
- Reduced Network Overhead: Multiple operations in a single HTTP request
- Improved Performance: Fewer connection establishments and reduced latency
- Atomic Operations: Ability to process related requests together
- Better Resource Utilization: Server can optimize processing of multiple requests
- Leveraging Existing Code: The SDK already has the client-side implementation
Proposed Implementation
The batch endpoint should:
- Accept a POST request to
/batch
- Receive an array of request objects, each containing:
method: HTTP method (GET, POST, PUT, DELETE, etc.)
path: Relative path for the request
headers: Optional request-specific headers
body: Optional request body
id: Client-generated ID to match requests with responses
- Return an array of response objects, each containing:
statusCode: HTTP status code
headers: Response headers
body: Response body
error: Error message (if applicable)
id: The client-generated ID from the request
Example Request
[
{
"method": "GET",
"path": "/.../transactions/batch",
"id": "req_1"
},
{
"method": "POST",
"path": "/.../transactions/batch",
"body": {
various transactions bodies
},
}
]
Example Response
[
{
"id": "req_1",
"statusCode": 200,
"body": {
...
}
},
{
"id": "req_2",
"statusCode": 201,
"body": {
...
}
}
]
Priority and Impact
This feature would significantly improve performance for operations that require multiple API calls, such as:
- Creating complex workflows with multiple entities
- Batch processing transactions
- Retrieving data for dashboards and reports
Additional Considerations
- Rate limiting should be adjusted to account for batch requests
- Authentication should be handled at the batch level
- Error handling should allow for partial success/failure
Overview
I'm requesting the addition of a
/batchendpoint to the Midaz API to enable efficient processing of multiple API requests in a single HTTP call. The Go SDK already includes a comprehensive HTTP batch processor implementation (pkg/concurrent/http_batch.go), but it currently can't be fully utilized without a corresponding server-side endpoint.Current Situation
HTTPBatchProcessorinpkg/concurrent/http_batch.go/batchendpoint/batchendpoint on the Midaz APIBenefits of a Batch Endpoint
Proposed Implementation
The batch endpoint should:
/batchmethod: HTTP method (GET, POST, PUT, DELETE, etc.)path: Relative path for the requestheaders: Optional request-specific headersbody: Optional request bodyid: Client-generated ID to match requests with responsesstatusCode: HTTP status codeheaders: Response headersbody: Response bodyerror: Error message (if applicable)id: The client-generated ID from the requestExample Request
[ { "method": "GET", "path": "/.../transactions/batch", "id": "req_1" }, { "method": "POST", "path": "/.../transactions/batch", "body": { various transactions bodies }, } ]Example Response
[ { "id": "req_1", "statusCode": 200, "body": { ... } }, { "id": "req_2", "statusCode": 201, "body": { ... } } ]Priority and Impact
This feature would significantly improve performance for operations that require multiple API calls, such as:
Additional Considerations