MCPcopy Create free account
hub / github.com/MG-RAST/Shock / RemoveOld

Method RemoveOld

shock-server/node/locker/locker.go:288–304  ·  view source on GitHub ↗
(hours int)

Source from the content-addressed store, hash-verified

286}
287
288func (i *IndexLocker) RemoveOld(hours int) {
289 i.Lock()
290 defer i.Unlock()
291 currTime := time.Now()
292 expireTime := currTime.Add(time.Duration(hours*-1) * time.Hour)
293 for id, names := range i.nodes {
294 for n, info := range names {
295 if info.CreatedOn.Before(expireTime) {
296 logger.Error(fmt.Sprintf("Removing stale index lock: node=%s, index=%s", id, n))
297 delete(names, n)
298 }
299 }
300 if len(names) == 0 {
301 delete(i.nodes, id)
302 }
303 }
304}
305
306// hacky function for debugging
307func getGID() uint64 {

Callers

nothing calls this directly

Calls 2

AddMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected