Skip to content

Commit ac76bdb

Browse files
refactor: Use enum-only format for mock source dataType config
- Remove string format support and custom deserializer for dataType - DataType now requires object format: { type: counter|sensor_reading|generic } - sensor_reading supports sensor_count parameter (default: 5) - Update all example configs to use enum format - Update README documentation - Update all tests
1 parent 823e18a commit ac76bdb

24 files changed

Lines changed: 118 additions & 120 deletions

README.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -351,17 +351,18 @@ sources:
351351

352352
Generates synthetic test data for development and demonstrations. Supports three data types with configurable generation intervals.
353353

354-
**Simple string format:**
354+
**Configuration format:**
355355
```yaml
356356
sources:
357357
- kind: mock
358358
id: test-source
359359
autoStart: true
360-
dataType: sensor_reading # or "counter", "generic"
360+
dataType:
361+
type: generic # or "counter", "sensor_reading"
361362
intervalMs: 2000
362363
```
363364

364-
**Object format with sensor count:**
365+
**Sensor reading with custom sensor count:**
365366
```yaml
366367
sources:
367368
- kind: mock
@@ -375,16 +376,16 @@ sources:
375376

376377
| Field | Type | Default | Description |
377378
|-------|------|---------|-------------|
378-
| `dataType` | string or object | `generic` | Type of mock data (see below) |
379+
| `dataType` | object | `{ type: generic }` | Type of mock data (see below) |
379380
| `intervalMs` | integer | `5000` | Data generation interval in milliseconds |
380381

381382
**Data Types:**
382383

383-
| Type | String Value | Generated Nodes | Properties |
384-
|------|--------------|-----------------|------------|
385-
| Counter | `counter` | `Counter` | `value` (sequential int), `timestamp` |
386-
| Sensor Reading | `sensor_reading` or `sensor` | `SensorReading` | `sensor_id`, `temperature` (20-30°C), `humidity` (40-60%), `timestamp` |
387-
| Generic | `generic` | `Generic` | `value` (random int), `message`, `timestamp` |
384+
| Type | Value | Generated Nodes | Properties |
385+
|------|-------|-----------------|------------|
386+
| Counter | `{ type: counter }` | `Counter` | `value` (sequential int), `timestamp` |
387+
| Sensor Reading | `{ type: sensor_reading, sensor_count: N }` | `SensorReading` | `sensor_id`, `temperature` (20-30°C), `humidity` (40-60%), `timestamp` |
388+
| Generic | `{ type: generic }` | `Generic` | `value` (random int), `message`, `timestamp` |
388389

389390
**Sensor Reading Behavior:**
390391
- First reading for each sensor generates an **INSERT** event

config/server-docker.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ sources:
2020
- id: order-status-source
2121
autoStart: true
2222
kind: mock
23-
dataType: generic
23+
dataType:
24+
type: generic
2425
intervalMs: 3000
2526

2627
queries:

examples/configs/01-fundamentals/first-continuous-query.yaml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,16 @@ logLevel: info
3434
persistConfig: false
3535

3636
sources:
37-
# Mock source generates data with labels based on dataType:
38-
# - "sensor" → SensorReading nodes with temperature, humidity, sensor_id
39-
# - "counter" → Counter nodes with count value
40-
# - "generic" → Generic nodes with value and message
37+
# Mock source generates data with labels based on dataType enum:
38+
# - { type: sensor_reading, sensor_count: N } → SensorReading nodes with temperature, humidity, sensor_id
39+
# First reading per sensor = INSERT, subsequent readings = UPDATE
40+
# - { type: counter } → Counter nodes with sequential count value (always INSERT)
41+
# - { type: generic } → Generic nodes with random value and message (always INSERT)
4142
- kind: mock
4243
id: sensor-data
4344
autoStart: true
44-
dataType: "sensor"
45+
dataType:
46+
type: sensor_reading
4547
intervalMs: 2000
4648

4749
queries:

examples/configs/01-fundamentals/hello-world.yaml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,21 @@ logLevel: info
3737
persistConfig: false
3838

3939
# A simple mock source that generates test data
40-
# dataType options: "sensor" (Sensor), "counter" (Counter), "generic" (Generic)
40+
# dataType is an enum with the following options:
41+
# - { type: sensor_reading, sensor_count: N } - SensorReading nodes with sensor_id, temperature, humidity
42+
# (first reading per sensor = INSERT, subsequent = UPDATE, default sensor_count: 5)
43+
# - { type: counter } - Counter nodes with sequential value
44+
# - { type: generic } - Generic nodes with random value and message
4145
sources:
4246
- kind: mock
4347
id: test-source
4448
autoStart: true
45-
dataType: "sensor"
49+
dataType:
50+
type: sensor_reading
4651
intervalMs: 3000
4752

4853
# A query that matches all data from the source
49-
# Note: The mock source with dataType "sensor" generates SensorReading nodes
54+
# Note: The mock source with type: sensor_reading generates SensorReading nodes
5055
queries:
5156
- id: all-sensors
5257
autoStart: true

examples/configs/01-fundamentals/mock-with-logging.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ sources:
4040
- kind: mock
4141
id: data-generator
4242
autoStart: true
43-
dataType: "generic"
43+
dataType:
44+
type: generic
4445
intervalMs: 3000
4546

4647
queries:

examples/configs/03-reactions/grpc-streaming-reaction.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ sources:
4545
- kind: mock
4646
id: events
4747
autoStart: true
48-
dataType: "generic"
48+
dataType:
49+
type: generic
4950
intervalMs: 500
5051

5152
queries:

examples/configs/03-reactions/http-webhook-sender.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ sources:
4949
- kind: mock
5050
id: orders
5151
autoStart: true
52-
dataType: "generic"
52+
dataType:
53+
type: generic
5354
intervalMs: 3000
5455

5556
queries:

examples/configs/03-reactions/log-with-templates.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ sources:
4444
- kind: mock
4545
id: events
4646
autoStart: true
47-
dataType: "generic"
47+
dataType:
48+
type: generic
4849
intervalMs: 2000
4950

5051
queries:

examples/configs/03-reactions/profiler-performance.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ sources:
4949
- kind: mock
5050
id: high-volume
5151
autoStart: true
52-
dataType: "generic"
52+
dataType:
53+
type: generic
5354
intervalMs: 100
5455

5556
queries:

examples/configs/03-reactions/sse-browser-streaming.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,12 @@ persistConfig: false
4747

4848
sources:
4949
# Mock source generates SensorReading nodes with temperature, humidity, sensor_id
50+
# First reading per sensor = INSERT, subsequent = UPDATE
5051
- kind: mock
5152
id: live-data
5253
autoStart: true
53-
dataType: "sensor"
54+
dataType:
55+
type: sensor_reading
5456
intervalMs: 1000
5557

5658
queries:

0 commit comments

Comments
 (0)