리팩토링
This commit is contained in:
@ -30,15 +30,41 @@ type HoustonClient interface {
|
||||
Shutdown()
|
||||
}
|
||||
|
||||
type bufferStack struct {
|
||||
pool [5][]byte
|
||||
cursor int32
|
||||
}
|
||||
|
||||
func (bs *bufferStack) pop() []byte {
|
||||
pos := atomic.LoadInt32(&bs.cursor)
|
||||
for !atomic.CompareAndSwapInt32(&bs.cursor, pos, pos+1) {
|
||||
pos = atomic.LoadInt32(&bs.cursor)
|
||||
}
|
||||
|
||||
defer func() {
|
||||
bs.pool[pos] = nil
|
||||
}()
|
||||
|
||||
curbuf := bs.pool[pos]
|
||||
if curbuf == nil {
|
||||
curbuf = make([]byte, 1024)
|
||||
}
|
||||
return curbuf
|
||||
}
|
||||
|
||||
func (bs *bufferStack) push(x []byte) {
|
||||
pos := atomic.AddInt32(&bs.cursor, -1)
|
||||
bs.pool[pos] = x
|
||||
}
|
||||
|
||||
type procmeta struct {
|
||||
cmd *exec.Cmd
|
||||
name string
|
||||
version string
|
||||
state protos.ProcessState
|
||||
stdin io.WriteCloser
|
||||
stdPrefix string
|
||||
stdoutSize int32
|
||||
stderrSize int32
|
||||
cmd *exec.Cmd
|
||||
name string
|
||||
version string
|
||||
state protos.ProcessState
|
||||
stdin io.WriteCloser
|
||||
logUploadChan chan *shared.UploadRequest
|
||||
buffers bufferStack
|
||||
}
|
||||
|
||||
type houstonClient struct {
|
||||
@ -86,9 +112,9 @@ func gatherDeployedPrograms(name string) []*protos.VersionAndArgs {
|
||||
}
|
||||
}
|
||||
sort.Slice(rawvers, func(i, j int) bool {
|
||||
leftParsed := parseVersionString(rawvers[i].Version)
|
||||
rightParsed := parseVersionString(rawvers[j].Version)
|
||||
return compareVersionString(leftParsed, rightParsed) < 0
|
||||
leftParsed := shared.ParseVersionString(rawvers[i].Version)
|
||||
rightParsed := shared.ParseVersionString(rawvers[j].Version)
|
||||
return shared.CompareVersionString(leftParsed, rightParsed) < 0
|
||||
})
|
||||
return rawvers
|
||||
}
|
||||
@ -98,13 +124,11 @@ func (hc *houstonClient) makeOperationQueryRequest() *protos.OperationQueryReque
|
||||
procs := make([]*protos.ProcessDescription, 0, len(hc.childProcs))
|
||||
for _, child := range hc.childProcs {
|
||||
procs = append(procs, &protos.ProcessDescription{
|
||||
Name: child.name,
|
||||
Args: child.cmd.Args,
|
||||
Version: child.version,
|
||||
State: child.state,
|
||||
Pid: int32(child.cmd.Process.Pid),
|
||||
StdoutSize: atomic.LoadInt32(&child.stdoutSize),
|
||||
StderrSize: atomic.LoadInt32(&child.stderrSize),
|
||||
Name: child.name,
|
||||
Args: child.cmd.Args,
|
||||
Version: child.version,
|
||||
State: child.state,
|
||||
Pid: int32(child.cmd.Process.Pid),
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user