Subscribes to devices/+/telemetry, validates payloads, buffers writes into ClickHouse (flush on size or interval), and emits a per-reading event on RabbitMQ for rule-engine-service to consume later. Adds the initial Postgres and ClickHouse schema migrations, a Dockerfile, and wires the service into docker-compose. Verified end-to-end via docker compose + mosquitto_pub: row lands in ClickHouse and the event reaches the telemetry.new_reading queue. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
10 lines
255 B
SQL
10 lines
255 B
SQL
CREATE TABLE IF NOT EXISTS telemetry.telemetry (
|
|
device_id String,
|
|
zone_id String,
|
|
sensor_type String,
|
|
value Float64,
|
|
recorded_at DateTime,
|
|
received_at DateTime
|
|
) ENGINE = MergeTree()
|
|
ORDER BY (device_id, recorded_at);
|