-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor handling of non-managed resources #1360
Conversation
These are plain Ruby objects representing the concepts of engine and data store on Discovery Engine. Our architecture only has a single one of each, and that is unlikely to change in the medium term, so these are not persisted in the database but rather just have a single default instance available as `.default`.
This changes `Control` and its actions to use the new models instead of getting their engine and data store names straight from the Rails config.
This removes the unnecessary configuration of a data store, and also removes the erroneous test environment configuration for engine that was left in as part of a previous PR.
This refactors the repetitive name generation into a `DiscoveryEngineNameable` mixin.
This could come in helpful for debugging.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes look good, except that I've tripped over the naming again. You can see my full confusion in the inline comments 😅
Anything that removes unnecessary config is a plus 🪇
This is a more sensible name that doesn't cause confusion around "engines".
# parent resource is not the default collection. | ||
module DiscoveryEngineNameable | ||
# The name (fully qualified path) of this Discovery Engine resource on GCP | ||
def name | ||
[parent_name, resource_path_fragment, discovery_engine_id].join("/") | ||
[parent_name, resource_path_fragment, remote_resource_id].join("/") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a much better name. Thanks for updating! ⭐
We currently need the GCP "name" (actually a path/unique identifier!) for two resources that aren't managed by Search Admin:
Control
s need the name of our default engine (as they are created as child resources on the engine)Control::BoostAction
s andControl::FilterAction
s need the name of our default data store (as that is the data store they are active against).So far we have been setting separate environment variables for the data store and engine on the app (one of these was missing in a previous PR causing a bug). But both of these share a common parent (the GCP project's default collection), so we only really need to configure that and infer the data store and engine name based on that.
This PR:
DataStore
andEngine
as classes, with a single default instance, and uses those inControl
and its actionsDiscoveryNameable
mixinScreenshots