Skip to content

Commit

Permalink
refactor: refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
suzuki-shunsuke committed Jan 21, 2025
1 parent 0dadc30 commit 337188f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions pkg/controller/vacuum/queue_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ func (sq *StoreQueue) worker(ctx context.Context) {
}
}

// enqueue adds a task to the queue.
func (sq *StoreQueue) enqueue(logE *logrus.Entry, pkg *Package) {
// Enqueue adds a task to the queue.
func (sq *StoreQueue) Enqueue(logE *logrus.Entry, pkg *Package) {
select {
case <-sq.done:
return
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/vacuum/vacuum.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func (vc *Controller) handleAsyncStorePackage(logE *logrus.Entry, vacuumPkg *Pac
if vacuumPkg == nil {
return errors.New("vacuumPkg is nil")
}
vc.db.storeQueue.enqueue(logE, vacuumPkg)
vc.db.StoreAsync(logE, vacuumPkg)
return nil
}

Expand Down
4 changes: 4 additions & 0 deletions pkg/controller/vacuum/vacuum_db.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ func (d *DB) Store(ctx context.Context, logE *logrus.Entry, pkg *Package, lastUs
})
}

func (d *DB) StoreAsync(logE *logrus.Entry, pkg *Package) {
d.storeQueue.Enqueue(logE, pkg)
}

// List lists all stored package entries.
func (d *DB) List(ctx context.Context, logE *logrus.Entry) ([]*PackageVacuumEntry, error) {
db, err := d.getDB()
Expand Down

0 comments on commit 337188f

Please sign in to comment.