async def run():
    # Create a producer client to send messages to the event hub.
    # Specify a connection string to your event hubs namespace and
    # the event hub name.
    producer = EventHubProducerClient.from_connection_string(
        conn_str='<connection-string>', eventhub_name='<event-hub>')
    async with producer:
        # Create a batch.
        event_data_batch = await producer.create_batch()

        # Create dummy event data
        simulation = Simulation(user_pool_size=100, sessions_per_day=100000)
        events = simulation.run(duration_seconds=60)
        for event in events:
            event_data = json.dumps(event)

            # Add events to the batch.
            event_data_batch.add(EventData(event_data))

            # Send the batch of events to the event hub.
            await producer.send_batch(event_data_batch)
Example #2
0
import boto3
import json
from fake_web_events import Simulation

client = boto3.client('kinesis')


def put_record(event):
    data = (json.dumps(event) + '\n').encode('utf-8')
    response = client.put_record(StreamName='kinesis-stream',
                                 Data=data,
                                 PartitionKey='test')
    print(event)
    return response


simulation = Simulation(user_pool_size=100, sessions_per_day=10000)
events = simulation.run(duration_seconds=300)

for event in events:
    ##print(json.dumps(event, indent=4))
    put_record(event)
Example #3
0
def create_events_file():
    simulation = Simulation(user_pool_size=100, sessions_per_day=10000)
    events = simulation.run(duration_seconds=60)

    with open('events.json', 'w') as f:
        f.write(json.dumps(list(events)))