def send_to_kinesis_stream(events, stream_name, partition_key=None,<EOL>packer=None, serializer=json.dumps):
if not events:<EOL><INDENT>logger.info("<STR_LIT>")<EOL>return<EOL><DEDENT>records = []<EOL>for event in events:<EOL><INDENT>if not partition_key:<EOL><INDENT>partition_key_value = str(uuid.uuid4())<EOL><DEDENT>elif hasattr(partition_key, "<STR_LIT>"):<EOL><INDENT>partition_key_value = partition_key(event)<EOL><DEDENT>else:<EOL><INDENT>partition_key_value = partition_key<EOL><DEDENT>if not isinstance(event, str):<EOL><INDENT>event = serializer(event)<EOL><DEDENT>if packer:<EOL><INDENT>event = packer(event)<EOL><DEDENT>record = {"<STR_LIT>": event,<EOL>"<STR_LIT>": partition_key_value}<EOL>records.append(record)<EOL><DEDENT>kinesis = boto3.client("<STR_LIT>")<EOL>resp = kinesis.put_records(StreamName=stream_name, Records=records)<EOL>return resp<EOL>
Sends events to a Kinesis stream.