Skip to content

Commit

Permalink
chore: Simplify license routines (#64068)
Browse files Browse the repository at this point in the history
There's no need to track they haven't been called twice, this is a
programming error and should not happen. We don't need to maintain a
global int for that, IMO which just makes it harder to call in tests
etc.

Test plan: Local stack still works, code review.
  • Loading branch information
eseliger committed Jul 31, 2024
1 parent c44ffb0 commit 515acb8
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"fmt"
"net/url"
"sync/atomic"
"time"

"github.com/derision-test/glock"
Expand All @@ -23,16 +22,10 @@ import (

const licenseAnomalyCheckKey = "license_anomaly_check"

var licenseAnomalyCheckers uint32

// StartCheckForAnomalousLicenseUsage checks for anomalous license usage.
//
// TODO(@bobheadxi): Migrate to Enterprise Portal https://linear.app/sourcegraph/issue/CORE-182
func StartCheckForAnomalousLicenseUsage(logger log.Logger, db database.DB) {
if atomic.AddUint32(&licenseAnomalyCheckers, 1) != 1 {
panic("StartCheckForAnomalousLicenseUsage called more than once")
}

dotcom := conf.Get().Dotcom
if dotcom == nil {
return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package productsubscription
import (
"context"
"fmt"
"sync/atomic"
"time"

"github.com/derision-test/glock"
Expand All @@ -19,17 +18,11 @@ import (

const lastLicenseExpirationCheckKey = "last_license_expiration_check"

var licenseExpirationCheckers uint32

// StartCheckForUpcomingLicenseExpirations checks for upcoming license expirations once per day.
//
// TODO(@bobheadxi): Migrate to Enterprise Portal
// https://linear.app/sourcegraph/issue/CORE-183
func StartCheckForUpcomingLicenseExpirations(logger log.Logger, db database.DB) {
if atomic.AddUint32(&licenseExpirationCheckers, 1) != 1 {
panic("StartCheckForUpcomingLicenseExpirations called more than once")
}

dotcom := conf.Get().Dotcom
if dotcom == nil {
return
Expand Down

0 comments on commit 515acb8

Please sign in to comment.