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

upload: process counterflow messages #38

Merged
merged 12 commits into from
Jul 14, 2021
Merged

upload: process counterflow messages #38

merged 12 commits into from
Jul 14, 2021

Conversation

bassosimone
Copy link
Contributor

@bassosimone bassosimone commented Feb 11, 2020

While there, also go get -u -v ./... && go mod tidy


This change is Reviewable

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.
@bassosimone bassosimone requested a review from pboothe February 12, 2020 15:18
@robertodauria robertodauria requested review from stephen-soltesz and removed request for pboothe July 13, 2021 21:28
Copy link
Contributor

@stephen-soltesz stephen-soltesz left a 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.

Copy link
Contributor

@robertodauria robertodauria left a 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 be continue? 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?

Copy link
Contributor

@stephen-soltesz stephen-soltesz left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: 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 point readcounterflow has quit already in every case. Is my understanding correct?

lgtm 👍

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