Description
Right now, it looks like our Blob
and Bucket
objects are stateless, in that they don't keep a reference to a StorageService
object. What this means is, given we have the following:
StorageService storage = ... // Get a storage service (irrelevant how here)
Bucket bucket = storage.get("bucket-name");
Blob blob = storage.get("bucket-name", "blobname");
The only way to interact with these objects is by keeping a reference to the StorageService
:
BlobReadChannel channel = storage.reader("bucket", "blob");
// or
BlobReadChannel channel = storage.reader(blob); // I think?
There's no way to do:
BlobReadChannel channel = blob.getReadChannel(); // Or anything like this.
The purpose of this issue is to discuss whether or not these objects should hold a reference to the StorageService
which would make things like blob.getReadChannel()
or blob.delete()
possible rather than always calling storage.getReadChannel(blob)
and storage.delete(blob)
.
The benefits of this are friendlier-looking code (IMO at least....). The downsides are (I think) serialization becomes a bit more confusing, and what does it mean to send one "StorageService
-aware" Blob
into another StorageService
method, ie:
StorageService storageA = ... // Authenticated with read permissions only.
StorageService storageB = ... // Authenticated with read *and* write permissions.
Blob blobA = storageA.get("bucket-name", "blob");
blobA.delete(); // This should fail: blobA is tied to storageA, which has read-only permissions.
storageB.delete(blobA); // Should this "override" the `StorageService`?
I have no idea what the right answer is, but wanted to open the floor for discussion.