timoniq / telegrinder

Modern visionary telegram bot framework
MIT License
29 stars 4 forks source link

WaiterMachine base lifetime of all wait tasks #84

Open vffuunnyy opened 2 weeks ago

vffuunnyy commented 2 weeks ago

🚀 Feature Request 🚀

✏️ New feature description ✏️

Changeable base lifetime of all waiting tasks, instead of limiting their number (but they can be combined) or specifying the lifetime of each specific task.

🪄 Provide a minimal example 🪄

class WaiterMachine:
    def __init__(self, *, max_storage_size: int = 1000, base_task_lifetime: float | timedelta | None = None) -> None:
        self.max_storage_size = max_storage_size
        self.base_task_lifetime = base_task_lifetime
        self.storage: Storage = {}

✨ Teachability, Documentation, Adoption ✨

timoniq commented 2 weeks ago

just in addition to this

max_storage_size as long as proposed lifetime parameter should be changed to attributes of storage. Storage should behave as a factory for inner limited state collectors instead of adding it like this:

https://github.com/timoniq/telegrinder/blob/96bd77057bbcc8f07d1343240be142e91f49722c/telegrinder/bot/dispatch/waiter_machine/machine.py#L95