deployprogress
This commit is contained in:
@ -59,6 +59,20 @@ type hostPool struct {
|
||||
hosts map[string]*hostWithChan
|
||||
}
|
||||
|
||||
type deployingBoard struct {
|
||||
sync.Mutex
|
||||
progs []*protos.DeployingProgress
|
||||
}
|
||||
|
||||
func (db *deployingBoard) clone() (out []*protos.DeployingProgress) {
|
||||
db.Lock()
|
||||
defer db.Unlock()
|
||||
|
||||
out = make([]*protos.DeployingProgress, len(db.progs))
|
||||
copy(out, db.progs)
|
||||
return
|
||||
}
|
||||
|
||||
func (sp *hostPool) regist(desc *protos.OperationQueryRequest) (string, chan *opdef) {
|
||||
sp.Lock()
|
||||
defer sp.Unlock()
|
||||
@ -135,6 +149,7 @@ func (sp *hostPool) query(filter func(*hostWithChan) bool) []*hostWithChan {
|
||||
type operationServer struct {
|
||||
protos.UnimplementedOperationServer
|
||||
hp hostPool
|
||||
db deployingBoard
|
||||
}
|
||||
|
||||
func marshal(argval reflect.Value, output map[string]string) map[string]string {
|
||||
@ -190,6 +205,25 @@ Outer:
|
||||
return nil
|
||||
}
|
||||
|
||||
func (os *operationServer) ReportDeployingProgress(ctx context.Context, dp *protos.DeployingProgress) (*protos.Empty, error) {
|
||||
os.db.Lock()
|
||||
defer os.db.Unlock()
|
||||
|
||||
for i, p := range os.db.progs {
|
||||
if p.Hostname == dp.Hostname && p.Name == dp.Name && p.Version == dp.Version {
|
||||
if dp.State == "done" {
|
||||
os.db.progs = append(os.db.progs[:i], os.db.progs[i+1:]...)
|
||||
} else {
|
||||
os.db.progs[i] = dp
|
||||
}
|
||||
return &protos.Empty{}, nil
|
||||
}
|
||||
}
|
||||
|
||||
os.db.progs = append(os.db.progs, dp)
|
||||
return &protos.Empty{}, nil
|
||||
}
|
||||
|
||||
func (os *operationServer) Refresh(ctx context.Context, desc *protos.OperationQueryRequest) (*protos.Empty, error) {
|
||||
os.hp.refresh(desc)
|
||||
return &protos.Empty{}, nil
|
||||
|
||||
Reference in New Issue
Block a user