def main()

in producer/producer.py [0:0]


def main (stream_name):
    client = boto3.client('kinesis', region_name='eu-central-1')

    # Generate data record
    record = {
        "sensor_id": get_random_string(30),
        "temperature": 0.0,
        "rpm": "1500",
        "in_service": True,
    }

    # Generate data records with normal distribution
    mu = 70.0
    sigma = 4.0
    data = np.random.randn(100000) * sigma + mu
    i=0

    while True:
        # Replace temperature with record from normal distribution dataset
        record['temperature'] = data[i]

        # Ingest data into Kinesis with random partition key
        try:
            response = client.put_record(
                StreamName=stream_name,
                Data=json.dumps(record),
                PartitionKey=str(random.randint(1, 9999))
            )
        except botocore.exceptions.ClientError as error:
            raise error

        print(f"Record sent! Temp: {record['temperature']}", )

        # If end of data set is reached start from the beginning
        if i >= 99999:
            i=0
        else:
            i=i+1

        # Throttle data ingestion
        time.sleep(0.2)