Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
CMGS committed Mar 21, 2017
1 parent 419c809 commit 25e0cee
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
6 changes: 2 additions & 4 deletions cluster/calcium/run_and_wait.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@ import (
log "github.com/Sirupsen/logrus"
enginetypes "github.com/docker/docker/api/types"
"gitlab.ricebook.net/platform/core/types"
"gitlab.ricebook.net/platform/core/utils"
"golang.org/x/net/context"
)

// FUCK DOCKER
const PREFIXLEN int = 8

func (c *calcium) RunAndWait(specs types.Specs, opts *types.DeployOptions) (chan *types.RunAndWaitMessage, error) {
ch := make(chan *types.RunAndWaitMessage)

Expand Down Expand Up @@ -60,7 +58,7 @@ func (c *calcium) RunAndWait(specs types.Specs, opts *types.DeployOptions) (chan
scanner := bufio.NewScanner(resp)
for scanner.Scan() {
data := scanner.Bytes()
log.Debugf("[RunAndWait] %s %s", message.ContainerID[:12], data[PREFIXLEN:])
log.Debugf("[RunAndWait] %s %s", message.ContainerID[:12], data[utils.StreamPrefix:])
m := &types.RunAndWaitMessage{ContainerID: message.ContainerID, Data: data}
ch <- m
}
Expand Down
4 changes: 2 additions & 2 deletions rpc/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"gitlab.ricebook.net/platform/core/cluster"
"gitlab.ricebook.net/platform/core/rpc/gen"
"gitlab.ricebook.net/platform/core/types"
"gitlab.ricebook.net/platform/core/utils"
"golang.org/x/net/context"
)

Expand Down Expand Up @@ -235,8 +236,7 @@ func (v *virbranium) RunAndWait(opts *pb.DeployOptions, stream pb.CoreRPC_RunAnd
if err := stream.Send(toRPCRunAndWaitMessage(m)); err != nil {
go func() {
for r := range ch {
// TODO fuck docker
log.Infof("[RunAndWait] Unsent streamed message: %v", string(r.Data[8:]))
log.Infof("[RunAndWait] Unsent streamed message: %s", r.Data[utils.StreamPrefix:])
}
}()
return err
Expand Down
1 change: 1 addition & 0 deletions utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const (
letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
shortenLength = 7
CpuPeriodBase = 100000
StreamPrefix = 8
)

func RandomString(n int) string {
Expand Down

0 comments on commit 25e0cee

Please sign in to comment.