github.com/jghiloni/cli@v6.28.1-0.20170628223758-0ce05fe032a2+incompatible/actor/v3action/process.go (about) 1 package v3action 2 3 import ( 4 "time" 5 6 "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" 7 ) 8 9 // Process represents a V3 actor process. 10 type Process struct { 11 Type string 12 Instances []Instance 13 MemoryInMB int 14 } 15 16 // Instance represents a V3 actor instance. 17 type Instance ccv3.Instance 18 19 // StartTime returns the time that the instance started. 20 func (instance *Instance) StartTime() time.Time { 21 uptimeDuration := time.Duration(instance.Uptime) * time.Second 22 23 return time.Now().Add(-uptimeDuration) 24 } 25 26 func (p Process) TotalInstanceCount() int { 27 return len(p.Instances) 28 } 29 30 func (p Process) HealthyInstanceCount() int { 31 count := 0 32 for _, instance := range p.Instances { 33 if instance.State == "RUNNING" { 34 count++ 35 } 36 } 37 return count 38 }