go-tick / core

0 stars 0 forks source link

πŸ”₯ Feature: Dynamic Idle Polling Interval #7

Open misikdmytro opened 1 month ago

misikdmytro commented 1 month ago

πŸ”₯ Feature Description

Implement a feature that allows setting dynamic idle polling intervals in GoTick with support for multiple strategies, such as Zero, Constant interval, Exponential interval, and others as needed

πŸš€ Problem Solved

Currently, GoTick has a fixed polling interval during idle states, which can lead to inefficiencies in resource usage. Introducing dynamic polling intervals can help optimize performance by adjusting the polling frequency based on current system load, job availability, or other factors, reducing unnecessary database queries or system checks

πŸ’‘ Proposed Solution

  1. Strategy Pattern Implementation: Implement the Strategy pattern to allow easy addition and management of different polling interval strategies. Define an interface, PollingIntervalStrategy, which will have a method NextInterval() time.Duration to calculate the next polling interval and Reset() to reset current timer
  2. Strategy Options: Zero Interval (Immediate re-polling without any delay. Useful when real-time processing is required), Constant Interval (A fixed interval that does not change, defined by the user), Exponential Interval (Starts with a base interval and increase it after each idle cycle, up to a maximum limit, to reduce the load on the system during low activity periods)
  3. Configuration: Add configuration options to select the polling interval strategy and provide any necessary parameters (e.g., base interval, maximum interval for exponential strategy).

πŸ”„ Alternatives Considered

A simple backoff strategy without exponential growth, but it lacks the flexibility provided by multiple strategies

πŸ“¦ Additional Context

Ensure that the configuration is easily accessible via the existing configuration management system

πŸ“š Related Issues

No response