Skip to content

Improve IPv64 update performance and validation - #411

Open
Ludy87 wants to merge 1 commit into
mainfrom
codex/projekt-leistungsstark-und-benutzerfreundlich-machen
Open

Improve IPv64 update performance and validation#411
Ludy87 wants to merge 1 commit into
mainfrom
codex/projekt-leistungsstark-und-benutzerfreundlich-machen

Conversation

@Ludy87

@Ludy87 Ludy87 commented Jun 24, 2026

Copy link
Copy Markdown
Owner

Motivation

  • Reduce latency and make updates more robust so the integration is faster and more user-friendly during startup and connectivity issues.
  • Ensure domain input is validated strictly to avoid accidental acceptance of non-IPv64 zones.
  • Improve user-facing behavior by restoring cached data on startup and clearing stale error notifications after successful updates.

Description

  • Fetch account and domain information concurrently during coordinator refreshes using asyncio.gather() to reduce overall update time and race conditions (custom_components/ipv64/coordinator.py).
  • Restore cached coordinator data at the start of _async_update_data() via a new _async_restore_cache() helper so sensors are available faster and during offline scenarios (custom_components/ipv64/coordinator.py).
  • Convert get_domain() to return structured data and set explicit subdomains/error fields on failure for clearer downstream handling (custom_components/ipv64/coordinator.py).
  • Add is_allowed_domain() in const.py and replace ad-hoc endswith() 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).
  • Dismiss previous update-related persistent notifications on successful updates, clamp remaining-update counts to non-negative values, and use UTC timestamps for cache records to improve UX and correctness (custom_components/ipv64/coordinator.py).

Testing

  • Ran ruff check custom_components/ipv64 and applied fixes, which completed successfully.
  • Ran python -m compileall custom_components/ipv64 and verified all modules compiled without errors.
  • Ran git diff --check to ensure no whitespace or diff issues; check passed.

Codex Task

@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. enhancement New feature or request performance Performance labels Jun 24, 2026
@sonarqubecloud

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +294 to +297
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, "")}),
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

codex enhancement New feature or request in progress performance Performance size:M This PR changes 30-99 lines, ignoring generated files. Version 2 wait in examination

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant