config.py 1006 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. # -*- coding: utf-8 -*-
  2. # @Author : YY
  3. from concurrent.futures import ThreadPoolExecutor
  4. from datetime import timedelta
  5. from ruoyi_common.ruoyi.config import CONFIG_CACHE
  6. class TokenConfig:
  7. header = CONFIG_CACHE["token.header"]
  8. secret = CONFIG_CACHE["token.secret"]
  9. _expire_time = CONFIG_CACHE["token.expireTime"]
  10. @classmethod
  11. def expire_time(cls) -> timedelta:
  12. """
  13. 获取过期时间
  14. Returns:
  15. timedelta: 过期时间
  16. """
  17. return timedelta(minutes=int(cls._expire_time))
  18. class ThreadPoolConfig:
  19. max_pool_size = 200
  20. keep_alive_time = 300
  21. @classmethod
  22. def thread_pool(cls) -> ThreadPoolExecutor:
  23. """
  24. 获取线程池
  25. Returns:
  26. ThreadPoolExecutor: 线程池
  27. """
  28. ThreadPool = ThreadPoolExecutor(
  29. max_workers=cls.max_pool_size,
  30. thread_name_prefix='schedule-pool-%d',
  31. )
  32. return ThreadPool