-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Smooth the operation storage clean-up along the time (#535)
* Smooth the operation storage clean-up along the time * Add a comment explaining the motivation of the hardcoded values
- Loading branch information
Showing
4 changed files
with
32 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,7 @@ import ( | |
"strings" | ||
"time" | ||
|
||
"github.com/m-lab/go/memoryless" | ||
"github.com/topfreegames/maestro/internal/core/logs" | ||
"github.com/topfreegames/maestro/internal/core/operations/healthcontroller" | ||
"github.com/topfreegames/maestro/internal/core/operations/storagecleanup" | ||
|
@@ -86,7 +87,18 @@ func (w *OperationExecutionWorker) Start(ctx context.Context) error { | |
healthControllerTicker := time.NewTicker(w.healthControllerExecutionInterval) | ||
defer healthControllerTicker.Stop() | ||
|
||
storagecleanupTicker := time.NewTicker(w.storagecleanupExecutionInterval) | ||
storagecleanupTicker, err := memoryless.NewTicker(context.Background(), memoryless.Config{ | ||
Expected: w.storagecleanupExecutionInterval, | ||
// This minimum value was took from the memoryless documentation https://pkg.go.dev/github.com/m-lab/[email protected]/memoryless#Ticker | ||
Min: time.Duration(0.1 * float64(w.storagecleanupExecutionInterval)), | ||
// This maximum value was took from the memoryless documentation https://pkg.go.dev/github.com/m-lab/[email protected]/memoryless#Ticker | ||
Max: time.Duration(2.5 * float64(w.storagecleanupExecutionInterval)), | ||
}) | ||
if err != nil { | ||
w.logger.Error("Error creating ticker to storage clean-up operation", zap.Error(err)) | ||
return fmt.Errorf("Error creating ticker to storage clean-up operation: %w", err) | ||
} | ||
|
||
defer storagecleanupTicker.Stop() | ||
|
||
for { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters