-
Notifications
You must be signed in to change notification settings - Fork 103
Feature: conditional upload API #178
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
…, inmem providers Signed-off-by: Tom Plowman <7210552+alsenz@users.noreply.github.com>
Signed-off-by: Tom Plowman <7210552+alsenz@users.noreply.github.com>
Signed-off-by: Tom Plowman <7210552+alsenz@users.noreply.github.com>
Signed-off-by: Tom Plowman <7210552+alsenz@users.noreply.github.com>
c21b930 to
1bb876b
Compare
|
@bwplotka - would you be the appropriate maintainer to submit this for a first review? Greatly appreciated. |
| } | ||
| } | ||
|
|
||
| func tryOpenFile(name string, ifNotExists bool) (exists bool, err error) { |
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.
does it leak file descriptor?
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.
Agreed - fixed.
| } | ||
|
|
||
| // ValidateUploadOptions ensures that only supported options are passed as options. | ||
| func ValidateUploadOptions(supportedOptions []ObjectUploadOptionType, opts ...ObjectUploadOption) error { |
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.
maybe we should also validate IfNotExists and IfMatch/IfNotMatch aren't used together
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.
Sounds sensible - done.
| b.mtx.Lock() | ||
| defer b.mtx.Unlock() | ||
|
|
||
| params := ApplyObjectUploadOptions(opts...) |
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.
shall we validate the options here?
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.
Whoops - done!
|
What's the progress on this PR? Any chance it gets merged? |
Signed-off-by: Alsenz <7210552+alsenz@users.noreply.github.com>
Signed-off-by: Tom Plowman <7210552+alsenz@users.noreply.github.com>
a5d77ae to
b395c1c
Compare
Signed-off-by: Tom Plowman <7210552+alsenz@users.noreply.github.com>
|
Thanks @yuchen-db for your review. I agree with all your points and have pushed some changes accordingly. This is an old PR but hopefully we can get it across the line. |
|
@anarcher this is an older PR that didn't get much attention, hopefully the maintainers will be able to find some time to review and accept. I have brought the feature branch back in line with main and responded to comments, so it should be ready to go. |
Signed-off-by: Tom Plowman <7210552+alsenz@users.noreply.github.com>
Signed-off-by: Tom Plowman <7210552+alsenz@users.noreply.github.com>
cbdcc69 to
9ee1894
Compare
Signed-off-by: Tom Plowman <7210552+alsenz@users.noreply.github.com>
Resolves #129
Adds support for conditional object uploads.
Extends
ObjectAttributeswith optionalObjectVersion(if supported), andUpload(...)with three newObjectUploadOption, depending on provider support.IfMatch: the object is written only if the existing object matches the provided versionIfNotMatch: the object is written only if the existing object does not match the provided versionIfNotExists: the object is written only if no object already exists for the provided keySupports two forms of
ObjectVersion:Not all providers support conditional write. The following providers are supported:
IfNotMatchis not yet supported (as it is not supported by AWS).Clients can check conditional API by calling
SupportedObjectUploadOptionson theBucketinterface.Changes
API changes
ObjectUploadOptions:IfMatch,IfNotMatchandIfNotExists1.1 Made
ObjectUploadOptiontyped, repeating the existingIterOptionpattern.1.2 Added three new parameter modifiers-
WithIfMatch,WithIfNotExistsandWithIfNotMatch, andWithContentTypeto support the previous un-typedObjectUploadOptionObjectVersionfield toObjectAttributesIfMatch,IfNotMatch,IfNotExistsand forAttributesAPIBucketprovider implementations for:1.1 filesystem: this now uses Extended Attributes, if supported by the host system
1.2 inmem
1.3 GCS
1.4 Azure
1.5 S3, excepting
IfNoneMatchwhich is not fully supported (by AWS) yet1.6 Wrappers
Backwards compatibility
API changes are additive and should be backwards compatible.
The
UploadAPI changes use a trailing variadic parameter so should be backwards compatibleThe
ObjectAttributesadd new field so should be backwards compatibleThe
SupportedObjectUploadOptionsinterface method potentially breaks existingBucketimplementations. Library users who implement their own providers will need to implement this method. Full or stub implementations are provided for all provider implementations in the libary.Dependencies
Verification
Added acceptance tests for
IfMatchIfNotMatchIfExistsDid not run integration tests on other object store providers, as I do not have access to test environments, but these should be unchanged.