Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Use DataSource for entity scanning (with pausing when the window loses focus) #1634

Merged
merged 12 commits into from
Nov 1, 2023

Conversation

johncowen
Copy link
Contributor

@johncowen johncowen commented Oct 19, 2023

Replaces the EntityScanner with a DataSource.

Makes all polling/retrying DataSources pause when the tab loses focus.

Whilst doing this I made a helper to let us configure the source of the DataSource easier from the sources.ts file so you can opt in to polling rather than opt out.

Closes #1582

Also addresses a part of #1474


I wanted to note that there will be some follow up work here, but I wanted to submit this PR so we could get this in rather than keep working on related things:

  • I 'think' its a good point to PR the DataLoader component I spoken about in the past.
  • The DataSource file/import organization is a bit messy just down to how DataSource came over here, I'd like to make that a bit less messy.
  • Probably PR chore: Add automatic typing to source internals #1525 for real.

@netlify
Copy link

netlify bot commented Oct 19, 2023

Deploy Preview for kuma-gui ready!

Name Link
🔨 Latest commit 697dc35
🔍 Latest deploy log https://app.netlify.com/sites/kuma-gui/deploys/654224ca1aca6900085dada9
😎 Deploy Preview https://deploy-preview-1634--kuma-gui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@johncowen johncowen force-pushed the chore/refactor-data-source-usage branch 8 times, most recently from 561de7d to 962abde Compare October 23, 2023 17:25
Copy link
Contributor Author

@johncowen johncowen left a comment

Choose a reason for hiding this comment

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

Inlines:

src/app/zones/data/index.ts Outdated Show resolved Hide resolved
@johncowen johncowen changed the title [WIP] chore: Use DataSource for entity scanning (with pausing when the window loses focus) chore: Use DataSource for entity scanning (with pausing when the window loses focus) Oct 24, 2023
@johncowen johncowen marked this pull request as ready for review October 24, 2023 09:25
@johncowen johncowen requested a review from a team as a code owner October 24, 2023 09:25
@johncowen johncowen requested review from kleinfreund and removed request for a team October 24, 2023 09:25
features/zones/Create.feature Outdated Show resolved Hide resolved
src/app/zones/data/index.ts Show resolved Hide resolved
src/app/zones/data/index.ts Show resolved Hide resolved
src/app/application/services/data-source/index.ts Outdated Show resolved Hide resolved
src/app/zones/sources.ts Outdated Show resolved Hide resolved
src/app/zones/views/CreateView.vue Outdated Show resolved Hide resolved
src/app/zones/views/CreateView.vue Show resolved Hide resolved
@johncowen johncowen force-pushed the chore/refactor-data-source-usage branch from a611e24 to c7f14a6 Compare October 31, 2023 11:26
@kleinfreund
Copy link
Contributor

I’ve looked over this again and am mostly fine with how this works.

Two things I think need to be addressed as part of this PR (linking to the relevant threads) and not only in a follow up:

Could you also please rebase this PR?

@johncowen johncowen force-pushed the chore/refactor-data-source-usage branch from 285cb2a to 6a78b62 Compare November 1, 2023 10:03
Signed-off-by: John Cowen <[email protected]>
Signed-off-by: John Cowen <[email protected]>
Signed-off-by: John Cowen <[email protected]>
Signed-off-by: John Cowen <[email protected]>
Signed-off-by: John Cowen <[email protected]>
Signed-off-by: John Cowen <[email protected]>
@johncowen johncowen force-pushed the chore/refactor-data-source-usage branch from 6a78b62 to 54433cb Compare November 1, 2023 10:11
Signed-off-by: John Cowen <[email protected]>
@johncowen johncowen merged commit c1a4331 into kumahq:master Nov 1, 2023
15 checks passed
johncowen added a commit that referenced this pull request Nov 13, 2023
Back in #1634 we changed the functionality of checking for a connected zone by additionally catching a 404 error and retrying the request, which I'd wrongly assumed how this functioned.

The endpoint only ever returns a 404 if the zone is deleted (i.e. doesn't exist). It doesn't 404 if the zone exists but is not connected.

Due to the change, it was possible to create a zone, without connecting it, and then in say another tab, delete the zone, and the scanner would continue to spin due to the 404s.

I've removed the 404 retries, and also added further testing for making sure a 404 shows the error page when the scanner is waiting to connect, and I also updated the mocks so that they are closer to the real responses.

We decided that we should check for a `zone.enabled` (#1634 (comment)) but I don't think we ever need to check for `zone.enabled` for the purposes of this PR (or #1634) when checking for whether the zone is connected. I haven't altered anything there as yet as it doesn't have any effect, but I have updated the mocks here so that we don't get `enabled: true`, only a non-existant `enabled` (i.e. defaults to `true`) or `false`, which I 'think' is more correct.

I re-added some comments explaining this a little better in a couple of places, and I almost renamed and moved around functions to help the code self-comment, but I'm a little way into a longer piece of work of collecting up zone data related functions de-duping them and refactoring them, which I'd rather continue to do separately rather than in this PR. The comments here will help when I continue with that.

---------

Signed-off-by: John Cowen <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Disable any HTTP polling when we hide tabs/lose window focus
2 participants