yr.create_stream_producer

yr.create_stream_producer#

yr.create_stream_producer(stream_name: str, config: ProducerConfig) Producer[source]#

Create a producer.

Parameters:
  • stream_name (str) – The name of the stream. The length must be less than 256 characters and contain only the following characters (a-zA-Z0-9~.-/_!@#%^&*()+=;:) .

  • config (ProducerConfig) – The configuration of the producer.

Returns:

Producer.

Raises:

RuntimeError – If creating the Producer fails.

Examples

>>> try:
...     producer_config = yr.ProducerConfig(
...         delay_flush_time=5,
...         page_size=1024 * 1024,
...         max_stream_size=1024 * 1024 * 1024,
...         auto_clean_up=True,
...     )
...     stream_producer = yr.create_stream_producer("streamName", producer_config)
... except RuntimeError as exp:
...     # 处理异常
...     pass