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 (
|
import (
|
||||||
"sync"
|
"sync"
|
||||||
|
"time"
|
||||||
|
|
||||||
"git.giftfish.de/ston1th/keyctl/pkg/key"
|
"git.giftfish.de/ston1th/keyctl/pkg/key"
|
||||||
"golang.org/x/exp/maps"
|
"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 {
|
if app, ok := a.m[aid]; ok {
|
||||||
app.Status = s
|
app.Status = s
|
||||||
a.m[aid] = app
|
a.m[aid] = app
|
||||||
|
go a.cleanup(aid)
|
||||||
} else {
|
} else {
|
||||||
err = ErrReqNotFound
|
err = ErrReqNotFound
|
||||||
}
|
}
|
||||||
|
|
@ -84,6 +86,13 @@ func (a *Approver) Update(aid string, s Status) (err error) {
|
||||||
return
|
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 {
|
type Approval struct {
|
||||||
ID string
|
ID string
|
||||||
Name string
|
Name string
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue