-
Notifications
You must be signed in to change notification settings - Fork 808
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
blob: remove global registry for Open #931
Comments
Importantly: can you add code snippets showing how a user application would use this? Assume they want to pick and choose which providers they want to support (although choosing the "default" ones should be easier). |
Is it worth currying this? We could just have
|
On #981 (comment), @clausti suggested that maybe the scheme(s) that a provider registers for should be exposed as public constants for the package. |
One additional consideration that occurred to me while hacking on this (and this might be a separate issue): do we want to support being able to open readers and writers by URL? It seems like a natural extension. EDIT: This is a separate issue. Opened #1101 to track. |
Added URLOpener types to all of the provider packages. Fixes google#931
Updates google#931 Updates google#1174
Obsoleted by design decisions in #1174. |
blob.Open
currently operates from a global, mutable registry (populated withblob.Register
). Go Cloud emphatically tries to avoid the pattern of having a global registry due to the confusion that can come in the face of conflicting keys and the difficulty of reasoning about side effects, especially when incorporating into a large application or when multiple incompatible versions are present. Avoiding global mutable state in favor of explicit construction is preferred.Proposed Change
The
blob
package should grow a new type (calledOpener
below, but exact name TBD) that manages the mapping to different implementations. A reasonable default package can exist in the Go Cloud repository that imports GCS, S3, and Azure.and elsewhere:
While this adds a bit more setup code, it:
*blob.Opener
s to be present in different parts of the applicationOpen
call and the bucket much more explicitFromURLFunc
s being sent to the opener/cc @vangent @shantuo
The text was updated successfully, but these errors were encountered: