Closed allran closed 8 months ago
We were thinking about it, but consider to support only async API Is it problem for you?
Because when sending a message, I need the following encapsulation to work properly:
def publish_msg(*args, **kwargs):
"""
发送消息
"""
async def send_msg():
#
broker_pub = kwargs.get('broker', None) # 是否有传入broker
if broker_pub is None and len(args) > 0:
bro = args[0]
if isinstance(bro, RabbitBroker): # 传入的第一个参数,是否是broker
broker_pub = bro
if broker_pub is None:
async with RabbitBroker(broker_url) as broker_pub:
await broker_pub.publish(*args, **kwargs)
else:
await broker_pub.connect()
await broker_pub.publish(*args, **kwargs)
asyncio.run(send_msg())
if __name__ == "__main__":
publish_msg("messageOne", "in")
I have a plan to add syncify class from this discussion. Now you can use it by youself
ok, thanks very much. @Lancetnik
To suggest an idea or inquire about a new Message Broker supporting feature or any other enhancement, please follow this template:
Is your feature request related to a problem? Please describe. Provide a clear and concise description of the problem you've encountered. For example: "I'm always frustrated when..."
Describe the solution you'd like Clearly and concisely describe the desired outcome or solution.
Feature code example To help others understand the proposed feature, illustrate it with a FastStream code example:
Describe alternatives you've considered Provide a clear and concise description of any alternative solutions or features you've thought about.
Additional context Include any other relevant context or screenshots related to the feature request.