-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
live loading from stdin #3266
live loading from stdin #3266
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.
Reviewed 3 of 3 files at r1.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @gitlw)
chunker/chunk.go, line 283 at r1 (raw file):
var err error if file == "-" { f = os.Stdin
Data can already be loaded from standard input by using /dev/stdin
as the filename, but is useful on systems that may not have that device (Windows).
dgraph/cmd/live/run.go, line 226 at r1 (raw file):
// to the loader.reqs channel func (l *loader) processChunk(chunkBuf *bytes.Buffer, ck chunker.Chunker) { if chunkBuf != nil && chunkBuf.Len() > 0 {
Is the entire function body wrapped by this if statement? I the code would be clearer written like:
if chunBuf == nil || chunkBuf.Len() == 0 {
return
}
<function body>
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: 2 of 3 files reviewed, 2 unresolved discussions (waiting on @codexnull)
chunker/chunk.go, line 283 at r1 (raw file):
Previously, codexnull (Javier Alvarado) wrote…
Data can already be loaded from standard input by using
/dev/stdin
as the filename, but is useful on systems that may not have that device (Windows).
Done.
dgraph/cmd/live/run.go, line 226 at r1 (raw file):
Previously, codexnull (Javier Alvarado) wrote…
Is the entire function body wrapped by this if statement? I the code would be clearer written like:
if chunBuf == nil || chunkBuf.Len() == 0 { return } <function body>
Done.
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.
Got a comment. See if it would be worth doing. Will leave it to @codexnull for the final approval.
Reviewed 2 of 3 files at r1, 1 of 1 files at r2.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @codexnull)
chunker/chunk.go, line 283 at r1 (raw file):
Previously, gitlw (Lucas Wang) wrote…
Done.
A file named dash can cause confusion for command line args. Why not just have a boolean arg in live loader to accept input from stdin?
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: all files reviewed, 2 unresolved discussions (waiting on @codexnull and @manishrjain)
chunker/chunk.go, line 283 at r1 (raw file):
Previously, manishrjain (Manish R Jain) wrote…
A file named dash can cause confusion for command line args. Why not just have a boolean arg in live loader to accept input from stdin?
A file named dash to represent stdin/stdout is a Unix/Linux convention. (For example, I used this earlier today: curl -SsL 'https://github.com/dgraph-io/dgraph/releases/download/v1.0.13/dgraph-linux-amd64.tar.gz' | tar zxf -
)
I don't think it's worth adding another flag for that, especially since you can already use /dev/stdin
as the file if you don't want to use a dash.
Adding the support of live loader reading from standard input
Refactored the code around chunk processing, mainly because the checking of
if err == io.EOF
is supposed to be checking the err returned by the ck.Chunk function, however in the current code, the err variable can be overwriten by the ck.Parse function.
This change is