Skip to content
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

chore(cleanup)!: Remove redundant callback types, move storage.ts to … #2445

Closed
wants to merge 10 commits into from

Conversation

ddelgrosso1
Copy link
Contributor

…calling gaxios

Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

Fixes #<issue_number_goes_here> 🦕

@product-auto-label product-auto-label bot added size: l Pull request size is large. api: storage Issues related to the googleapis/nodejs-storage API. labels Apr 24, 2024
@ddelgrosso1
Copy link
Contributor Author

Gigantic WIP / PoC

@product-auto-label product-auto-label bot added size: xl Pull request size is extra large. and removed size: l Pull request size is large. labels May 16, 2024
@ddelgrosso1 ddelgrosso1 changed the base branch from main to gaxios-feature May 22, 2024 21:33
@ddelgrosso1 ddelgrosso1 marked this pull request as ready for review May 22, 2024 21:35
@ddelgrosso1 ddelgrosso1 requested review from a team as code owners May 22, 2024 21:35
Copy link

@danielduhh danielduhh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIUC the bulk of this PR is refactoring all the common options to "Storage-Transport" and wiring everything back together? If thats right, it would be helpful to add context in the StorageTransport docs.

Also, if this is the case, maybe create a seperate PR that introduces the concept of "storage-transport", and then the PRs after that can incrementally refactor specific files that need to be refactored (e.g. ACL, Bucket, HMAC, etc.)

[hmacKey] = await storage.createHmacKey(
`${TESTS_PREFIX}@email.com`
);
hmacKey = await storage.createHmacKey(`${TESTS_PREFIX}@email.com`);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Im guessing we can remove this once #2461 is complete?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a conformance test, it already runs against test bench. The change here is that it no longer returns an array, only a single element.


storage.interceptors.push({
//TODO: Interceptors

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add a bug here with more info on the TODO?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can actually be fixed now. When I started this was dependent on adding interceptors to gaxios.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed this.

@@ -795,7 +795,7 @@ export async function notificationGetMetadata(options: ConformanceTestOptions) {

export async function createBucket(options: ConformanceTestOptions) {
const bucket = options.storage!.bucket('test-creating-bucket');
const [exists] = await bucket.exists();
const exists = await bucket.exists();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whats the change here? previously we were returning an array, and now its an object?
It would be helpful to start a README doc with a list of "breaking" changes so that we make sure we cover everything

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or update PR description with a checklist of # of changes that need to happen

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We were returning arrays for no reason all over the place. I'm trying to bring responses much more in line with the standard JSON API responses.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The number of breaking changes is going to be too big for comments / PR commit messsages. I have created an issue in buganizer to create a migration guide.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Throwing out some random ideas here... It seems like migrating for returning an array vs object is the big breaking change here. Is there anyway to have some kind of flag for customers who want to keep the current behavior? We can eventually deprecate the flag but it would give customers some more time to keep the current behavior while we modernize the library

(err: GaxiosError<T> | null, data?: T): void;
}

interface TransportParameters extends Omit<GoogleAuthOptions, 'authClient'> {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where's Omit coming from?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

v cool. TIL

}

interface TransportParameters extends Omit<GoogleAuthOptions, 'authClient'> {
apiEndpoint: string;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are these options all copied from somewhere? What's the source and how do we know nothing is missing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is extending GoogleAuthOptions but omitting authClient.


const keyIndex = this.interceptors.indexOf(
// TODO: INTERCEPTORS

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same request about adding a bug or notes

src/file.ts Outdated
this.bucket.name
}/${encodeURIComponent(this.name)}`,
headers,
//headers,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why comment this out?

@@ -13,33 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this file even necessary anymore?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably not. I was going to sweep up all the garbage once I got things back to a working state.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sg, can you add it to some tracking list of TODOs

@@ -779,6 +755,10 @@ export class Storage extends Service {

this.retryOptions = config.retryOptions;

this.storageTransport = new StorageTransport({...config, ...options});
//this.interceptors = [];
this.universeDomain = options.universeDomain || DEFAULT_UNIVERSE;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wheres this change coming from?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What change are you referring to? It probably shows all three lines as new because I commented out the interceptors and added StorageTransport. I didn't touch universedomain.

@@ -654,7 +655,7 @@ export class TransferManager {
: fileOrName;

const fileInfo = await file.get();
const size = parseInt(fileInfo[0].metadata.size!.toString());
const size = parseInt(fileInfo.metadata.size!.toString());

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar question here about expecting an array vs a single object

@ddelgrosso1
Copy link
Contributor Author

IIUC the bulk of this PR is refactoring all the common options to "Storage-Transport" and wiring everything back together? If thats right, it would be helpful to add context in the StorageTransport docs.

Also, if this is the case, maybe create a seperate PR that introduces the concept of "storage-transport", and then the PRs after that can incrementally refactor specific files that need to be refactored (e.g. ACL, Bucket, HMAC, etc.)

Sort of. StorageTransport is replacing the mixture of transport level options and functionality that was spread across several files (Service, ServiceObject, util).

I think we are a bit too far past just introducing Storage Transport. I think at this point our best path forward is to merge this into the feature branch and then do as you suggest and work on each file / section individually.

@ddelgrosso1 ddelgrosso1 closed this Jul 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: storage Issues related to the googleapis/nodejs-storage API. size: xl Pull request size is extra large.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants