Пример #1
0
import os
import time

from classes.CKafkaPC import KafkaPC

print("start 1p_count_up")

env_vars = {
    "config_path": os.getenv("config_path"),
    "config_section": os.getenv("config_section"),
}

new_p = KafkaPC(**env_vars)

for i in range(10):

    message = {"count": i * 2}
    new_p.send_msg(message)
    print(f"Sent message {i} with count={i*2}")
    time.sleep(1)
Пример #2
0
            "rmse": msgdata["rmse"],
            "CPU_ms": msgdata["CPU_ms"],
            "RAM": msgdata["RAM"],
        },
    }

    new_c.send_msg(new_data_point)
    print("model application message sent")


env_vars = {
    "config_path": os.getenv("config_path"),
    "config_section": os.getenv("config_section"),
}

new_c = KafkaPC(**env_vars)

plot_dict = new_c.config["PLOT_TOPIC"]

try:
    while True:
        msg = new_c.consumer.poll(0.1)

        if msg is None:
            continue

        elif msg.error() is not None:
            print(f"Error occured: {str(msg.error())}")

        else:
            # tests if msg.topic is in plot_dict and calls function from dict