1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Moved Go() to the main package... And got rid of the useless docker/future package

This commit is contained in:
Solomon Hykes 2013-03-21 01:13:55 -07:00
parent deb603aaf4
commit 623e91e2e3
4 changed files with 15 additions and 18 deletions

View file

@ -6,7 +6,6 @@ import (
"errors"
"fmt"
"github.com/dotcloud/docker/auth"
"github.com/dotcloud/docker/future"
"github.com/dotcloud/docker/rcli"
"io"
"math/rand"
@ -749,7 +748,7 @@ func (srv *Server) CmdRun(stdin io.ReadCloser, stdout io.Writer, args ...string)
return err
}
if *fl_attach {
future.Go(func() error {
Go(func() error {
_, err := io.Copy(cmd_stdin, stdin)
cmd_stdin.Close()
return err
@ -769,11 +768,11 @@ func (srv *Server) CmdRun(stdin io.ReadCloser, stdout io.Writer, args ...string)
if err := container.Start(); err != nil {
return err
}
sending_stdout := future.Go(func() error {
sending_stdout := Go(func() error {
_, err := io.Copy(stdout, cmd_stdout)
return err
})
sending_stderr := future.Go(func() error {
sending_stderr := Go(func() error {
_, err := io.Copy(stdout, cmd_stderr)
return err
})

View file

@ -3,7 +3,6 @@ package main
import (
"flag"
"github.com/dotcloud/docker"
"github.com/dotcloud/docker/future"
"github.com/dotcloud/docker/rcli"
"github.com/dotcloud/docker/term"
"io"
@ -57,11 +56,11 @@ func runCommand(args []string) error {
// closing the connection.
// See http://code.google.com/p/go/issues/detail?id=3345
if conn, err := rcli.Call("tcp", "127.0.0.1:4242", args...); err == nil {
receive_stdout := future.Go(func() error {
receive_stdout := docker.Go(func() error {
_, err := io.Copy(os.Stdout, conn)
return err
})
send_stdin := future.Go(func() error {
send_stdin := docker.Go(func() error {
_, err := io.Copy(conn, os.Stdin)
if err := conn.CloseWrite(); err != nil {
log.Printf("Couldn't send EOF: " + err.Error())

View file

@ -1,11 +0,0 @@
package future
import ()
func Go(f func() error) chan error {
ch := make(chan error)
go func() {
ch <- f()
}()
return ch
}

View file

@ -14,6 +14,16 @@ import (
"time"
)
// Go is a basic promise implementation: it wraps calls a function in a goroutine,
// and returns a channel which will later return the function's return value.
func Go(f func() error) chan error {
ch := make(chan error)
go func() {
ch <- f()
}()
return ch
}
// Request a given URL and return an io.Reader
func Download(url string, stderr io.Writer) (*http.Response, error) {
var resp *http.Response