-
Notifications
You must be signed in to change notification settings - Fork 558
feat(odsp-client): lookupTemporaryBlobUrl functionality #25815
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
base: main
Are you sure you want to change the base?
Conversation
| try { | ||
| if ( | ||
| runtimeInternal !== undefined && | ||
| typeof (runtimeInternal as { lookupTemporaryBlobStorageId?: unknown }) |
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.
Shouldn't need this guard since odsp-client brings along a modern version of the runtime (via fluid-static) and therefore knows it's going to have a version with this function.
That said, would be nice to add a more explicit check and throw a more helpful error if it's missing in runtime-utils rather than a plain cast.
| * @returns The blob URL if found and the blob is not pending, undefined otherwise | ||
| */ | ||
| function lookupOdspBlobURL( | ||
| runtimeInternal: IContainerRuntimeInternal, |
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 runtime-utils lookupTemporaryBobStorageId takes an IContainerRuntime, so this should just be an IContainerRuntime.
| public constructor( | ||
| container: IContainer, | ||
| private readonly odspResolvedUrl?: IOdspResolvedUrl, | ||
| private readonly containerRuntimeInternal?: IContainerRuntimeInternal, |
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.
Here also prefer to pass around an IContainerRuntime. In general my preference is to defer casting to the internal type until just when it's needed.
| const resolvedUrl = container.resolvedUrl; | ||
| const odspResolvedUrl = | ||
| resolvedUrl && isOdspResolvedUrl(resolvedUrl) ? resolvedUrl : undefined; | ||
| return new OdspContainerServices(container, odspResolvedUrl, runtimeInternal); |
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.
Here you have everything you need to create a partially-applied function lookupTemporaryBlobURL(handle) and hand that function directly to the OdspContainerServices rather than making OdspContainerServices construct it itself. This will let you avoid passing large objects around.
| } | ||
|
|
||
| /** | ||
| * Unclear if this is the best way to go about accessing the runtime internal from the entry point. |
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.
Instead I think I'd expect to plumb a lookupTemporaryBlobStorageId onto IRootDataObject, in general IRootDataObject is the chokepoint for exposing stuff in the runtime to the outside world.
Description
Portion of #25597. Adds
lookupTemporaryBlobUrlfunctionality to OdspContainerServices. This new method allows consumers to see a handle's current blob url with no guarantees of the URL's longevity.Reviewer Guidance
The way I'm accessing ContainerRuntimeInternal is technically correct, but doesn't feel great. Should I alter some internal types used by
fluid-static?