auto cleanup reqs
This commit is contained in:
parent
c565dd5ece
commit
84937cc3a1
1 changed files with 9 additions and 0 deletions
|
|
@ -4,6 +4,7 @@ package types
|
|||
|
||||
import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"git.giftfish.de/ston1th/keyctl/pkg/key"
|
||||
"golang.org/x/exp/maps"
|
||||
|
|
@ -77,6 +78,7 @@ func (a *Approver) Update(aid string, s Status) (err error) {
|
|||
if app, ok := a.m[aid]; ok {
|
||||
app.Status = s
|
||||
a.m[aid] = app
|
||||
go a.cleanup(aid)
|
||||
} else {
|
||||
err = ErrReqNotFound
|
||||
}
|
||||
|
|
@ -84,6 +86,13 @@ func (a *Approver) Update(aid string, s Status) (err error) {
|
|||
return
|
||||
}
|
||||
|
||||
func (a *Approver) cleanup(aid string) {
|
||||
time.Sleep(time.Second * 10)
|
||||
a.mu.Lock()
|
||||
delete(a.m, aid)
|
||||
a.mu.Unlock()
|
||||
}
|
||||
|
||||
type Approval struct {
|
||||
ID string
|
||||
Name string
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue