Skip to content
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

Add progress events #40

Merged
merged 2 commits into from
Mar 6, 2017
Merged

Conversation

iGEL
Copy link
Contributor

@iGEL iGEL commented Mar 1, 2017

What do you think about this?

Paired on with @yundt

@danielcompton
Copy link
Collaborator

This looks pretty reasonable, I'll just need to take a closer look to make sure the API changes are ok. Thanks!

Copy link
Owner

@martinklepsch martinklepsch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this! Progress events have been on the list since the beginning and this looks like a straightforward implementation 👍

:bytes-sent - the size of the already uploaded potion in bytes
:bytes-total - the total file size in bytes
:identifier - an identifier pass-through value for caller to identify the file with"
[progress-events {:keys [f identifier form-data upload-url] :as upload-info} ch]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think instead of passing progress-events as argument here we should pass a map so we can extend the number of options passed without introducing backwards incompatible (fn-arity) changes.

[{:keys [progress-events] :as opts} ... ]

@@ -144,7 +164,8 @@
defaults to read-string.
:key-fn - a function used to generate the object key for the uploaded file on S3
defaults to nil, which means it will use the passed filename as the object key.
:headers-fn - a function used to create the headers for the GET request to the signing server."
:headers-fn - a function used to create the headers for the GET request to the signing server.
:progress-events - if true, progress events will be pushed on to channel during upload."
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if this should maybe be :progress-events? since it's a boolean flag? Or do we only do that with functions that return boolean values?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, I think boolean parameters should also have a ? at the end by default.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, document that it defaults to false.

Copy link
Collaborator

@danielcompton danielcompton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is pretty good, but I've left some review notes.

@@ -144,7 +164,8 @@
defaults to read-string.
:key-fn - a function used to generate the object key for the uploaded file on S3
defaults to nil, which means it will use the passed filename as the object key.
:headers-fn - a function used to create the headers for the GET request to the signing server."
:headers-fn - a function used to create the headers for the GET request to the signing server.
:progress-events - if true, progress events will be pushed on to channel during upload."
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, I think boolean parameters should also have a ? at the end by default.

project.clj Outdated
@@ -7,8 +7,8 @@

:source-paths ["src/clj" "src/cljs"]

:dependencies [[org.clojure/clojure "1.6.0" :scope "provided"]
[org.clojure/clojurescript "0.0-2371" :scope "provided"]
:dependencies [[org.clojure/clojure "1.8.0" :scope "provided"]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do these upgrades need to be done as part of this change? If they're separate it can make it easier to bisect any breakage down the line.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess, I could revert the clojure bump.

About cljs: Google's XhrIo lib got support for these events only in August 2015, so I assume it's in the v20150901 release (there is no changelog entry). Clojurescript bumped the version in October 2015, which was included in the 1.7.170 release.

I'm not that experienced with clojurescript, so I trust you which version I should require here. I'm not even sure, whether this has effects on the users of the lib. 😉

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now, I set it to 1.7.170.

## Changes

#### Unreleased

- Add support for progress events.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 thanks for adding a changelog entry 😄.

(if (contains? upload-info :error-code)
(do
(put! ch upload-info)
(put! ch (merge {:type :error}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this just be assoc upload-info :type :error?

@@ -144,7 +164,8 @@
defaults to read-string.
:key-fn - a function used to generate the object key for the uploaded file on S3
defaults to nil, which means it will use the passed filename as the object key.
:headers-fn - a function used to create the headers for the GET request to the signing server."
:headers-fn - a function used to create the headers for the GET request to the signing server.
:progress-events - if true, progress events will be pushed on to channel during upload."
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, document that it defaults to false.

@danielcompton
Copy link
Collaborator

I wish GitHub's review system didn't feel so negative when I requested changes. It makes me feel like I've put a big red x all over it, when that's not how I feel at all...

iGEL added 2 commits March 6, 2017 11:26
Paired on with @yundt, sponsored by @BillFront.
Sepearate for better reviewing, will squash the commits later.

Sponsored by @BillFront.
@iGEL
Copy link
Contributor Author

iGEL commented Mar 6, 2017

Thanks for the review, @martinklepsch & @danielcompton. I addressed the issues, would be nice if you could have another look.

@martinklepsch
Copy link
Owner

martinklepsch commented Mar 6, 2017

Looking good to me 👍 Thanks for taking the time!

@danielcompton danielcompton merged commit c7b0edd into martinklepsch:master Mar 6, 2017
@danielcompton
Copy link
Collaborator

I've pushed an alpha3 version to GitHub, @martinklepsch are you able to deploy to Clojars? @iGEL once it's all deployed and you're using it in production, can you report back in a week with any progress? (ba dum tish)

If it's all good then we can release an 0.6.0. Thanks!

@iGEL
Copy link
Contributor Author

iGEL commented Mar 6, 2017

Thanks for the support and merge!

Unfortunately we're still a few weeks away from production usage. Also, we have very few (but valuable) users, a proper cross browser test will be more telling. Hope that someone has a better test field.

@iGEL iGEL deleted the progress-events branch March 6, 2017 20:46
@martinklepsch
Copy link
Owner

@danielcompton @iGEL Hey folks, I just pushed to Clojars:

[org.martinklepsch/s3-beam "0.6.0-alpha3"]

Sorry for the delay on this and nice work everyone :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants