notifier/internal/workers/notifyer.go

40 lines
634 B
Go

package workers
import (
"context"
"mailnotifier/internal/clients"
"mailnotifier/internal/repository"
"time"
)
type Notifyer struct {
repo *repository.Repository
mailClient *clients.MailClient
}
type NotifyerDeps struct {
Repo *repository.Repository
MailClient *clients.MailClient
}
func NewNotifyer(deps NotifyerDeps) *Notifyer {
return &Notifyer{
repo: deps.Repo,
mailClient: deps.MailClient,
}
}
func (n *Notifyer) Start(ctx context.Context) {
tiker := time.NewTicker(time.Hour)
defer tiker.Stop()
for {
select {
case <-tiker.C:
// todo method
case <-ctx.Done():
return
}
}
}