Repository navigation
Should Blobs and Buckets be stateless or keep a reference to a StorageService ? #55
Description
Activity
- addedtype: questionRequest for information or clarification. Not an issue.Request for information or clarification. Not an issue.api: storageIssues related to the Cloud Storage API.Issues related to the Cloud Storage API.
on May 12, 2015 I think that this is nice but consider it in the level of a syntactic sugar. I don't think an extra reference to Storage service would be a problem.
Two more things to consider are:
- consistency with the Datastore API
- This would either make the blobs/bucket mutable or operation would have to return a new copy
- modified the milestones: This milestone has been deleted, This milestone has been deleted
on Jun 1, 2015 I am taking over on this.
It would be nice for functionalBucketto return functionalBlobobjects (in methods likegetorlist) rather thanBucketInfoobjects (so that users do not need to do further conversions asnew Blob(bucket.get("someBlob"))).This is perfectly doable for
getmethods. Forlistmethod instead we use the underlyingstorage.listwich returns aListResult<BlobInfo>.ListResultis an iterable that handles pagination and is also serializable.ListResulttherefore takes only seriablizable types. Because of that we can not instantiateListResult<Blob>. I see two solutions here given that we want to preserve the fact that storage works with serializable types (and I think we should):- Define a BlobList class which wraps ListResult and is an
Iterable<Blob> - Let bucket methods return
BlobInforather than functionalBlob
I would personally prefer solution 1.
@jgeewax @aozarov @ajkannan thoughs?- Define a BlobList class which wraps ListResult and is an
I also think that Bucket should return (functional) Blob.
Another option would be remove the constrain that
Tneeds to beSerializablebut
document that theresultsparam must beSerializable. and then passresults<Blob>
that keeps a transient reference to storageService and convertBlobInfotoBlobon the fly.Now the question is how do we create storageService upon de-serialization of that implementation
of results. For that I think we can do the following (probably should be done as a prior PR):I think it is reasonable to ask
XXXFactoryto be serialize.
with bothXXXOptionsandXXXFactoryserializable we can always construct the implementation
for XXX service.
We could pass both factory and option to the service impl (maybe even have part of the service contract)getFactoryas we have nowgetOptions.If we do so, we could technically even make the functional
BlobandBucketSerializableand the
keep the signature ofListResultas is...What do you think?
I am not sure I would want functional classes as Blob, Bucket or XXX Service to be serializable. I think having serializable BlobInfo and BucketInfo is good as the classes are semantically containers or metadata. But for XXX Service, Blob and Bucker I struggle to find reasons for making them serializable.
Yes, we don't have to make or declare them as serializable, the other approach was to transform them on the fly and remove the requirement of having T serializable. Any opinion on that?
15 remaining items
- added a commit that references this issue
on Jul 14, 2022 - added a commit that references this issue
on Aug 9, 2022 - added 2 commits that reference this issue
on Oct 4, 2022 - added a commit that references this issue
on Dec 22, 2025 - added 2 commits that reference this issue
on Jan 6, 2026 - added a commit that references this issue
on Jan 22, 2026 - added a commit that references this issue
on Feb 24, 2026 - added a commit that references this issue
on Mar 11, 2026 - added a commit that references this issue
on Mar 12, 2026 - added 2 commits that reference this issue
on Mar 23, 2026
Right now, it looks like our
BlobandBucketobjects are stateless, in that they don't keep a reference to aStorageServiceobject. What this means is, given we have the following:The only way to interact with these objects is by keeping a reference to the
StorageService:There's no way to do:
The purpose of this issue is to discuss whether or not these objects should hold a reference to the
StorageServicewhich would make things likeblob.getReadChannel()orblob.delete()possible rather than always callingstorage.getReadChannel(blob)andstorage.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"Blobinto anotherStorageServicemethod, ie:I have no idea what the right answer is, but wanted to open the floor for discussion.
/cc @aozarov @jboynes