Source code for example.example

"""
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
"""

import asyncio
import logging

from stream_manager import MessageStreamDefinition, ReadMessagesOptions, StrategyOnFull, StreamManagerClient


[docs]def main(): try: client = StreamManagerClient() client.delete_message_stream("jjj") print( client.create_message_stream( MessageStreamDefinition( name="jjj", max_size=1024 * 1024, strategy_on_full=StrategyOnFull.OverwriteOldestData ) ) ) print(client.append_message("jjj", "ABCDEFGHIJKLMNO".encode("utf-8"))) print(client.append_message("jjj", "asdgdgdgs".encode("utf-8"))) print(client.append_message("jjj", "sdgaoidsgdg9373bgjd".encode("utf-8"))) print(client.read_messages("jjj", ReadMessagesOptions(min_message_count=3, read_timeout_millis=1000))) except asyncio.TimeoutError: print("Timed out") except Exception as e: print(e) print(type(e)) finally: if client: client.close()
if __name__ == "__main__": logging.basicConfig(level=logging.NOTSET) main()