pool: Reddo component-like fields

This commit is contained in:
Tom Wiesing 2022-12-22 13:49:05 +01:00
parent 99983ee6db
commit 337a5fbeba
No known key found for this signature in database
48 changed files with 291 additions and 163 deletions

View file

@ -16,8 +16,9 @@ import (
type Cron struct {
component.Base
Tasks []component.Cronable
Dependencies struct {
Tasks []component.Cronable
}
}
// Listen returns a channel that listens for triggers in the current process.
@ -51,11 +52,11 @@ func (control *Cron) Listen(ctx context.Context) (<-chan struct{}, func()) {
// Once should not be called concurrently with Cron.
func (control *Cron) Once(ctx context.Context) {
var wg sync.WaitGroup
wg.Add(len(control.Tasks))
wg.Add(len(control.Dependencies.Tasks))
zerolog.Ctx(ctx).Info().Time("time", time.Now()).Msg("Starting Cron")
for _, task := range control.Tasks {
for _, task := range control.Dependencies.Tasks {
go func(task component.Cronable) {
defer wg.Done()