Rename Obj() to AsClient()

Signed-off-by: Aanand Prasad <aanand.prasad@gmail.com>
This commit is contained in:
Aanand Prasad 2014-06-23 14:46:21 +01:00
parent fcbf0b1905
commit 3ccf699c3a
10 changed files with 23 additions and 23 deletions

View File

@ -25,5 +25,5 @@ func New() *libswarm.Client {
backends.Bind("shipyard", Shipyard())
backends.Bind("ec2", Ec2())
backends.Bind("tutum", Tutum())
return libswarm.Obj(backends)
return libswarm.AsClient(backends)
}

View File

@ -247,7 +247,7 @@ func instance(t *testing.T, server *stubServer) *libswarm.Client {
}
backend := DockerClient()
instance, err := libswarm.Obj(backend).Spawn(url)
instance, err := libswarm.AsClient(backend).Spawn(url)
if err != nil {
t.Fatal(err)
}

View File

@ -109,13 +109,13 @@ type containerJson struct {
}
func getContainerJson(out libswarm.Sender, containerID string) (containerJson, error) {
o := libswarm.Obj(out)
o := libswarm.AsClient(out)
_, containerOut, err := o.Attach(containerID)
if err != nil {
return containerJson{}, err
}
container := libswarm.Obj(containerOut)
container := libswarm.AsClient(containerOut)
responseJson, err := container.Get()
if err != nil {
return containerJson{}, err
@ -142,7 +142,7 @@ func getContainersJSON(out libswarm.Sender, version version.Version, w http.Resp
return err
}
o := libswarm.Obj(out)
o := libswarm.AsClient(out)
names, err := o.Ls()
if err != nil {
return err
@ -225,7 +225,7 @@ func postContainersCreate(out libswarm.Sender, version version.Version, w http.R
return err
}
container, err := libswarm.Obj(out).Spawn(string(body))
container, err := libswarm.AsClient(out).Spawn(string(body))
if err != nil {
return err
}
@ -250,8 +250,8 @@ func postContainersStart(out libswarm.Sender, version version.Version, w http.Re
// TODO: r.Body
name := vars["name"]
_, containerOut, err := libswarm.Obj(out).Attach(name)
container := libswarm.Obj(containerOut)
_, containerOut, err := libswarm.AsClient(out).Attach(name)
container := libswarm.AsClient(containerOut)
if err != nil {
return err
}
@ -269,8 +269,8 @@ func postContainersStop(out libswarm.Sender, version version.Version, w http.Res
}
name := vars["name"]
_, containerOut, err := libswarm.Obj(out).Attach(name)
container := libswarm.Obj(containerOut)
_, containerOut, err := libswarm.AsClient(out).Attach(name)
container := libswarm.AsClient(containerOut)
if err != nil {
return err
}
@ -325,11 +325,11 @@ func postContainersAttach(out libswarm.Sender, version version.Version, w http.R
errStream := dockerutils.NewStdWriter(outStream, dockerutils.Stderr)
outStream = dockerutils.NewStdWriter(outStream, dockerutils.Stdout)
_, containerOut, err := libswarm.Obj(out).Attach(vars["name"])
_, containerOut, err := libswarm.AsClient(out).Attach(vars["name"])
if err != nil {
return err
}
container := libswarm.Obj(containerOut)
container := libswarm.AsClient(containerOut)
containerR, _, err := container.Attach("")
var tasks sync.WaitGroup

View File

@ -281,7 +281,7 @@ func (c *ec2Client) initDockerClientInstance(instance *ec2.Instance) error {
URLHost: "localhost",
})
dockerBackend := libswarm.Obj(dockerClient)
dockerBackend := libswarm.AsClient(dockerClient)
url := fmt.Sprintf("tcp://localhost:%s", c.config.sshLocalPort)
dockerInstance, err := dockerBackend.Spawn(url)
c.dockerInstance = dockerInstance

View File

@ -46,7 +46,7 @@ func Exec() libswarm.Sender {
if _, err := msg.Ret.Send(&libswarm.Message{Verb: libswarm.Ack, Ret: inW}); err != nil {
return err
}
out := libswarm.Obj(msg.Ret)
out := libswarm.AsClient(msg.Ret)
go func() {
defer stdin.Close()
for {
@ -84,7 +84,7 @@ func Exec() libswarm.Sender {
go func() {
defer cmd.tasks.Done()
if err := cmd.Cmd.Wait(); err != nil {
libswarm.Obj(msg.Ret).Log("%s exited status=%v", cmd.Cmd.Path, err)
libswarm.AsClient(msg.Ret).Log("%s exited status=%v", cmd.Cmd.Path, err)
}
}()
msg.Ret.Send(&libswarm.Message{Verb: libswarm.Ack})

View File

@ -15,7 +15,7 @@ func FakeClient() libswarm.Sender {
instance := utils.Task(func(in libswarm.Receiver, out libswarm.Sender) {
fmt.Printf("fake client!\n")
defer fmt.Printf("end of fake client!\n")
o := libswarm.Obj(out)
o := libswarm.AsClient(out)
o.Log("fake client starting")
defer o.Log("fake client terminating")
for {

View File

@ -40,7 +40,7 @@ func Orchard() libswarm.Sender {
URLHost: host.IPAddress,
TLSClientConfig: tlsConfig,
})
forwardBackend := libswarm.Obj(backend)
forwardBackend := libswarm.AsClient(backend)
forwardInstance, err := forwardBackend.Spawn(url)
if err != nil {
return nil, err

View File

@ -10,11 +10,11 @@ func Simulator() libswarm.Sender {
s.OnVerb(libswarm.Spawn, libswarm.Handler(func(ctx *libswarm.Message) error {
containers := ctx.Args
instance := utils.Task(func(in libswarm.Receiver, out libswarm.Sender) {
libswarm.Obj(out).Log("[simulator] starting\n")
libswarm.AsClient(out).Log("[simulator] starting\n")
s := libswarm.NewServer()
s.OnVerb(libswarm.Ls, libswarm.Handler(func(msg *libswarm.Message) error {
libswarm.Obj(out).Log("[simulator] generating fake list of objects...\n")
libswarm.Obj(msg.Ret).Set(containers...)
libswarm.AsClient(out).Log("[simulator] generating fake list of objects...\n")
libswarm.AsClient(msg.Ret).Set(containers...)
return nil
}))
libswarm.Copy(s, in)

View File

@ -12,7 +12,7 @@ type Client struct {
Sender
}
func Obj(dst Sender) *Client {
func AsClient(dst Sender) *Client {
return &Client{dst}
}

View File

@ -25,7 +25,7 @@ func NewTree() *Tree {
msg.Ret.Send(&libswarm.Message{Verb: libswarm.Ack, Ret: child})
return nil
}
libswarm.Obj(msg.Ret).Error("not found")
libswarm.AsClient(msg.Ret).Error("not found")
return nil
}))
t.OnVerb(libswarm.Ls, libswarm.Handler(func(msg *libswarm.Message) error {
@ -34,7 +34,7 @@ func NewTree() *Tree {
names = append(names, name)
}
sort.Strings(names)
libswarm.Obj(msg.Ret).Set(names...)
libswarm.AsClient(msg.Ret).Set(names...)
return nil
}))
return t