Improve IPv64 update performance and validation - #411
Conversation
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c3339a24c2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| account_info, domain_info = await asyncio.gather( | ||
| get_account_info(session, headers_api, self.config_entry.data), | ||
| get_domain(session, headers_api, {CONF_DOMAIN: self.config_entry.data.get(CONF_DOMAIN, "")}), | ||
| ) |
There was a problem hiding this comment.
Avoid issuing domain lookups on failed account retries
When the account-info request fails or is temporarily rate-limited, this gather has already started the get_domains request, and the outer retry loop then starts both calls again. Previously the domain lookup only ran after account info succeeded, so in a 429/5xx/timeout scenario on get_account_info each retry now burns an extra IPv64 API request (and get_domain has its own retries), which can quickly exceed the integration’s 3-requests/10s rate-limit handling and make transient failures worse. Fetch the domain data only after account info succeeds, or explicitly cancel/avoid the second task on retry.
Useful? React with 👍 / 👎.



Motivation
Description
asyncio.gather()to reduce overall update time and race conditions (custom_components/ipv64/coordinator.py)._async_update_data()via a new_async_restore_cache()helper so sensors are available faster and during offline scenarios (custom_components/ipv64/coordinator.py).get_domain()to return structured data and set explicitsubdomains/errorfields on failure for clearer downstream handling (custom_components/ipv64/coordinator.py).is_allowed_domain()inconst.pyand replace ad-hocendswith()checks with this helper to accept only exact allowed zones or proper subdomains (custom_components/ipv64/const.py,custom_components/ipv64/config_flow.py,custom_components/ipv64/coordinator.py).custom_components/ipv64/coordinator.py).Testing
ruff check custom_components/ipv64and applied fixes, which completed successfully.python -m compileall custom_components/ipv64and verified all modules compiled without errors.git diff --checkto ensure no whitespace or diff issues; check passed.Codex Task