Skip to content
This repository was archived by the owner on Sep 11, 2020. It is now read-only.

remote: sideband support #156

Closed
wants to merge 2 commits into from
Closed

remote: sideband support #156

wants to merge 2 commits into from

Conversation

mcuadros
Copy link
Contributor

@mcuadros mcuadros commented Dec 4, 2016

This is the support of Remote for sideband capable servers.

When Remote. Fetch is called If the request contained a side-band-64k or side-band a sideband.Demux is used inside of Remote to read the packfile data.

If the human readable progress is needed a io.Reader/io.Writer should be provided to Repository.Progress field, this pointer will be pass to the remotes and be used when the packfile is read. If the Repository.Progress is not set the no-progress capability is set if supported.

Also a couple of bugs are solved at transport/client:

  • Content-Length is correctly encoded using strconv.Itoa instead of just casting a integer to string.
  • Request encoding is done now using the encoders provide by the `protocol/packp package

@codecov-io
Copy link

codecov-io commented Dec 4, 2016

Current coverage is 76.42% (diff: 77.55%)

Merging #156 into master will decrease coverage by 0.41%

@@             master       #156   diff @@
==========================================
  Files            80         83     +3   
  Lines          5150       5344   +194   
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
+ Hits           3957       4084   +127   
- Misses          749        810    +61   
- Partials        444        450     +6   

Powered by Codecov. Last update 528e2cd...a9d003f

}

// Demuxer demultiplex the progress reports and error info interleaved with the
// packfile itself.
//
// A sideband has three diferent channels the main one call PackData contains
// A sideband has three diferent channels the main one, call PackData, contains
// the packfile data, the ErrorMessage channel, that contains server errors and
// the last one ProgressMessage channel containing information about the ongoing
// tast happening in the server (optinal, can be suppressed sending NoProgress
// or Quiet capabilities to the server)
Copy link
Contributor

@alcortesm alcortesm Dec 5, 2016

Choose a reason for hiding this comment

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

English grammar and typos, consider this alternate version:

Sideband information comes through 3 different channels:
- PackData: the packfile data itself.
- ErrorMessage: server errors.
- ProgressMessage: progress information about the packfile download
  process.  When the NoProgress and/or Quiet capabilities are in use,
  this channel remains silent.

// stored and can be read from `Progress` field, if any message is retrieved
// from the ErrorMessage channel an error is returned and we can assume that the
// written at `Progress` (if any), if any message is retrieved from the
// ErrorMessage channel an error is returned and we can assume that the
// conection has been closed.
type Demuxer struct {
Copy link
Contributor

@alcortesm alcortesm Dec 5, 2016

Choose a reason for hiding this comment

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

This is confusing as the Demuxer type does not actually demultiplex the channels and it is not clear how are errors messages sent back to the user. Also a connection is mentioned in the comment, and some assumptions about it being closed, but it is not clear how this can be relevant for anything.

I think a better comment would be something like this:

[Foo] is a reader to the packfile data in the PackData channel.  The progress information
is writen to the the Progress field while reading.  If any message is received through the
ErrorMessage channel, the `Read` method will return it as an error and it will assume the
connection has been closed.

Although I am still not sure about the connection thing.

I would rather use a real demuxer though or even simply a method that returns 3 readers (or even better, 3 scanners): one for each channel, treating them as equal, with the same usage semantics. This will have a much simpler API and will let the user decide how to use each channel.

Another approach would be to use a single scanner, returning channel and data when read.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, this is not a PR of the sideband demux this was already merged. Your text doesn't explain that the Progress could be optional. I will review the text with the new phrase

t: t,
r: r,
max: max,
s: pktline.NewScanner(r),
}
}

// Read reads up to len(p) bytes from the PackData channel into p, an error can
// be return if an error happends when reading or if a message is sent in the
Copy link
Contributor

Choose a reason for hiding this comment

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

s/sent/received/

Copy link
Contributor

Choose a reason for hiding this comment

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

s/in/over/

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you are reviewing an already merged comment

// is zero, err will be nil unless an error reading happens.
// If a ProgressMessage is read, it won't be copied to b. Instead of this,
// Progress was set will be stored there. If the n value returned is zero, err
// will be nil unless an error reading happens.
Copy link
Contributor

Choose a reason for hiding this comment

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

rewrite.

@@ -126,13 +125,17 @@ func (d *Demuxer) nextPackData() ([]byte, error) {
case PackData:
return content[1:], nil
case ProgressMessage:
_, err := d.Progress.(io.Writer).Write(content[1:])
return nil, err
if d.Progress != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think NewDemuxer should has a Progress as an argument.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is a optional argument, and not the most common behavior, so that's why is not part of the New method

@@ -19,6 +19,8 @@ import (
"gopkg.in/src-d/go-git.v4/storage/memory"
osfs "gopkg.in/src-d/go-git.v4/utils/fs/os"

"bytes"
Copy link
Collaborator

Choose a reason for hiding this comment

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

import order

@mcuadros mcuadros closed this Dec 6, 2016
@mcuadros mcuadros deleted the sideband-client branch December 6, 2016 20:44
@mcuadros mcuadros mentioned this pull request Dec 6, 2016
gsalingu-ovhus pushed a commit to gsalingu-ovhus/go-git that referenced this pull request Mar 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants