feat(storage): add built-in storage engine with system-level fallback#1468
Open
nixidexiangjiao wants to merge 1 commit into
Open
feat(storage): add built-in storage engine with system-level fallback#1468nixidexiangjiao wants to merge 1 commit into
nixidexiangjiao wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Add a declarative system-level fallback mechanism for storage engine configuration via
config/builtin_storage_engine.yaml, mirroring the existingbuiltin_models.yamlpattern. When a tenant'sstorage_engine_configis absent or has an empty provider sub-config, the system automatically falls back to the built-in config.Key changes:
internal/types/storage_resolve.go):ResolveXxxConfigfunctions implement tenant → builtin → env fallback with empty-shell detection. If a tenant sub-config has all key fields empty (e.g.OSS: {}), it's treated as an empty shell and bypassed in favor of the builtin fallback.internal/types/builtin_storage_engine_config.go): Loads the config file at startup with${ENV}and${ENV:-default}placeholder interpolation, stored in anatomic.Pointersingleton.internal/types/env_interpolation.go):${VAR}for string fields (unset stays literal to surface misconfig),${VAR:-default}for bool/int fields (unset falls back to default to avoid YAML parse errors).sec == nil || sec.Xxx == nilchecks withtypes.ResolveXxxConfig(sec)calls infactory.goandsystem.go.KBStorageSettings.vuenow checksprops.storageProviderinstead of local state for provider pre-selection.OBS_*env-var path is now the 3rd-tier fallback (tenant → builtin → env) and emits async.Oncedeprecation warning. Planned for removal in vip-v0.7.x.*EngineConfigtypes now haveyamltags alongside existingjsontags, enabling deserialization from both API/DB (JSON) and config file (YAML).Type of Change
Related Issue
Fixes #
Testing
All new test files pass with
go test ./internal/types/ ./internal/application/service/file/ ./internal/handler/:internal/types/env_interpolation_test.go—${VAR}and${VAR:-default}expansion, unset/empty/default casesinternal/types/storage_resolve_test.go— Full matrix: tenant-first, empty-shell fallback, partial-config-no-fallback, both-nil; plus OBS env deprecation andsync.Onceonce-only guaranteeinternal/types/builtin_storage_engine_config_test.go— File missing, invalid YAML, env interpolation, empty config, env override path, atomic replaceinternal/application/service/file/factory_builtin_test.go— All 8 providers with builtin fallback, default provider fallback, both-nil returns incompleteinternal/handler/system_storage_resolve_test.go—isXxxConfiguredwith builtin fallback for all providersinternal/handler/tenant_storage_resolve_test.go—GetTenantStorageEngineConfigfills DefaultProvider from builtin, respects STORAGE_ALLOW_LIST, never leaks builtin secrets to clientChecklist
make fmt && make lint && make testpass locallydocs/, Swagger annotations, etc.)Screenshots / Recordings
No user-visible UI changes (only a minor fix to provider pre-selection logic in the KB storage settings).