mirror of
https://github.com/pocket-id/pocket-id.git
synced 2025-12-11 07:32:57 +03:00
[PR #423] refactor: simplify app_config service and fix race conditions #818
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Original Pull Request: https://github.com/pocket-id/pocket-id/pull/423
State: closed
Merged: Yes
Fixes #391
Fixes #407
As discussed with @stonith404 , this PR refactors the app_config service with the goals of greatly simplify the logic, and fixing race conditions.
There are significant performance improvements too, especially when updating config, as the number of database round-trips has been reduced to no more than 2 (currently, it's 2 per each key). API calls to retrieve config are also much faster as they return the data from memory only.
atomic.Pointer, which removes the risk of data races.PR includes extensive unit tests which use an in-memory SQLite database to validate the behavior of the service.
Note: I had to update to Go 1.24 to be able to use
testing.Context().