-
Notifications
You must be signed in to change notification settings - Fork 83
Open
lazaroborges/midaz
#3Labels
back-endBack-end IssuesBack-end Issues
Description
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
HTTPBatchProcessorinpkg/concurrent/http_batch.go - This processor is designed to send multiple requests to a
/batchendpoint - Currently, there is no
/batchendpoint 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 requestheaders: Optional request-specific headersbody: Optional request bodyid: Client-generated ID to match requests with responses
- Return an array of response objects, each containing:
statusCode: HTTP status codeheaders: Response headersbody: Response bodyerror: 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
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
back-endBack-end IssuesBack-end Issues