-
Notifications
You must be signed in to change notification settings - Fork 25
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
upload: process counterflow messages #38
Conversation
At this point I'm writing Go 1.13 and indeed we've seen that the code does not compile when using Go 1.13.
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.
Reviewed 1 of 3 files at r3.
Reviewable status: 1 change requests, 0 of 1 approvals obtained (waiting on @bassosimone)
internal/upload/upload.go, line 52 at r3 (raw file):
err := conn.SetReadDeadline(time.Now().Add(params.UploadTimeout)) if err != nil { errCh <- err
Previously this loop would return
. Now it continues -- should this be continue
? Or return the err and then return? or break? Are these errors recoverable?
Whatever the case, similar handling below.
internal/upload/upload.go, line 135 at r3 (raw file):
ctx, cancel := context.WithTimeout(ctx, params.UploadTimeout) defer cancel() errCh := make(chan error)
Who closes this channel?
internal/upload/upload.go, line 148 at r3 (raw file):
err := <-errCh if err != nil {
If Run returns on the first error from the readcounterflow
goroutine, I would expect the goroutine to quit immediately.
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.
Reviewable status: 1 change requests, 0 of 1 approvals obtained (waiting on @stephen-soltesz)
internal/upload/upload.go, line 52 at r3 (raw file):
Previously, stephen-soltesz (Stephen Soltesz) wrote…
Previously this loop would
return
. Now it continues -- should this becontinue
? Or return the err and then return? or break? Are these errors recoverable?Whatever the case, similar handling below.
Good catch! These should never happen under normal operation.
- Setting a ReadDeadline should always be possible
- ReadMessage() shouldn't fail unless the connection was dropped
- The server should never send anything other than TextMessages during the upload
- The JSON from the server should be a valid
spec.Measurement
in every case
I would prefer to let the upload fail, so it's obvious something is wrong (either on the server or something strange between client and server or the connection was dropped).
internal/upload/upload.go, line 135 at r3 (raw file):
Previously, stephen-soltesz (Stephen Soltesz) wrote…
Who closes this channel?
The reader (this function). I've added a defer close(errCh)
.
internal/upload/upload.go, line 148 at r3 (raw file):
Previously, stephen-soltesz (Stephen Soltesz) wrote…
If Run returns on the first error from the
readcounterflow
goroutine, I would expect the goroutine to quit immediately.
readcounterflow
now can only write to the channel once (an error or nil if successful) before returning. At this point readcounterflow
has quit already in every case. Is my understanding correct?
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.
Reviewable status:
complete! 1 of 1 approvals obtained
internal/upload/upload.go, line 148 at r3 (raw file):
Previously, robertodauria (Roberto D'Auria) wrote…
readcounterflow
now can only write to the channel once (an error or nil if successful) before returning. At this pointreadcounterflow
has quit already in every case. Is my understanding correct?
lgtm 👍
While there, also
go get -u -v ./... && go mod tidy
This change is![Reviewable](https://camo.githubusercontent.com/1541c4039185914e83657d3683ec25920c672c6c5c7ab4240ee7bff601adec0b/68747470733a2f2f72657669657761626c652e696f2f7265766965775f627574746f6e2e737667)