Skip to content

Commit

Permalink
Naming improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfsblu committed Dec 22, 2024
1 parent 744e405 commit b634be5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions domain/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,11 @@ func (s *RecipeService) RegisterUser(ctx context.Context, credentials Credential
return nil
}

func (s *RecipeService) RemoveObsoletePasswordResets(ctx context.Context) error {
func (s *RecipeService) RemoveOldPasswordResets(ctx context.Context) error {
return nil
}

func (s *RecipeService) RemoveObsoleteRegistrations(ctx context.Context) error {
func (s *RecipeService) RemoveOldRegistrations(ctx context.Context) error {
return nil
}

Expand Down
4 changes: 2 additions & 2 deletions infra/jobs/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ func StartScheduler(service *domain.RecipeService) {
for {
select {
case <-getC(cleanupPasswordResets):
_ = service.RemoveObsoletePasswordResets(ctx)
_ = service.RemoveOldPasswordResets(ctx)
case <-getC(cleanupRegistrations):
_ = service.RemoveObsoleteRegistrations(ctx)
_ = service.RemoveOldRegistrations(ctx)
case <-quit:
cancel()
stopTickers()
Expand Down
14 changes: 7 additions & 7 deletions infra/jobs/tickers.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,20 @@ var (
cleanupRegistrations = tickerType("cleanupRegistrations")
)

func getC(t tickerType) <-chan time.Time {
if ticker, ok := tickerMap[t]; ok {
return ticker.C
}
return make(chan time.Time)
}

func initializeTickers() {
tickerMap = map[tickerType]*time.Ticker{
cleanupPasswordResets: time.NewTicker(24 * time.Hour),
cleanupRegistrations: time.NewTicker(24 * time.Hour),
}
}

func getC(t tickerType) <-chan time.Time {
if ticker, ok := tickerMap[t]; ok {
return ticker.C
}
return make(chan time.Time)
}

func stopTickers() {
for _, t := range tickerMap {
t.Stop()
Expand Down

0 comments on commit b634be5

Please sign in to comment.