Skip to content

Commit 11d4b6f

Browse files
authored
chore: move dormancy to enterprise package (#9468)
1 parent 7c4ce62 commit 11d4b6f

File tree

5 files changed

+10
-5
lines changed

5 files changed

+10
-5
lines changed

cli/server.go

-4
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ import (
7070
"github.com/coder/coder/v2/coderd/database/migrations"
7171
"github.com/coder/coder/v2/coderd/database/pubsub"
7272
"github.com/coder/coder/v2/coderd/devtunnel"
73-
"github.com/coder/coder/v2/coderd/dormancy"
7473
"github.com/coder/coder/v2/coderd/gitauth"
7574
"github.com/coder/coder/v2/coderd/gitsshkey"
7675
"github.com/coder/coder/v2/coderd/httpapi"
@@ -866,9 +865,6 @@ func (r *RootCmd) Server(newAPI func(context.Context, *coderd.Options) (*coderd.
866865
options.StatsBatcher = batcher
867866
defer closeBatcher()
868867

869-
closeCheckInactiveUsersFunc := dormancy.CheckInactiveUsers(ctx, logger, options.Database)
870-
defer closeCheckInactiveUsersFunc()
871-
872868
// We use a separate coderAPICloser so the Enterprise API
873869
// can have it's own close functions. This is cleaner
874870
// than abstracting the Coder API itself.

enterprise/cli/server.go

+3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"github.com/coder/coder/v2/enterprise/audit"
1919
"github.com/coder/coder/v2/enterprise/audit/backends"
2020
"github.com/coder/coder/v2/enterprise/coderd"
21+
"github.com/coder/coder/v2/enterprise/coderd/dormancy"
2122
"github.com/coder/coder/v2/enterprise/trialer"
2223
"github.com/coder/coder/v2/tailnet"
2324

@@ -67,6 +68,8 @@ func (r *RootCmd) server() *clibase.Cmd {
6768
ProxyHealthInterval: options.DeploymentValues.ProxyHealthStatusInterval.Value(),
6869
DefaultQuietHoursSchedule: options.DeploymentValues.UserQuietHoursSchedule.DefaultSchedule.Value(),
6970
ProvisionerDaemonPSK: options.DeploymentValues.Provisioner.DaemonPSK.Value(),
71+
72+
CheckInactiveUsersCancelFunc: dormancy.CheckInactiveUsers(ctx, options.Logger, options.Database),
7073
}
7174

7275
api, err := coderd.New(ctx, o)

enterprise/coderd/coderd.go

+6
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,8 @@ type Options struct {
378378

379379
// optional pre-shared key for authentication of external provisioner daemons
380380
ProvisionerDaemonPSK string
381+
382+
CheckInactiveUsersCancelFunc func()
381383
}
382384

383385
type API struct {
@@ -414,6 +416,10 @@ func (api *API) Close() error {
414416
if api.derpMesh != nil {
415417
_ = api.derpMesh.Close()
416418
}
419+
420+
if api.Options.CheckInactiveUsersCancelFunc != nil {
421+
api.Options.CheckInactiveUsersCancelFunc()
422+
}
417423
return api.AGPL.Close()
418424
}
419425

coderd/dormancy/dormantusersjob_test.go renamed to enterprise/coderd/dormancy/dormantusersjob_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313

1414
"github.com/coder/coder/v2/coderd/database"
1515
"github.com/coder/coder/v2/coderd/database/dbfake"
16-
"github.com/coder/coder/v2/coderd/dormancy"
16+
"github.com/coder/coder/v2/enterprise/coderd/dormancy"
1717
"github.com/coder/coder/v2/testutil"
1818
)
1919

0 commit comments

Comments
 (0)