Skip to content
This repository has been archived by the owner on Jun 12, 2024. It is now read-only.

feat: WebSocket based implementation of server sent events for cache busting #527

Merged
merged 11 commits into from
Aug 2, 2023

Conversation

hay-kot
Copy link
Owner

@hay-kot hay-kot commented Aug 1, 2023

To Do's

  • Remove unused update/delete methods from Repo Layer
  • Ensure all mutations are covered by event bus
  • Cleanup all old event bus related frontend code
  • Websocket reconnect
  • Item mutations should also invalidate location cache

What type of PR is this?

  • bug
  • cleanup

What this PR does / why we need it:

This PR implements several layers necessary to properly cache bust the frontend Labels and Locations cache on a mutation made in the database. Procedure works like so.

  1. Client establishes a web socket connection
  2. Client waits for server to send 'label.mutation' or 'location.mutation' event
  3. When received the client will refresh data.

In the event of a performance problem down the line, we can implement passing data over the WS connection to avoid the extra call, but I don't think we'll every get to that point.

On the backend the Repository Layer will publish mutation events whenever the Locations or Labels tables are updated. It will also provide the GID as a context value.

Which issue(s) this PR fixes:

Fixes #50

Special notes for your reviewer:

Currently in rough draft status, needs another refactor to cleanup code.

@hay-kot hay-kot marked this pull request as ready for review August 2, 2023 20:07
@hay-kot hay-kot force-pushed the feat/server-side-ws-cache-buster branch from 4944664 to 1df47ef Compare August 2, 2023 20:12
@hay-kot hay-kot merged commit 2cbcc8b into main Aug 2, 2023
3 checks passed
@hay-kot hay-kot deleted the feat/server-side-ws-cache-buster branch August 2, 2023 21:01
@yusiwen
Copy link

yusiwen commented Nov 9, 2023

@hay-kot
I'm getting this error:

homebox  | 6:39AM INF ../go/src/app/internal/web/mid/logger.go:36 > request received method=GET path=/api/v1/ws/events rid=c03ab9c385da/1BpEUP5c6X-000014
homebox  | 6:39AM ERR ../go/src/app/internal/web/mid/errors.go:31 > ERROR occurred error="Authorization header or query is required" req_id=c03ab9c385da/1BpEUP5c6X-000014

Version: v0.10.1

hay-kot added a commit that referenced this pull request Jan 28, 2024
…busting (#527)

* rough implementation of WS based event system for server side notifications of mutation

* fix test construction

* fix deadlock on event bus

* disable linter error

* add item mutation events

* remove old event bus code

* refactor event system to use composables

* refresh items table when new item is added

* fix create form errors

* cleanup unnecessary calls

* fix importer erorrs + limit fn calls on import

Former-commit-id: 2cbcc8b
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Site data not refreshing correctly until page is manually refreshed
2 participants