Skip to content

Commit b89f484

Browse files
committed
Run generator
1 parent 96c4062 commit b89f484

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

cli/server.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ import (
5656
"cdr.dev/slog"
5757
"cdr.dev/slog/sloggers/sloghuman"
5858
"github.com/coder/coder/v2/coderd/entitlements"
59+
"github.com/coder/coder/v2/coderd/notifications/reports"
5960
"github.com/coder/pretty"
6061
"github.com/coder/quartz"
6162
"github.com/coder/retry"
@@ -1023,6 +1024,10 @@ func (r *RootCmd) Server(newAPI func(context.Context, *coderd.Options) (*coderd.
10231024

10241025
// nolint:gocritic // TODO: create own role.
10251026
notificationsManager.Run(dbauthz.AsSystemRestricted(ctx))
1027+
1028+
// Run report generator to distribute periodic reports.
1029+
reportGenerator := reports.NewReportGenerator(ctx, logger, options.Database, options.NotificationsEnqueuer, quartz.NewReal())
1030+
defer reportGenerator.Close()
10261031
}
10271032

10281033
// Wrap the server in middleware that redirects to the access URL if

coderd/notifications/reports/generator.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,15 @@ import (
1010
"github.com/coder/coder/v2/coderd/database"
1111
"github.com/coder/coder/v2/coderd/database/dbauthz"
1212
"github.com/coder/coder/v2/coderd/database/dbtime"
13+
"github.com/coder/coder/v2/coderd/notifications"
1314
"github.com/coder/quartz"
1415
)
1516

1617
const (
1718
delay = 5 * time.Minute
1819
)
1920

20-
func NewReportGenerator(ctx context.Context, logger slog.Logger, db database.Store, clk quartz.Clock) io.Closer {
21+
func NewReportGenerator(ctx context.Context, logger slog.Logger, db database.Store, notificationsEnqueuer notifications.Enqueuer, clk quartz.Clock) io.Closer {
2122
closed := make(chan struct{})
2223

2324
ctx, cancelFunc := context.WithCancel(ctx)

0 commit comments

Comments
 (0)