-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Description
Description
Hello.
I'm grateful for the work you've done in supporting Loco natively in Symfony via loco-translation-provider, however it has some issues I'd like to lay out here. If I had the time (and the Symfony knowledge) I'd submit a PR, but for now I can only make suggestions.
In the short term: There's an issue with the way the adapter sends concurrent requests from the translateAssets method. The Loco API has no hourly or daily rate limits, but it does restrict parallel HTTP requests to a buffer of 10 pending requests per API key. If an eleventh request comes in before the first one has responded, it will fail with 429 - too many requests.
I'm aware the default max_host_connections is 6, which should present no problem, but set it above 10 and the adapter will simply fail before the work is done.
As a workaround I believe a scoped client could be used for the localise.biz domain in order to set a lower max_host_connections value. I'm not 100% clear on what this config looks like though. Perhaps someone could post an example?
As for the approach in the code: I can see there's a note in the read method about purposefully not sending parallel requests. This should apply to the write commands too, but the code need not be refactored if the concurrency can be limited.
In the longer term: The adapter should really make use of the Import API rather than invoke hundreds of separate API calls. This endpoint takes a single blob (say JSON) and performs all the logic that the adapter currently performs. It would only need to make one request per text domain, and would be a great deal faster.
Example
No response