feat: merge feature/rfc135_merge_send18_dev_config

This commit is contained in:
莘权 马 2023-12-04 10:18:49 +08:00
commit 739348e8f1
4 changed files with 18 additions and 13 deletions

View file

@ -52,3 +52,6 @@ class ProductManager(Role):
else:
self._set_state(0)
return self._rc.todo
async def _observe(self, ignore_memory=False) -> int:
return await super(ProductManager, self)._observe(ignore_memory=True)

View file

@ -169,3 +169,8 @@ class QaEngineer(Role):
sent_from=self.profile,
send_to=MESSAGE_ROUTE_TO_NONE,
)
async def _observe(self, ignore_memory=False) -> int:
# This role has events that trigger and execute themselves based on conditions, and cannot rely on the
# content of memory to activate.
return await super(QaEngineer, self)._observe(ignore_memory=True)

View file

@ -291,12 +291,12 @@ class Role:
return msg
async def _observe(self) -> int:
async def _observe(self, ignore_memory=False) -> int:
"""Prepare new messages for processing from the message buffer and other sources."""
# Read unprocessed messages from the msg buffer.
news = self._rc.msg_buffer.pop_all()
# Store the read messages in your own memory to prevent duplicate processing.
old_messages = self._rc.memory.get()
old_messages = [] if ignore_memory else self._rc.memory.get()
self._rc.memory.add_batch(news)
# Filter out messages of interest.
self._rc.news = [n for n in news if n.cause_by in self._rc.watch and n not in old_messages]