Closed fsouza closed 7 years ago
I can also work on the s3 driver, the code would be very similar, as the concepts are the same. Just let me know if you like the structure of this PR.
This looks great. I have a question around https://github.com/mattes/migrate/pull/227/files#diff-4178ab4a0dc6cc9bd3e00c7d70f1d1bfR48. Does the GCS API offer a way to return the next file without loading them all upfront?
@mattes we could use prefixes for both GCS and S3 on this, but I don't think it is safe to assume the prefix of the migration (e.g. 1 vs 01 vs 001 vs 0001), is it?
Aside from that, both systems support pagination, and the S3 sdk allows me to set page size to 1 (see #228), but I wasn't able to find a similar option in the GCS sdk (the API supports that, but the sdk doesn't expose the option).
Since the GCS client uses iterators for the file list (and underneath it paginates requests, but I think I don't have control on the size of the page), we could save the iterator internally and consume it as the user calls Next (and save the list to support Prev). This way loadMigrations would make the call and save the iterator as an attribute in the struct.
See my comment for the AWS driver. Let's merge it the way it is for now and then in the future we can iterate and improve.
@mattes please let me know what you think.
I wanted to have a better test coverage on this, but testing the Open method is hard because of the call to
storage.NewClient
.Closes #163.