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

Command channel output #499

Merged
merged 16 commits into from
Jan 7, 2015
Merged

Command channel output #499

merged 16 commits into from
Jan 7, 2015

Conversation

mappum
Copy link
Contributor

@mappum mappum commented Jan 6, 2015

This PR lets commands return channels, which allows for streaming object output. Now the add command will show hashes of files as they are added. 😄

It's pretty satisfying to watch it add the whole go-ipfs directory.

Thanks to the sharness tests for catching various edge-case bugs I wouldn't have noticed. 👍

@btc btc added the status/in-progress In progress label Jan 6, 2015
@mappum
Copy link
Contributor Author

mappum commented Jan 6, 2015

Jenkins is yelling at me because one of the intermediate commits doesn't build, should I change the history to fix that?

@jbenet
Copy link
Member

jbenet commented Jan 6, 2015

Jenkins is yelling at me because one of the intermediate commits doesn't build, should I change the history to fix that?

@mappum yeah ideally. though feel free to squash commits together if its not super easy.

cr.reader = r
}

n, err := cr.reader.Read(p)
Copy link
Member

Choose a reason for hiding this comment

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

io.ReadFull just in case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Are you sure? It looks like that would error if len(p) is greater than the length of one of the readers.

Copy link
Member

Choose a reason for hiding this comment

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

It'll stop on io.EOF and return io.ErrUnexpectedEOF (which we can ignore). The thing i'm worried about is that Read call not reading all it's supposed to. there's no guarantee the network won't just give it a few bytes and return.

Looking closer at this function, looks like if there are any bytes read, we keep the reader, so we just read again. if so then that may be fine (i thought we lost the reader right away)

@whyrusleeping
Copy link
Member

Yay! I'll be able to write ping now!

writer.WriteString("HTTP/1.1 200 OK\r\n")
writer.WriteString(contentTypeHeader + ": application/json\r\n")
writer.WriteString(transferEncodingHeader + ": chunked\r\n")
writer.WriteString(channelHeader + ": 1\r\n\r\n")
Copy link
Member

Choose a reason for hiding this comment

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

nice :) love how simple http is
didn't know about \r\n. guess that makes sense for the time.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was probably chosen just so Tim Berners-Lee could test out his server via telnet :P

Copy link
Member

Choose a reason for hiding this comment

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

yeah. he didn't have protobufs. :]

@jbenet
Copy link
Member

jbenet commented Jan 6, 2015

@mappum solid PR! LGTM after making commits pass, and comments (that one io.ReadFull)

@jbenet
Copy link
Member

jbenet commented Jan 7, 2015

Sweet, i'm going to merge this! Thanks! 👍

jbenet added a commit that referenced this pull request Jan 7, 2015
@jbenet jbenet merged commit 9bd2f42 into master Jan 7, 2015
@jbenet jbenet removed the status/in-progress In progress label Jan 7, 2015
@jbenet jbenet deleted the command-channels branch January 7, 2015 00:19
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.

4 participants