Implement review feedback
This commit is contained in:
@@ -122,11 +122,12 @@ func CleanProcessStorage(activePIDs map[int]struct{}) {
|
||||
}
|
||||
|
||||
// Process is inactive, start deletion process
|
||||
lastSeen := p.GetLastSeen()
|
||||
switch {
|
||||
case p.LastSeen == 0:
|
||||
// add last
|
||||
p.LastSeen = time.Now().Unix()
|
||||
case p.LastSeen > threshold:
|
||||
case lastSeen == 0:
|
||||
// add last seen timestamp
|
||||
p.SetLastSeen(time.Now().Unix())
|
||||
case lastSeen > threshold:
|
||||
// within keep period
|
||||
default:
|
||||
// delete now
|
||||
|
||||
@@ -59,9 +59,29 @@ type Process struct {
|
||||
|
||||
// Profile returns the assigned layered profile.
|
||||
func (p *Process) Profile() *profile.LayeredProfile {
|
||||
if p == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return p.profile
|
||||
}
|
||||
|
||||
// GetLastSeen returns the unix timestamp when the process was last seen.
|
||||
func (p *Process) GetLastSeen() int64 {
|
||||
p.Lock()
|
||||
defer p.Unlock()
|
||||
|
||||
return p.LastSeen
|
||||
}
|
||||
|
||||
// SetLastSeen sets the unix timestamp when the process was last seen.
|
||||
func (p *Process) SetLastSeen(lastSeen int64) {
|
||||
p.Lock()
|
||||
defer p.Unlock()
|
||||
|
||||
p.LastSeen = lastSeen
|
||||
}
|
||||
|
||||
// Strings returns a string representation of process.
|
||||
func (p *Process) String() string {
|
||||
if p == nil {
|
||||
|
||||
Reference in New Issue
Block a user