feat(storage): multi-scheme DataStore with lazy per-scheme backend routing#7555
Open
EngHabu wants to merge 1 commit into
Open
feat(storage): multi-scheme DataStore with lazy per-scheme backend routing#7555EngHabu wants to merge 1 commit into
EngHabu wants to merge 1 commit into
Conversation
…uting Replace the single-purpose redis scheme-routing store with a general routing store. The configured Type is built eagerly as the primary backend (owning the InitContainer and GetBaseContainerFQN); every other scheme (s3://, gs://, abfs://, redis://, ...) is dialed lazily on first reference and memoized for reuse, so one DataStore can serve any scheme/container. Schemes absent from the optional per-scheme config map are dialed with ambient credentials. Cross-scheme CopyRaw routes through the store itself. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR generalizes flytestdlib/storage so a single DataStore can route operations across multiple URL schemes (e.g. s3://, gs://, abfs://, redis://) by wrapping the configured primary backend in a lazy, memoizing routing RawStore.
Changes:
- Added a new
routingStorethat dispatches by scheme and lazily dials/memoizes per-scheme backends. - Extended storage config with
Schemes map[string]SchemeConfigto support per-scheme backend overrides. - Updated stow/redis stores and
RefreshConfigwiring to support eager primary backend + lazy secondary backends, plus added focused routing-store tests.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
flytestdlib/storage/stow_store.go |
Adds scheme<->kind mapping, primary-scheme derivation, and a stow backend factory + dial helper for lazy secondary schemes. |
flytestdlib/storage/scheme_routing_store.go |
Removes the previous redis-vs-default router in favor of the generalized router. |
flytestdlib/storage/routing_store.go |
New generalized router with lazy instantiation/memoization and scheme fallback behavior. |
flytestdlib/storage/routing_store_internal_test.go |
New internal tests covering lazy creation, memoization, fallback, and concurrency behavior. |
flytestdlib/storage/redis_store.go |
Refactors redis construction and adds redisFactory for lazy redis backend dialing. |
flytestdlib/storage/rawstores.go |
Wires RefreshConfig to build the eager primary store and wrap it with the routing store, threading the configured HTTP client. |
flytestdlib/storage/protobuf_store_test.go |
Updates expectations to reflect routing store always wrapping the primary backend. |
flytestdlib/storage/config.go |
Adds Schemes + SchemeConfig to support per-scheme overrides (stow kind/config, redis config). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+68
to
+72
| scheme, ok := kindToScheme[kind] | ||
| if !ok { | ||
| return "", fmt.Errorf("no scheme registered for stow kind [%v]", kind) | ||
| } | ||
| return scheme, nil |
Comment on lines
+90
to
+94
| // RegisterStowScheme associates a URL scheme with a stow kind so the DataStore can lazily dial it | ||
| // when a reference with that scheme is encountered. Pair it with RegisterStowKind to teach | ||
| // flytestdlib about an out-of-tree stow backend. | ||
| func RegisterStowScheme(scheme, kind string) error { | ||
| if existing, ok := schemeToStowKind[scheme]; ok && existing != kind { |
Comment on lines
+304
to
+308
| if redisCfg.Addr == "" { | ||
| _, host, _, err := ref.Split() | ||
| if err != nil { | ||
| return nil, err | ||
| } |
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.
Summary
Generalizes the storage layer's scheme routing so a single
DataStorecan serve any URL scheme and container, instead of being pinned to one configured backend.Typeis built eagerly as the primary backend — it owns theInitContainerandGetBaseContainerFQN.s3://,gs://,abfs://,redis://, ...) is dialed lazily the first time a matching reference is seen and memoized for reuse (creation is serialized so each scheme is dialed at most once under concurrency).Config.Schemesmap allows per-scheme backend overrides (kind, stow config, redis connection). Schemes absent from the map are dialed with ambient credentials (provider default credential chain — IAM/instance profile, GCP ADC, workload identity, env vars).CopyRaw(e.g.redis -> s3,s3 -> gs) routes through the router itself via plainReadRaw/WriteRaw.This replaces the previous single-purpose
scheme_routing_store.go(which only split redis from a blob store) with a generalrouting_store.go.RegisterStowSchemeis added alongsideRegisterStowKindso out-of-tree stow backends can be taught to the router.Changes
routing_store.go(new) — lazy, memoizing, scheme-dispatchingRawStorescheme_routing_store.go(removed) — supersededconfig.go—Schemes map[string]SchemeConfig+SchemeConfigstow_store.go—schemeToStowKind/kindToSchememaps,primarySchemeForConfig,RegisterStowScheme,stowFactoryredis_store.go—redisFactoryfor lazy redis dialingrawstores.go—RefreshConfigwires the routing store and threads the configured HTTP clientrouting_store_internal_test.go(new) — routing/lazy-creation/fallback coverageTest plan
go test ./flytestdlib/storage/...🤖 Generated with Claude Code