aboutsummaryrefslogtreecommitdiff
path: root/pkg
diff options
context:
space:
mode:
authorGabriel Arakaki Giovanini <mail@gabrielgio.me>2023-06-24 00:09:26 +0200
committerGabriel Arakaki Giovanini <mail@gabrielgio.me>2023-06-24 00:09:26 +0200
commit3b06cb010948c241b3c940b7d85e4390f2d93dd0 (patch)
tree07b230a4d413ef85c61cc6ab44385ac0cf2da8fb /pkg
parent5bb3d3ecabfc658035e69d5d5286cabaf44e3f73 (diff)
downloadlens-3b06cb010948c241b3c940b7d85e4390f2d93dd0.tar.gz
lens-3b06cb010948c241b3c940b7d85e4390f2d93dd0.tar.bz2
lens-3b06cb010948c241b3c940b7d85e4390f2d93dd0.zip
ref: Rename list to batch processor
Diffstat (limited to 'pkg')
-rw-r--r--pkg/worker/exif_scanner.go2
-rw-r--r--pkg/worker/list_processor.go32
2 files changed, 17 insertions, 17 deletions
diff --git a/pkg/worker/exif_scanner.go b/pkg/worker/exif_scanner.go
index d7865e3..4aa247d 100644
--- a/pkg/worker/exif_scanner.go
+++ b/pkg/worker/exif_scanner.go
@@ -13,7 +13,7 @@ type (
}
)
-var _ ListProcessor[*media.Media] = &EXIFScanner{}
+var _ BatchProcessor[*media.Media] = &EXIFScanner{}
func NewEXIFScanner(repository media.Repository) *EXIFScanner {
return &EXIFScanner{
diff --git a/pkg/worker/list_processor.go b/pkg/worker/list_processor.go
index c9c20a9..bbc9fb7 100644
--- a/pkg/worker/list_processor.go
+++ b/pkg/worker/list_processor.go
@@ -16,7 +16,7 @@ type (
Process(context.Context, T) error
}
- ListProcessor[T any] interface {
+ BatchProcessor[T any] interface {
Query(context.Context) ([]T, error)
Process(context.Context, T) error
}
@@ -26,38 +26,38 @@ type (
scheduler *Scheduler
}
- listProcessorWorker[T any] struct {
- listProcessor ListProcessor[T]
- logrus *logrus.Entry
- scheduler *Scheduler
+ batchProcessorWorker[T any] struct {
+ batchProcessor BatchProcessor[T]
+ logrus *logrus.Entry
+ scheduler *Scheduler
}
)
-func NewWorkerFromListProcessor[T any](
- listProcessor ListProcessor[T],
+func NewWorkerFromBatchProcessor[T any](
+ batchProcessor BatchProcessor[T],
scheduler *Scheduler,
logrus *logrus.Entry,
) Worker {
- return &listProcessorWorker[T]{
- listProcessor: listProcessor,
- scheduler: scheduler,
- logrus: logrus,
+ return &batchProcessorWorker[T]{
+ batchProcessor: batchProcessor,
+ scheduler: scheduler,
+ logrus: logrus,
}
}
func NewWorkerFromChanProcessor[T any](
- listProcessor ChanProcessor[T],
+ chanProcessor ChanProcessor[T],
scheduler *Scheduler,
) Worker {
return &chanProcessorWorker[T]{
- chanProcessor: listProcessor,
+ chanProcessor: chanProcessor,
scheduler: scheduler,
}
}
-func (l *listProcessorWorker[T]) Start(ctx context.Context) error {
+func (l *batchProcessorWorker[T]) Start(ctx context.Context) error {
for {
- values, err := l.listProcessor.Query(ctx)
+ values, err := l.batchProcessor.Query(ctx)
if err != nil {
return err
}
@@ -79,7 +79,7 @@ func (l *listProcessorWorker[T]) Start(ctx context.Context) error {
go func(v T) {
defer l.scheduler.Return()
defer wg.Done()
- if err := l.listProcessor.Process(ctx, v); err != nil && !errors.Is(err, context.Canceled) {
+ if err := l.batchProcessor.Process(ctx, v); err != nil && !errors.Is(err, context.Canceled) {
l.logrus.WithError(err).Error("Error processing batch")
}
}(v)