funboost 44.5__py3-none-any.whl → 44.6__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of funboost might be problematic. Click here for more details.

Files changed (86) hide show
  1. funboost/__init__.py +3 -2
  2. funboost/constant.py +2 -0
  3. funboost/consumers/base_consumer.py +4 -1
  4. funboost/consumers/empty_consumer.py +26 -0
  5. funboost/consumers/redis_consumer.py +5 -5
  6. funboost/consumers/redis_consumer_ack_able.py +4 -2
  7. funboost/consumers/redis_stream_consumer.py +3 -2
  8. funboost/core/funboost_current_task_context_thread.py +12 -0
  9. funboost/core/func_params_model.py +6 -2
  10. funboost/factories/broker_kind__publsiher_consumer_type_map.py +3 -1
  11. funboost/factories/consumer_factory.py +9 -1
  12. funboost/factories/publisher_factotry.py +10 -1
  13. funboost/function_result_web/__pycache__/app.cpython-37.pyc +0 -0
  14. funboost/function_result_web/__pycache__/functions.cpython-37.pyc +0 -0
  15. funboost/publishers/empty_publisher.py +31 -0
  16. funboost/set_frame_config.py +1 -1
  17. funboost/utils/class_utils.py +51 -0
  18. funboost/utils/decorators.py +1 -1
  19. funboost/utils/dependency_packages_in_pythonpath/__pycache__/__init__.cpython-311.pyc +0 -0
  20. funboost/utils/dependency_packages_in_pythonpath/__pycache__/__init__.cpython-37.pyc +0 -0
  21. funboost/utils/dependency_packages_in_pythonpath/__pycache__/__init__.cpython-39.pyc +0 -0
  22. funboost/utils/dependency_packages_in_pythonpath/__pycache__/add_to_pythonpath.cpython-311.pyc +0 -0
  23. funboost/utils/dependency_packages_in_pythonpath/__pycache__/add_to_pythonpath.cpython-37.pyc +0 -0
  24. funboost/utils/dependency_packages_in_pythonpath/__pycache__/add_to_pythonpath.cpython-39.pyc +0 -0
  25. funboost/utils/dependency_packages_in_pythonpath/aioredis/__init__.py +59 -59
  26. funboost/utils/dependency_packages_in_pythonpath/aioredis/__pycache__/__init__.cpython-311.pyc +0 -0
  27. funboost/utils/dependency_packages_in_pythonpath/aioredis/__pycache__/__init__.cpython-37.pyc +0 -0
  28. funboost/utils/dependency_packages_in_pythonpath/aioredis/__pycache__/__init__.cpython-39.pyc +0 -0
  29. funboost/utils/dependency_packages_in_pythonpath/aioredis/__pycache__/client.cpython-311.pyc +0 -0
  30. funboost/utils/dependency_packages_in_pythonpath/aioredis/__pycache__/client.cpython-37.pyc +0 -0
  31. funboost/utils/dependency_packages_in_pythonpath/aioredis/__pycache__/client.cpython-39.pyc +0 -0
  32. funboost/utils/dependency_packages_in_pythonpath/aioredis/__pycache__/compat.cpython-311.pyc +0 -0
  33. funboost/utils/dependency_packages_in_pythonpath/aioredis/__pycache__/compat.cpython-37.pyc +0 -0
  34. funboost/utils/dependency_packages_in_pythonpath/aioredis/__pycache__/compat.cpython-39.pyc +0 -0
  35. funboost/utils/dependency_packages_in_pythonpath/aioredis/__pycache__/connection.cpython-311.pyc +0 -0
  36. funboost/utils/dependency_packages_in_pythonpath/aioredis/__pycache__/connection.cpython-37.pyc +0 -0
  37. funboost/utils/dependency_packages_in_pythonpath/aioredis/__pycache__/connection.cpython-39.pyc +0 -0
  38. funboost/utils/dependency_packages_in_pythonpath/aioredis/__pycache__/exceptions.cpython-311.pyc +0 -0
  39. funboost/utils/dependency_packages_in_pythonpath/aioredis/__pycache__/exceptions.cpython-37.pyc +0 -0
  40. funboost/utils/dependency_packages_in_pythonpath/aioredis/__pycache__/exceptions.cpython-39.pyc +0 -0
  41. funboost/utils/dependency_packages_in_pythonpath/aioredis/__pycache__/lock.cpython-311.pyc +0 -0
  42. funboost/utils/dependency_packages_in_pythonpath/aioredis/__pycache__/lock.cpython-37.pyc +0 -0
  43. funboost/utils/dependency_packages_in_pythonpath/aioredis/__pycache__/lock.cpython-39.pyc +0 -0
  44. funboost/utils/dependency_packages_in_pythonpath/aioredis/__pycache__/utils.cpython-311.pyc +0 -0
  45. funboost/utils/dependency_packages_in_pythonpath/aioredis/__pycache__/utils.cpython-37.pyc +0 -0
  46. funboost/utils/dependency_packages_in_pythonpath/aioredis/__pycache__/utils.cpython-39.pyc +0 -0
  47. funboost/utils/dependency_packages_in_pythonpath/aioredis/client.py +4804 -4804
  48. funboost/utils/dependency_packages_in_pythonpath/aioredis/compat.py +8 -8
  49. funboost/utils/dependency_packages_in_pythonpath/aioredis/connection.py +1668 -1668
  50. funboost/utils/dependency_packages_in_pythonpath/aioredis/exceptions.py +96 -96
  51. funboost/utils/dependency_packages_in_pythonpath/aioredis/lock.py +306 -306
  52. funboost/utils/dependency_packages_in_pythonpath/aioredis/log.py +15 -15
  53. funboost/utils/dependency_packages_in_pythonpath/aioredis/sentinel.py +329 -329
  54. funboost/utils/dependency_packages_in_pythonpath/aioredis/utils.py +61 -61
  55. funboost/utils/dependency_packages_in_pythonpath/func_timeout/StoppableThread.py +133 -133
  56. funboost/utils/dependency_packages_in_pythonpath/func_timeout/__init__.py +16 -16
  57. funboost/utils/dependency_packages_in_pythonpath/func_timeout/__pycache__/StoppableThread.cpython-311.pyc +0 -0
  58. funboost/utils/dependency_packages_in_pythonpath/func_timeout/__pycache__/StoppableThread.cpython-37.pyc +0 -0
  59. funboost/utils/dependency_packages_in_pythonpath/func_timeout/__pycache__/StoppableThread.cpython-39.pyc +0 -0
  60. funboost/utils/dependency_packages_in_pythonpath/func_timeout/__pycache__/__init__.cpython-311.pyc +0 -0
  61. funboost/utils/dependency_packages_in_pythonpath/func_timeout/__pycache__/__init__.cpython-37.pyc +0 -0
  62. funboost/utils/dependency_packages_in_pythonpath/func_timeout/__pycache__/__init__.cpython-39.pyc +0 -0
  63. funboost/utils/dependency_packages_in_pythonpath/func_timeout/__pycache__/dafunc.cpython-311.pyc +0 -0
  64. funboost/utils/dependency_packages_in_pythonpath/func_timeout/__pycache__/dafunc.cpython-37.pyc +0 -0
  65. funboost/utils/dependency_packages_in_pythonpath/func_timeout/__pycache__/dafunc.cpython-39.pyc +0 -0
  66. funboost/utils/dependency_packages_in_pythonpath/func_timeout/__pycache__/exceptions.cpython-311.pyc +0 -0
  67. funboost/utils/dependency_packages_in_pythonpath/func_timeout/__pycache__/exceptions.cpython-37.pyc +0 -0
  68. funboost/utils/dependency_packages_in_pythonpath/func_timeout/__pycache__/exceptions.cpython-39.pyc +0 -0
  69. funboost/utils/dependency_packages_in_pythonpath/func_timeout/__pycache__/py3_raise.cpython-311.pyc +0 -0
  70. funboost/utils/dependency_packages_in_pythonpath/func_timeout/__pycache__/py3_raise.cpython-37.pyc +0 -0
  71. funboost/utils/dependency_packages_in_pythonpath/func_timeout/__pycache__/py3_raise.cpython-39.pyc +0 -0
  72. funboost/utils/dependency_packages_in_pythonpath/func_timeout/dafunc.py +244 -244
  73. funboost/utils/dependency_packages_in_pythonpath/func_timeout/exceptions.py +98 -98
  74. funboost/utils/dependency_packages_in_pythonpath/func_timeout/py2_raise.py +7 -7
  75. funboost/utils/dependency_packages_in_pythonpath/func_timeout/py3_raise.py +7 -7
  76. funboost/utils/simple_data_class.py +17 -0
  77. funboost/utils/str_utils.py +51 -0
  78. funboost/utils/times/__init__.py +85 -85
  79. funboost/utils/times/version.py +1 -1
  80. {funboost-44.5.dist-info → funboost-44.6.dist-info}/METADATA +2 -1
  81. {funboost-44.5.dist-info → funboost-44.6.dist-info}/RECORD +85 -51
  82. {funboost-44.5.dist-info → funboost-44.6.dist-info}/entry_points.txt +1 -0
  83. funboost/function_result_web/__pycache__/functions.cpython-39.pyc +0 -0
  84. {funboost-44.5.dist-info → funboost-44.6.dist-info}/LICENSE +0 -0
  85. {funboost-44.5.dist-info → funboost-44.6.dist-info}/WHEEL +0 -0
  86. {funboost-44.5.dist-info → funboost-44.6.dist-info}/top_level.txt +0 -0
funboost/__init__.py CHANGED
@@ -13,7 +13,7 @@ set_frame_config这个模块的 use_config_form_funboost_config_module() 是核
13
13
  这段注释说明和使用的用户无关,只和框架开发人员有关.
14
14
  '''
15
15
 
16
- __version__ = "44.5"
16
+ __version__ = "44.6"
17
17
 
18
18
  from funboost.set_frame_config import show_frame_config
19
19
 
@@ -31,12 +31,13 @@ from funboost.utils.paramiko_util import ParamikoFolderUploader
31
31
 
32
32
  from funboost.consumers.base_consumer import (wait_for_possible_has_finish_all_tasks_by_conusmer_list,
33
33
  FunctionResultStatus, AbstractConsumer)
34
-
34
+ from funboost.consumers.empty_consumer import EmptyConsumer
35
35
  from funboost.core.exceptions import ExceptionForRetry, ExceptionForRequeue, ExceptionForPushToDlxqueue
36
36
  from funboost.core.active_cousumer_info_getter import ActiveCousumerProcessInfoGetter
37
37
  from funboost.core.msg_result_getter import HasNotAsyncResult, ResultFromMongo
38
38
  from funboost.publishers.base_publisher import (PriorityConsumingControlConfig,
39
39
  AbstractPublisher, AsyncResult, AioAsyncResult)
40
+ from funboost.publishers.empty_publisher import EmptyPublisher
40
41
  from funboost.factories.broker_kind__publsiher_consumer_type_map import register_custom_broker
41
42
  from funboost.factories.publisher_factotry import get_publisher
42
43
  from funboost.factories.consumer_factory import get_consumer
funboost/constant.py CHANGED
@@ -1,5 +1,7 @@
1
1
  # coding= utf-8
2
2
  class BrokerEnum:
3
+ EMPTY = 'empty' # 空的实现,需要搭配 boost入参的 consumer_override_cls 和 publisher_override_cls使用,或者被继承。
4
+
3
5
  RABBITMQ_AMQPSTORM = 'RABBITMQ_AMQPSTORM' # 使用 amqpstorm 包操作rabbitmq 作为 分布式消息队列,支持消费确认.强烈推荐这个作为funboost中间件。
4
6
  RABBITMQ = RABBITMQ_AMQPSTORM
5
7
 
@@ -562,6 +562,9 @@ class AbstractConsumer(LoggerLevelSetterMixin, metaclass=abc.ABCMeta, ):
562
562
  """
563
563
  self._do_not_delete_extra_from_msg = True
564
564
 
565
+ def user_custom_record_process_info_func(self,current_function_result_status:FunctionResultStatus): # 这个可以继承
566
+ pass
567
+
565
568
  # noinspection PyProtectedMember
566
569
  def _run(self, kw: dict, ):
567
570
  # print(kw)
@@ -633,7 +636,7 @@ class AbstractConsumer(LoggerLevelSetterMixin, metaclass=abc.ABCMeta, ):
633
636
  self._current_time_for_execute_task_times_every_unit_time = time.time()
634
637
  self._consuming_function_cost_time_total_every_unit_time = 0
635
638
  self._execute_task_times_every_unit_time = 0
636
-
639
+ self.user_custom_record_process_info_func(current_function_result_status) # 两种方式都可以自定义,记录结果.
637
640
  if self.consumer_params.user_custom_record_process_info_func:
638
641
  self.consumer_params.user_custom_record_process_info_func(current_function_result_status)
639
642
  except BaseException as e:
@@ -0,0 +1,26 @@
1
+ # -*- coding: utf-8 -*-
2
+ # @Author : ydf
3
+ # @Time : 2023/8/8 0008 13:32
4
+
5
+ import abc
6
+ from funboost.consumers.base_consumer import AbstractConsumer
7
+
8
+
9
+ class EmptyConsumer(AbstractConsumer, metaclass=abc.ABCMeta):
10
+ """
11
+ 空的消费者没实现,空的实现,需要搭配 boost入参的 consumer_override_cls 和 publisher_override_cls使用,或者被继承。
12
+ """
13
+ def custom_init(self):
14
+ pass
15
+
16
+ @abc.abstractmethod
17
+ def _shedual_task(self):
18
+ raise NotImplemented('not realization')
19
+
20
+ @abc.abstractmethod
21
+ def _confirm_consume(self, kw):
22
+ raise NotImplemented('not realization')
23
+
24
+ @abc.abstractmethod
25
+ def _requeue(self, kw):
26
+ raise NotImplemented('not realization')
@@ -17,20 +17,20 @@ class RedisConsumer(AbstractConsumer, RedisMixin):
17
17
  redis作为中间件实现的,使用redis list 结构实现的。
18
18
  这个如果消费脚本在运行时候随意反复重启或者非正常关闭或者消费宕机,会丢失大批任务。高可靠需要用rabbitmq或者redis_ack_able或者redis_stream的中间件方式。
19
19
 
20
- 这个是复杂版,一次性拉取100个,简单版在 funboost/consumers/redis_consumer_simple.py
20
+ 这个是复杂版,一次性拉取100个,减少和redis的交互,简单版在 funboost/consumers/redis_consumer_simple.py
21
21
  """
22
22
 
23
- BROKER_EXCLUSIVE_CONFIG_DEFAULT = {'redis_bulk_push':1} #redis_bulk_push 是否redis批量推送
23
+ BROKER_EXCLUSIVE_CONFIG_DEFAULT = {'redis_bulk_push':1,'pull_msg_batch_size':100} #redis_bulk_push 是否redis批量推送
24
24
 
25
25
  # noinspection DuplicatedCode
26
26
  def _shedual_task(self):
27
+ pull_msg_batch_size = self.consumer_params.broker_exclusive_config['pull_msg_batch_size']
27
28
  while True:
28
29
  # if False:
29
30
  # pass
30
31
  with self.redis_db_frame.pipeline() as p:
31
- get_msg_batch_size = 100
32
- p.lrange(self._queue_name, 0, get_msg_batch_size - 1)
33
- p.ltrim(self._queue_name, get_msg_batch_size, -1)
32
+ p.lrange(self._queue_name, 0, pull_msg_batch_size- 1)
33
+ p.ltrim(self._queue_name, pull_msg_batch_size, -1)
34
34
  task_str_list = p.execute()[0]
35
35
  if task_str_list:
36
36
  # self.logger.debug(f'从redis的 [{self._queue_name}] 队列中 取出的消息是: {task_str_list} ')
@@ -99,6 +99,7 @@ class RedisConsumerAckAble(ConsumerConfirmMixinWithTheHelpOfRedisByHearbeat, Abs
99
99
  # print(script_4(keys=["text_pipelien1","text_pipelien1b"]))
100
100
  """
101
101
 
102
+ BROKER_EXCLUSIVE_CONFIG_DEFAULT = { 'pull_msg_batch_size': 100}
102
103
 
103
104
  def _shedual_task000(self):
104
105
  # 可以采用lua脚本,也可以采用redis的watch配合pipeline使用。比代码分两行pop和zadd比还能减少一次io交互,还能防止丢失小概率一个任务。
@@ -122,8 +123,9 @@ class RedisConsumerAckAble(ConsumerConfirmMixinWithTheHelpOfRedisByHearbeat, Abs
122
123
  time.sleep(0.5)
123
124
 
124
125
  def _shedual_task(self):
125
- lua = '''
126
- local task_list = redis.call("lrange", KEYS[1],0,99)
126
+ pull_msg_batch_size = self.consumer_params.broker_exclusive_config['pull_msg_batch_size']
127
+ lua = f'''
128
+ local task_list = redis.call("lrange", KEYS[1],0,{pull_msg_batch_size-1})
127
129
  redis.call("ltrim", KEYS[1],100,-1)
128
130
  if (#task_list > 0) then
129
131
  for task_index,task_value in ipairs(task_list)
@@ -14,7 +14,7 @@ class RedisStreamConsumer(AbstractConsumer, RedisMixin):
14
14
  redis 的 stream 结构 作为中间件实现的。需要redis 5.0以上,redis stream结构 是redis的消息队列,概念类似kafka,功能远超 list结构。
15
15
  """
16
16
  GROUP = 'funboost_group'
17
- BROKER_EXCLUSIVE_CONFIG_DEFAULT = {'group': 'funboost_group'}
17
+ BROKER_EXCLUSIVE_CONFIG_DEFAULT = {'group': 'funboost_group','pull_msg_batch_size': 100}
18
18
 
19
19
  def custom_init(self):
20
20
  self.group = self.consumer_params.broker_exclusive_config['group'] or self.GROUP
@@ -33,6 +33,7 @@ class RedisStreamConsumer(AbstractConsumer, RedisMixin):
33
33
  self.keep_circulating(60, block=False)(self._requeue_tasks_which_unconfirmed)()
34
34
 
35
35
  def _shedual_task(self):
36
+ pull_msg_batch_size = self.consumer_params.broker_exclusive_config['pull_msg_batch_size']
36
37
 
37
38
  try:
38
39
  self.redis_db_frame.xgroup_create(self._queue_name,self.group , id=0, mkstream=True)
@@ -41,7 +42,7 @@ class RedisStreamConsumer(AbstractConsumer, RedisMixin):
41
42
  while True:
42
43
  # redis服务端必须是5.0以上,并且确保这个键的类型是stream不能是list数据结构。
43
44
  results = self.redis_db_frame.xreadgroup(self.group, self.consumer_identification,
44
- {self.queue_name: ">"}, count=100, block=60 * 1000)
45
+ {self.queue_name: ">"}, count=pull_msg_batch_size, block=60 * 1000)
45
46
  if results:
46
47
  # self.logger.debug(f'从redis的 [{self._queue_name}] stream 中 取出的消息是: {results} ')
47
48
  self._print_message_get_from_broker( results)
@@ -0,0 +1,12 @@
1
+ # import threading
2
+ #
3
+ # from funboost.core.current_task import thread_current_task
4
+ #
5
+ #
6
+ # class FctThread(threading.Thread):
7
+ # thread_current_task__dict_key = 'thread_current_task__dict'
8
+ #
9
+ #
10
+ # def run(self):
11
+ # thread_current_task._fct_local_data.__dict__.update(getattr(self,self.thread_current_task__dict_key)) # 把funboost的消费线程上下文需要传递到线程上下文里面来.
12
+ # super().run()
@@ -178,13 +178,16 @@ class BoosterParams(BaseJsonAbleModel):
178
178
 
179
179
  consuming_function: typing.Callable = None # 消费函数,在@boost时候不用指定,因为装饰器知道下面的函数.
180
180
 
181
- broker_kind: str = BrokerEnum.PERSISTQUEUE # 中间件选型见3.1章节 https://funboost.readthedocs.io/zh/latest/articles/c3.html
181
+ broker_kind: str = BrokerEnum.SQLITE_QUEUE # 中间件选型见3.1章节 https://funboost.readthedocs.io/zh/latest/articles/c3.html
182
182
 
183
183
  broker_exclusive_config: dict = {} # 加上一个不同种类中间件非通用的配置,不同中间件自身独有的配置,不是所有中间件都兼容的配置,因为框架支持30种消息队列,消息队列不仅仅是一般的先进先出queue这么简单的概念,
184
184
  # 例如kafka支持消费者组,rabbitmq也支持各种独特概念例如各种ack机制 复杂路由机制,有的中间件原生能支持消息优先级有的中间件不支持,每一种消息队列都有独特的配置参数意义,可以通过这里传递。每种中间件能传递的键值对可以看consumer类的 BROKER_EXCLUSIVE_CONFIG_DEFAULT
185
185
 
186
186
  should_check_publish_func_params: bool = True # 消息发布时候是否校验消息发布内容,比如有的人发布消息,函数只接受a,b两个入参,他去传2个入参,或者传参不存在的参数名字, 如果消费函数你非要写*args,**kwargs,那就需要关掉发布消息时候的函数入参检查
187
187
 
188
+ consumer_override_cls: typing.Optional[typing.Type] = None # 使用 consumer_override_cls 和 publisher_override_cls 来自定义重写或新增消费者 发布者,见文档4.21b介绍,
189
+ publisher_override_cls: typing.Optional[typing.Type] = None
190
+
188
191
  auto_generate_info: dict = {} # 自动生成的信息,不需要用户主动传参.
189
192
 
190
193
  @root_validator(skip_on_failure=True)
@@ -266,6 +269,7 @@ class PublisherParams(BaseJsonAbleModel):
266
269
  broker_kind: str = None
267
270
  broker_exclusive_config: dict = {}
268
271
  should_check_publish_func_params: bool = True # 消息发布时候是否校验消息发布内容,比如有的人发布消息,函数只接受a,b两个入参,他去传2个入参,或者传参不存在的参数名字, 如果消费函数你非要写*args,**kwargs,那就需要关掉发布消息时候的函数入参检查
272
+ publisher_override_cls: typing.Optional[typing.Type] = None
269
273
 
270
274
 
271
275
  if __name__ == '__main__':
@@ -277,4 +281,4 @@ if __name__ == '__main__':
277
281
  # print(PriorityConsumingControlConfig().get_str_dict())
278
282
 
279
283
  print(BoosterParams(queue_name='3213', specify_concurrent_pool=FlexibleThreadPool(100)).json_pre())
280
- print(PublisherParams.schema_json())
284
+ print(PublisherParams.schema_json())
@@ -1,6 +1,6 @@
1
1
  import typing
2
2
 
3
-
3
+ from funboost.publishers.empty_publisher import EmptyPublisher
4
4
  from funboost.publishers.http_publisher import HTTPPublisher
5
5
  from funboost.publishers.nats_publisher import NatsPublisher
6
6
  from funboost.publishers.peewee_publisher import PeeweePublisher
@@ -25,6 +25,7 @@ from funboost.publishers.redis_stream_publisher import RedisStreamPublisher
25
25
  from funboost.publishers.mqtt_publisher import MqttPublisher
26
26
  from funboost.publishers.httpsqs_publisher import HttpsqsPublisher
27
27
 
28
+ from funboost.consumers.empty_consumer import EmptyConsumer
28
29
  from funboost.consumers.redis_consumer_priority import RedisPriorityConsumer
29
30
  from funboost.consumers.redis_pubsub_consumer import RedisPbSubConsumer
30
31
  from funboost.consumers.http_consumer import HTTPConsumer
@@ -80,6 +81,7 @@ broker_kind__publsiher_consumer_type_map = {
80
81
  BrokerEnum.PEEWEE: (PeeweePublisher, PeeweeConsumer),
81
82
  BrokerEnum.REDIS_PUBSUB: (RedisPubSubPublisher, RedisPbSubConsumer),
82
83
  BrokerEnum.REIDS_ACK_USING_TIMEOUT: (RedisPublisher, RedisConsumerAckUsingTimeout),
84
+ BrokerEnum.EMPTY:(EmptyPublisher,EmptyConsumer),
83
85
 
84
86
  }
85
87
 
@@ -20,4 +20,12 @@ def get_consumer(boost_params: BoosterParams) -> AbstractConsumer:
20
20
 
21
21
  if boost_params.broker_kind not in broker_kind__publsiher_consumer_type_map:
22
22
  raise ValueError(f'设置的中间件种类数字不正确,你设置的值是 {boost_params.broker_kind} ')
23
- return broker_kind__publsiher_consumer_type_map[boost_params.broker_kind][1](boost_params)
23
+ consumer_cls = broker_kind__publsiher_consumer_type_map[boost_params.broker_kind][1]
24
+ if not boost_params.consumer_override_cls:
25
+ return consumer_cls(boost_params)
26
+ else:
27
+ ConsumerClsOverride = type(f'{consumer_cls.__name__}__{boost_params.consumer_override_cls.__name__}', (boost_params.consumer_override_cls, consumer_cls, AbstractConsumer), {})
28
+ # class ConsumerClsOverride(boost_params.consumer_override_cls, consumer_cls, AbstractConsumer):
29
+ # pass
30
+
31
+ return ConsumerClsOverride(boost_params)
@@ -32,4 +32,13 @@ def get_publisher(publisher_params: PublisherParams) -> AbstractPublisher:
32
32
  regist_to_funboost(broker_kind) # 动态注册中间件到框架是为了延迟导入,用户没安装不需要的第三方包不报错。
33
33
  if broker_kind not in broker_kind__publsiher_consumer_type_map:
34
34
  raise ValueError(f'设置的中间件种类数字不正确,你设置的值是 {broker_kind} ')
35
- return broker_kind__publsiher_consumer_type_map[broker_kind][0](publisher_params)
35
+ publisher_cls = broker_kind__publsiher_consumer_type_map[broker_kind][0]
36
+ if not publisher_params.publisher_override_cls:
37
+ return publisher_cls(publisher_params)
38
+ else:
39
+ PublsiherClsOverride = type(f'{publisher_cls.__name__}__{publisher_params.publisher_override_cls.__name__}', (publisher_params.publisher_override_cls, publisher_cls, AbstractPublisher), {})
40
+ # class PublsiherClsOverride(publisher_params.publisher_override_cls, publisher_cls, AbstractPublisher):
41
+ # pass
42
+
43
+ return PublsiherClsOverride(publisher_params)
44
+
@@ -0,0 +1,31 @@
1
+ # -*- coding: utf-8 -*-
2
+ # @Author : ydf
3
+ # @Time : 2023/8/8 0008 12:12
4
+
5
+ import abc
6
+ from funboost.publishers.base_publisher import AbstractPublisher
7
+
8
+
9
+ class EmptyPublisher(AbstractPublisher, metaclass=abc.ABCMeta):
10
+ """
11
+ 空的发布者,空的实现,需要搭配 boost入参的 consumer_override_cls 和 publisher_override_cls使用,或者被继承。
12
+ """
13
+
14
+ def custom_init(self):
15
+ pass
16
+
17
+ @abc.abstractmethod
18
+ def concrete_realization_of_publish(self, msg: str):
19
+ raise NotImplemented('not realization')
20
+
21
+ @abc.abstractmethod
22
+ def clear(self):
23
+ raise NotImplemented('not realization')
24
+
25
+ @abc.abstractmethod
26
+ def get_message_count(self):
27
+ raise NotImplemented('not realization')
28
+
29
+ @abc.abstractmethod
30
+ def close(self):
31
+ raise NotImplemented('not realization')
@@ -98,7 +98,7 @@ def show_frame_config():
98
98
  # only_print_on_main_process(f'{var_name}: {var_value[0]}{"*" * (len(var_value) - 2)}{var_value[-1]}')
99
99
  # else:
100
100
  # only_print_on_main_process(f'{var_name}: {var_value}')
101
- logger_prompt.debug(f'''读取的 BrokerConnConfig 配置是:\n {funboost_config_deafult.BrokerConnConfig().get_json(indent=None)} ''')
101
+ logger_prompt.debug(f'''读取的 BrokerConnConfig 配置是:\n {funboost_config_deafult.BrokerConnConfig().get_pwd_enc_json(indent=4)} ''')
102
102
 
103
103
  logger_prompt.debug(f'''读取的 FunboostCommonConfig 配置是:\n {funboost_config_deafult.FunboostCommonConfig().get_json(indent=None)} ''')
104
104
 
@@ -0,0 +1,51 @@
1
+ #
2
+ #
3
+ # # def get_child_custom_attr(child_cls:type,):
4
+ # # __dict = child_cls.__dict__
5
+ #
6
+ # def merge_cls(cls1:type,cls2:type):
7
+ # class Cls(cls2):
8
+ # pass
9
+ # for k,v in cls1.__dict__.items():
10
+ # if k.startswith('__') and k.endswith('__'):
11
+ # continue
12
+ # print(k,v)
13
+ # setattr(Cls,k,v)
14
+ # return Cls
15
+ #
16
+ #
17
+ # if __name__ == '__main__':
18
+ # class Parent:
19
+ # attr1=1
20
+ # def method_from_parent(self):
21
+ # print('method_from_parent')
22
+ #
23
+ # def method_from_parent2(self):
24
+ # print('method_from_parent2')
25
+ #
26
+ #
27
+ # class Child(Parent):
28
+ # attr1=2
29
+ # attr2=22
30
+ #
31
+ # def method_from_parent2(self):
32
+ # print('method_from_parent2chile')
33
+ # def method_from_child(self:Parent):
34
+ # print('method_from_child')
35
+ #
36
+ # class Child2(Parent,Parent):
37
+ # attr1 = 3
38
+ #
39
+ # class Child2b(Child2):
40
+ # attr1 = '2b'
41
+ #
42
+ #
43
+ # class Child2New(Child2b,Child):
44
+ # pass
45
+ #
46
+ #
47
+ # print(Child2().method_from_parent2())
48
+ # print(Child2New().method_from_parent2())
49
+ #
50
+ #
51
+ #
@@ -509,7 +509,7 @@ def cached_method_result_for_instance(fun):
509
509
 
510
510
 
511
511
  class FunctionResultCacher:
512
- logger = LogManager('FunctionResultChche').get_logger_and_add_handlers()
512
+ logger = LogManager('FunctionResultChche').get_logger_and_add_handlers(log_level_int=20)
513
513
  func_result_dict = {}
514
514
  """
515
515
  {
@@ -1,59 +1,59 @@
1
- from aioredis.client import Redis, StrictRedis
2
- from aioredis.connection import (
3
- BlockingConnectionPool,
4
- Connection,
5
- ConnectionPool,
6
- SSLConnection,
7
- UnixDomainSocketConnection,
8
- )
9
- from aioredis.exceptions import (
10
- AuthenticationError,
11
- AuthenticationWrongNumberOfArgsError,
12
- BusyLoadingError,
13
- ChildDeadlockedError,
14
- ConnectionError,
15
- DataError,
16
- InvalidResponse,
17
- PubSubError,
18
- ReadOnlyError,
19
- RedisError,
20
- ResponseError,
21
- TimeoutError,
22
- WatchError,
23
- )
24
- from aioredis.utils import from_url
25
-
26
-
27
- def int_or_str(value):
28
- try:
29
- return int(value)
30
- except ValueError:
31
- return value
32
-
33
-
34
- __version__ = "2.0.1"
35
- VERSION = tuple(map(int_or_str, __version__.split(".")))
36
-
37
- __all__ = [
38
- "AuthenticationError",
39
- "AuthenticationWrongNumberOfArgsError",
40
- "BlockingConnectionPool",
41
- "BusyLoadingError",
42
- "ChildDeadlockedError",
43
- "Connection",
44
- "ConnectionError",
45
- "ConnectionPool",
46
- "DataError",
47
- "from_url",
48
- "InvalidResponse",
49
- "PubSubError",
50
- "ReadOnlyError",
51
- "Redis",
52
- "RedisError",
53
- "ResponseError",
54
- "SSLConnection",
55
- "StrictRedis",
56
- "TimeoutError",
57
- "UnixDomainSocketConnection",
58
- "WatchError",
59
- ]
1
+ from aioredis.client import Redis, StrictRedis
2
+ from aioredis.connection import (
3
+ BlockingConnectionPool,
4
+ Connection,
5
+ ConnectionPool,
6
+ SSLConnection,
7
+ UnixDomainSocketConnection,
8
+ )
9
+ from aioredis.exceptions import (
10
+ AuthenticationError,
11
+ AuthenticationWrongNumberOfArgsError,
12
+ BusyLoadingError,
13
+ ChildDeadlockedError,
14
+ ConnectionError,
15
+ DataError,
16
+ InvalidResponse,
17
+ PubSubError,
18
+ ReadOnlyError,
19
+ RedisError,
20
+ ResponseError,
21
+ TimeoutError,
22
+ WatchError,
23
+ )
24
+ from aioredis.utils import from_url
25
+
26
+
27
+ def int_or_str(value):
28
+ try:
29
+ return int(value)
30
+ except ValueError:
31
+ return value
32
+
33
+
34
+ __version__ = "2.0.1"
35
+ VERSION = tuple(map(int_or_str, __version__.split(".")))
36
+
37
+ __all__ = [
38
+ "AuthenticationError",
39
+ "AuthenticationWrongNumberOfArgsError",
40
+ "BlockingConnectionPool",
41
+ "BusyLoadingError",
42
+ "ChildDeadlockedError",
43
+ "Connection",
44
+ "ConnectionError",
45
+ "ConnectionPool",
46
+ "DataError",
47
+ "from_url",
48
+ "InvalidResponse",
49
+ "PubSubError",
50
+ "ReadOnlyError",
51
+ "Redis",
52
+ "RedisError",
53
+ "ResponseError",
54
+ "SSLConnection",
55
+ "StrictRedis",
56
+ "TimeoutError",
57
+ "UnixDomainSocketConnection",
58
+ "WatchError",
59
+ ]