HW14 Completed
This commit is contained in:
parent
63c008f963
commit
04241cb809
@ -36,7 +36,7 @@ func New(conf Config) Scheduler {
|
||||
}
|
||||
|
||||
func (s *Scheduler) Start(ctx context.Context) error {
|
||||
fetcher := riseOnTick(ctx, s.Logger, func() interface{} { return worker(ctx, s.CalendarAPI, s.Rabbit) }, 1*time.Minute)
|
||||
fetcher := riseOnTick(ctx, s.Logger, func() interface{} { return worker(ctx, s.CalendarAPI, s.Rabbit, s.Logger) }, 1*time.Minute)
|
||||
go func() {
|
||||
for {
|
||||
select {
|
||||
|
@ -37,7 +37,7 @@ func riseOnTick(ctx context.Context, log logger.Interface, fn func() interface{}
|
||||
return valueStream
|
||||
}
|
||||
|
||||
func worker(ctx context.Context, calendarAPI config.Server, rb *rabbit.Rabbit) error {
|
||||
func worker(ctx context.Context, calendarAPI config.Server, rb *rabbit.Rabbit, log logger.Interface) error {
|
||||
cli, err := private.NewClient(calendarAPI.Address, calendarAPI.Port)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -56,5 +56,10 @@ func worker(ctx context.Context, calendarAPI config.Server, rb *rabbit.Rabbit) e
|
||||
return err
|
||||
}
|
||||
}
|
||||
resp2, err := cli.PurgeOldEvents(ctx, &private.PurgeReq{OlderThenDays: 365})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
log.Infof("Scheduler successfully purges %s events from storage", resp2.Qty)
|
||||
return nil
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user