Skip to content

Commit e4e3cf3

Browse files
cicoyleartursouza
authored andcommitted
add counters to garbage collector upon job deletion (#36)
Signed-off-by: Cassandra Coyle <[email protected]>
1 parent 7507380 commit e4e3cf3

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

api.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ func (c *cron) Delete(ctx context.Context, name string) error {
103103
if _, err := c.client.Delete(ctx, jobKey); err != nil {
104104
return err
105105
}
106+
counterKey := c.key.CounterKey(name)
107+
c.collector.Push(counterKey)
106108

107109
if _, ok := c.queueCache.Load(jobKey); !ok {
108110
return nil

internal/informer/informer.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ func (i *Informer) handleEvent(ev *clientv3.Event) (*Event, error) {
160160
if i.yard.HasJustDeleted(string(ev.PrevKv.Key)) {
161161
return nil, nil
162162
}
163+
i.collector.Push(i.key.CounterKey(i.key.JobName(ev.Kv.Key)))
163164

164165
kv = ev.PrevKv
165166
default:

0 commit comments

Comments
 (0)