Comments (3)
When I first designed the StoreComposer API, I used a similar approach as you are proposing here but it had its flaws. First of all, it does not properly work if you have a struct embedding a DataStore as it will hide all additional interfaces which are implemented by the embedded struct. Here is an example to help you understand this issue: https://play.golang.org/p/Eih7d2FvqH. This behavior is un-intuitive and I was very surprised when I first encountered it. Therefore I would prefer to save people the time of catching such a bug.
Secondly, I like my code explicit. It is way more descriptive to tell exactly which extension should be used in a given composer. It makes reading, understanding and debugging easier and that's even worth the additional lines which have to be written.
Finally, a StoreComposer will be created using exactly this method (as you described) when you pass a DataStore instead of an StoreComposer in the configuration (see https://github.com/tus/tusd/blob/master/config.go#L65-L68 and https://github.com/tus/tusd/blob/master/composer.go#L29-L50). This code is not there because I like it but simply to keep it backwards-compatible because the StoreComposer was added later as I discovered weird behavior with interfaces as I described in the first paragraph.
All in all I am not an eager fan of this idea but I am looking forward to your answer.
from tusd.
The main goal is to simplify the example of the Readme:
// A storage backend for tusd may consist of multiple different parts which
// handle upload creation, locking, termination and so on. The composer is a
// place where all those seperated pieces are joined together. In this example
// we only use the file store but you may plug in multiple.
composer := tusd.NewStoreComposer()
compoer.UseAllExtensions(store) // instead of store.UseIn(composer)
If you think it might be a good idea, I can make a PR with this.
from tusd.
I saw your example and didn't know about this behavior: thanks for pointing it out!
Maybe you could add a link to your example (or this issue) in the source so that it appears in the godoc
// The usage of this field is deprecated and should be avoided in favor of
// StoreComposer (see https://github.com/tus/tusd/issues/76).
from tusd.
Related Issues (20)
- Exposing header via cors-expose-header Issue HOT 2
- GPS metadata are removed when uploading images
- Breacking change on Hook-Name header HOT 2
- Second attempt to host a Helm chart HOT 5
- Allow stopping uploads in PatchRequest before any data is passed to the store HOT 3
- handler: support HTTP range requests in GET /:upload HOT 3
- Support RUFH draft-01 and -02
- S3 backend with TUS handler fails to handle PATCH HOT 10
- Keep old metadata after modifying it in pre-create hook HOT 1
- S3 Storage GetReader Range Support HOT 1
- Uniform Termination Process for Store Implementations: Ensuring Consistent Removal of Binary and .info Files HOT 1
- Cleaning up .info files HOT 3
- s3store: Experiment with optimistic part uploads to S3 HOT 2
- Tus returning http in initial response causing redirect to https to strip authorization headers HOT 3
- docs: Add developing and contributing guide
- docs: Add example usage with Minio and Azurite
- Many post-receive hooks after post-finish hook HOT 3
- Unable to fetch Upload Id from Path HOT 1
- cli: Option log-format=json is ignored for plugin logs HOT 1
- using tusd handler with gorilla mux causing "NetworkControlError" warnings HOT 10
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tusd.