feat: support disk usage limit #6
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request introduces a dynamic, hot-reloadable configuration system to the project, replacing the previous static configuration approach. The new system uses an atomic wrapper for configuration, allowing the application to reload configuration changes at runtime without restarting. This is supported by a file watcher and extensive refactoring to ensure all code accesses configuration via the new atomic interface. Additionally, a new test verifies the reload behavior, and some dependencies were updated to support these changes.
Key changes include:
Dynamic Configuration Reloading:
Config
type that wraps the configuration in anatomic.Value
, enabling safe concurrent access and hot-reloading of configuration changes at runtime (pkg/config/config.go
,pkg/config/watcher.go
). [1] [2]fsnotify
to monitor the configuration file for changes and automatically reload it when updated (pkg/config/watcher.go
).Refactoring for Atomic Configuration Access:
Config
interface (i.e.,cfg.Get().Field
) instead of direct struct access. This affects files such aspkg/server/server.go
,pkg/server/http.go
,pkg/provider/provider.go
,pkg/client/grpc.go
, and others. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13]Configuration Structure Enhancements:
RawConfig
(actual config fields) andConfig
(atomic wrapper), and added support for human-readable disk size fields via the newHumanizeSize
type. [1] [2]TraceEndpooint
→TraceEndpoint
).Testing and Dependency Updates:
pkg/config/config_test.go
) that verifies configuration hot-reloading works as expected.go.mod
to addfsnotify
(for file watching),gomonkey
(for testing), and movedgolang.org/x/sys
from indirect to direct dependency. [1] [2] [3]Build and Test Improvements:
Makefile
to streamline testing, including all packages except the main server package in standard tests and running the server tests separately.These changes collectively make the configuration system more robust and flexible, allowing runtime updates and laying groundwork for future dynamic behavior.