diff --git a/README.md b/README.md index d66ea54..a5756df 100644 --- a/README.md +++ b/README.md @@ -89,20 +89,3 @@ $ head -c 100000000 /dev/urandom > /tmp/random; cat /tmp/random | pv | time sh 95.4MiB 0:00:00 [1.73GiB/s] [ <=> ] sh -c "cat > /dev/null" 0.00s user 0.02s system 32% cpu 0.057 total ``` - -### Performance Goals - -Test command - -```shell script -head -c 100000000 /dev/urandom > /tmp/random; cat /tmp/random | pv | time coder sh ammar sh -c "cat > /dev/null" -``` - -streams at - -```shell script -95.4MiB 0:00:08 [10.7MiB/s] [ <=> ] - 15.34 real 2.16 user 1.54 sys -``` - -The same command over wush stdout (which is high performance) streams at 17MB/s. diff --git a/client.go b/client.go index 6a2f235..870fe8d 100644 --- a/client.go +++ b/client.go @@ -205,7 +205,7 @@ func (r remoteProcess) listen(ctx context.Context) { select { case exitCode := <-exitCode: if exitCode != 0 { - r.done <- ExitError{Code: int(exitCode)} + r.done <- ExitError{Code: exitCode} return } r.done <- nil diff --git a/exec.go b/exec.go index 432e7fa..e515289 100644 --- a/exec.go +++ b/exec.go @@ -19,10 +19,10 @@ func (e ExitError) Error() string { // Process represents a started command. type Process interface { - // Pid is populated immediately during a successfull start with the process ID. + // Pid is populated immediately during a successful start with the process ID. Pid() int // Stdout returns an io.WriteCloser that will pipe writes to the remote command. - // Closure of stdin sends the correspoding close messsage. + // Closure of stdin sends the corresponding close message. Stdin() io.WriteCloser // Stdout returns an io.Reader that is connected to the command's standard output. Stdout() io.Reader diff --git a/internal/proto/README.md b/internal/proto/README.md index ba85205..42cc39b 100644 --- a/internal/proto/README.md +++ b/internal/proto/README.md @@ -1,6 +1,6 @@ # Protocol -Each Message is represented as a single WebSocket message. A newline character separates a JSON header from the binary body. +Each message is represented as a single WebSocket message. A newline character separates a JSON header from the binary body. Some messages may omit the body. diff --git a/internal/proto/protocol_test.go b/internal/proto/protocol_test.go index ab20491..b156928 100644 --- a/internal/proto/protocol_test.go +++ b/internal/proto/protocol_test.go @@ -31,7 +31,8 @@ func TestWithHeader(t *testing.T) { for _, tcase := range tests { b := bytes.NewBuffer(nil) withheader := WithHeader(b, []byte(tcase.inputheader)) - withheader.Write([]byte(tcase.inputbody)) + _, err := withheader.Write([]byte(tcase.inputbody)) + assert.Success(t, "write to buffer with header", err) msg, err := ioutil.ReadAll(b) assert.Success(t, "read buffer", err) diff --git a/server.go b/server.go index a1dc5cd..05a9518 100644 --- a/server.go +++ b/server.go @@ -122,7 +122,7 @@ func Serve(ctx context.Context, c *websocket.Conn, execer Execer) error { } } -func sendExitCode(ctx context.Context, exitCode int, conn net.Conn) error { +func sendExitCode(_ context.Context, exitCode int, conn net.Conn) error { header, err := json.Marshal(proto.ServerExitCodeHeader{ Type: proto.TypeExitCode, ExitCode: exitCode, @@ -134,7 +134,7 @@ func sendExitCode(ctx context.Context, exitCode int, conn net.Conn) error { return err } -func sendPID(ctx context.Context, pid int, conn net.Conn) error { +func sendPID(_ context.Context, pid int, conn net.Conn) error { header, err := json.Marshal(proto.ServerPidHeader{Type: proto.TypePid, Pid: pid}) if err != nil { return err