-
Notifications
You must be signed in to change notification settings - Fork 29
Added StreamUpload #59
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
Conversation
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.
Do we want to be including white papers in the project, rather than a link to the whitepaper? Along with an explanation as to why it's relevant.
commit to that point and easily roll back if there is an interruption in | ||
the upload. | ||
|
||
In the code that I had sent previously, this would be at line 61 where |
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.
Give a link; Line 61 of what?
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.
It is an email from Tom's forwarded by Saswata. just attach it as a reference. So I don't make any change on it.
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.
The problem is that most readers will not understand this. I think you should either turn this into a *.md and reformat
it yourself or create a docs/merkle/streaming-merkle-hasher.md
where you introduce
this file and docs/merkle/streaming-merkle-hasher.node
.
BTW is this the reference to streaming-merkle-hasher.node, because if so its by no mean clear and you should replace In the code that I had sent previously, this would be at line 61
with something like (use 0chain repository)
In [streaming-merkle-hasher.node line 61](https://github.com/cnlangzi/gosdk/blob/featur/continuous_upload/docs/merkle/streaming-merkle-hasher.node#L61)
Alternately you could say in the .md file, that the line 61
mentioned at the end of the letter is here and then give the link.
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.
streaming-merkle-hasher.txt
is original content of Tom's email. I think It is unnecessary to update it. It has been implemented in stream_merkle_hasher.go. It is safe to remove them now.
And @guruhubb maybe better to explain it than me.
@@ -0,0 +1,122 @@ | |||
"use strict"; |
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.
What is the purpose of this streaming-merkle-hasher.node
file?
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.
It is an example code in nodejs. Please check streaming-merkle-hasher.txt. Tom explains it there.
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.
Where exactly? I found a reference in stream_merkle_hasher.go, is this an algorithm you have converted from javascript to go?
Does this file exist in an external GitHub repository? If so, I think a link to the file in its home repository would provide better context.
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.
Yes. It is written in go with some improvement in stream_merkle_hasher.go
The nodejs is written by Tom. They are forwarded by @guruhubb. just add it here as a reference. It is safe to remove now. I will remove them.
I am testing StreamUpload. so some code maybe be changed. please review it after I get test passed. thanks. |
FYI: |
@Sriep please help me to review PR if you get some time left , thanks. |
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.
For unit tests you can check out 0chain/0chain#325. Also recent unit tests in zboxcore/sdk might help https://github.com/0chain/gosdk/blob/master/zboxcore/sdk/filestatsworker_test.go
FileStore <- FileSystem: FileRef with merkle leave hash | ||
StorageHandler <- FileStore: FileOutputData | ||
StorageHandler -> AllocationChangeProcessor: Add `InitFileChange` | ||
UploadHandler <- StorageHandler: UploadResult |
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.
Is this all happening in gosdk
? If this for example some of these participants are in the blobber maybe you could indicate this.
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.
That is done in zbox and blobber with some update. I will update this UML. do you suggest where it should be put ?
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.
Wherever you are using it. Is this the same file you put in the blobber PR description?
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.
Yes. the UML diagram is built based on upload.puml
. do you know https://plantuml.com/?
|
||
} | ||
|
||
func (sb *StreamUploadBobbler) processUpload(su *StreamUpload, chunkIndex int, fileBytes, thumbnailBytes []byte, isFinal bool, wg *sync.WaitGroup) { |
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.
Please can we have unit tests for new functions.
type StreamUploadOption func(su *StreamUpload) | ||
|
||
// WithThumbnail add thumbnail. stream mode is unnecessary for thumbnail | ||
func WithThumbnail(buf []byte) StreamUploadOption { |
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.
Please can we have unit tests for new functions.
@@ -354,6 +354,25 @@ func NewListRequest(baseUrl, allocation string, path string, auth_token string) | |||
return req, nil | |||
} | |||
|
|||
// NewUploadRequestWithMethod create a http reqeust of upload | |||
func NewUploadRequestWithMethod(baseURL, allocation string, body io.Reader, method string) (*http.Request, 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.
There should be a unit test to confirm NewUploadRequestWithMethod
returns the right http.Request. I know no one else has done it, but that's now reason why this PR should make the same mistake.
@Sriep |
|
||
2) Otherwise: | ||
2.a) set H to hash(HashNodes[index], H) | ||
2.b) delete HashNodes[index] (i.e. set this position to empty) |
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.
Add comma, i.e.
should be i.e.,
@@ -0,0 +1,122 @@ | |||
"use strict"; |
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.
Where exactly? I found a reference in stream_merkle_hasher.go, is this an algorithm you have converted from javascript to go?
Does this file exist in an external GitHub repository? If so, I think a link to the file in its home repository would provide better context.
commit to that point and easily roll back if there is an interruption in | ||
the upload. | ||
|
||
In the code that I had sent previously, this would be at line 61 where |
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.
The problem is that most readers will not understand this. I think you should either turn this into a *.md and reformat
it yourself or create a docs/merkle/streaming-merkle-hasher.md
where you introduce
this file and docs/merkle/streaming-merkle-hasher.node
.
BTW is this the reference to streaming-merkle-hasher.node, because if so its by no mean clear and you should replace In the code that I had sent previously, this would be at line 61
with something like (use 0chain repository)
In [streaming-merkle-hasher.node line 61](https://github.com/cnlangzi/gosdk/blob/featur/continuous_upload/docs/merkle/streaming-merkle-hasher.node#L61)
Alternately you could say in the .md file, that the line 61
mentioned at the end of the letter is here and then give the link.
ignore it first. thanks. |
link to 0chain/blobber#166
Added StreamUpload with more clean design with parts