Add App.from_name for construction of a lazily-hydratable App #2798
+72
−15
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.
Describe your changes
This PR adds a new
App.from_name
method with similar lazy construction semantics to other.from_name
methods on Object subclasses, along with anApp.hydrate
method for on-demand hydration. The intention is to make it possible to deprecateApp.lookup
when we deprecate otherObject.lookup
methods, streamlining object construction onto a single lazy path.As
App
is not a subclass ofObject
we face a decision about whether we should make it one (and leverage the existing hydration plumbing) or add some App-specific plumbing. This PR takes the latter approach, which feels more straightforward now without foreclosing on adapting the other approach later.There's definitely some confusing things here. I've made it so that you can't call
App.hydrate
if you instantiated an App by calling its main constructor (App(name)
). Potentially we will want to leverage lazy-hydration of the App layout when we do App redeployments (i.e. the current_init_local_app_existing
). I think we can punt on that as there are not currently any user-facing workflows where you would want to hydrate the App and then access its layout, but we've tlaked about it, e.g. for Function discovery after looking up a deployed App.Part of CLI-96
Backward/forward compatibility checks
Check these boxes or delete any item (or this section) if not relevant for this PR.
Note on protobuf: protobuf message changes in one place may have impact to
multiple entities (client, server, worker, database). See points above.
Changelog
App.from_name
methods for lazily constructing an App based on a lookup and anApp.hydrate
method for hydrating it with server metadata on demand. These methods should be used instead of the eagerApp.lookup
method, which will be deprecated soon (along with other.lookup
methods). Note thatApp.from_name
is primarily useful when you need an App to associate with amodal.Sandbox
; other use-cases should continue to create Apps via the main constructor (app = App(name)
).