Skip to content

Commit 2b45ba3

Browse files
agentofrealityAllen Jones
andauthored
feat: Update mock source config to support DataType enum with sensorC… (drasi-project#62)
* feat: Update mock source config to support DataType enum with sensorCount - Add DataTypeDto enum with Counter, SensorReading, and Generic variants - Support both string ('sensor_reading') and object ({ type: 'sensor_reading', sensor_count: 10 }) formats for dataType - Update MockSourceConfigMapper to convert DataTypeDto to domain DataType - Update interactive prompts to let users choose data type and sensor count - Update README with new mock source configuration documentation - Update config/server-docker.yaml to use valid data types - Add drasi-core and drasi-lib path patches for local development Breaking change: dataType field is now a DataTypeDto enum instead of ConfigValue<String>. Backward compatible: string values still work for simple cases. * 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 * Fix mock source and postgres bootstrap config compatibility - Update MockSourceConfigMapper to use DataType enum from drasi_source_mock - Add serde rename for sensor_count field to sensorCount for camelCase YAML - Fix PostgresBootstrapProvider to convert PostgresSourceConfig to PostgresBootstrapConfig (different types from different crates) - Update CLI prompts to use sensorReading (camelCase) for consistency - Update all example configs and tests to use camelCase field names - Update README documentation to reflect camelCase naming convention * Update crate dependencies Signed-off-by: Agent of Reality <agentx@agentofreality.com> * Fix query language Signed-off-by: Agent of Reality <agentx@agentofreality.com> * Enable inactive-people query in getting-started example - Uncomment inactive-people query with time-based triggering - Add queryLanguage: Cypher for proper parsing - Include inactive-people in log and SSE reactions * Add devcontainer configuration for development environment - Add devcontainer.json with Rust development settings - Add post-create.sh setup script * Add symlink for consistent binary access in post-create script * Simplify post-create script: remove submodule init, add OpenSSL deps * Add protobuf and clang dependencies to devcontainer post-create script * Add shared Docker network for devcontainer-to-postgres connectivity * Switch to docker-outside-of-docker for consistent container networking * Remove init.sql volume mount from docker-compose * Simplify replication slot and publication names * Add tableKeys prompt to PostgreSQL source configuration in init command * Update devcontainer: add DB_HOST env var and use cargo install * Add locations.json and improve init.sql idempotency * Add cargo install metadata files to gitignore * Use PascalCase column names in Message table for Drasi compatibility * Update all drasi crates to latest versions * Add HTTP webhook support for drasi-source-http 0.1.5 - Add comprehensive webhook DTO types (WebhookConfigDto, CorsConfigDto, ErrorBehaviorDto, WebhookRouteDto, AuthConfigDto, etc.) - Implement mapper functions for all webhook-related types - Add webhooks field to HttpSourceConfigDto - Update README with detailed webhook documentation including: - GitHub webhook example with HMAC auth - CORS configuration reference - Route, authentication, and mapping configuration docs - Add 61 new unit tests for webhook DTOs and mappers - Update Cargo.lock for latest drasi crate versions * Update examples with unique ports and dev container/codespace docs - Trading: ports 8280 (API), 9100 (HTTP), 5632 (PG), 5273 (Vite), 8281 (SSE) - Playground: ports 8380 (API), 5373 (Vite), 8381 (SSE) - Getting Started: docker-compose uses POSTGRES_HOST_PORT env var - Add dev container and Codespaces quick start options to READMEs - Update all port references in server configs, scripts, app source, docker-compose files, .http files, and documentation * Add multiple dev container configurations - Default: minimal Drasi Server dev environment for developers - Getting Started: tutorial with unique ports (8180/8181/5532) - Trading: auto-starts trading demo (8280/8281/9100/5632/5273) - Playground: auto-starts playground (8380/8381/5373) VS Code presents a picker when opening in a container. * Update webhook tests and init prompts - Expand webhook config and mapper test coverage - Update init prompts for webhook support --------- Signed-off-by: Agent of Reality <agentx@agentofreality.com> Co-authored-by: Allen Jones <allenjones@Allens-M1-MacBook-Pro.local>
1 parent 95631ba commit 2b45ba3

79 files changed

Lines changed: 3549 additions & 361 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.devcontainer/devcontainer.json

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"name": "Drasi Server Development",
3+
"image": "mcr.microsoft.com/devcontainers/rust:1-bullseye",
4+
"features": {
5+
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": {},
6+
"ghcr.io/devcontainers/features/git:1": {},
7+
"ghcr.io/devcontainers/features/common-utils:2": {
8+
"installZsh": true,
9+
"configureZshAsDefaultShell": true
10+
}
11+
},
12+
"postCreateCommand": "bash .devcontainer/post-create.sh",
13+
"forwardPorts": [8080, 8081],
14+
"portsAttributes": {
15+
"8080": {
16+
"label": "Drasi Server API",
17+
"onAutoForward": "notify"
18+
},
19+
"8081": {
20+
"label": "SSE Stream",
21+
"onAutoForward": "notify"
22+
}
23+
},
24+
"customizations": {
25+
"vscode": {
26+
"extensions": [
27+
"rust-lang.rust-analyzer",
28+
"tamasfe.even-better-toml",
29+
"humao.rest-client",
30+
"serayuzgur.crates",
31+
"vadimcn.vscode-lldb"
32+
],
33+
"settings": {
34+
"rust-analyzer.cargo.features": "all",
35+
"rust-analyzer.check.command": "clippy",
36+
"editor.formatOnSave": true
37+
}
38+
}
39+
},
40+
"remoteUser": "vscode",
41+
"containerEnv": {
42+
"RUST_BACKTRACE": "1"
43+
}
44+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
{
2+
"name": "Drasi Server - Getting Started Tutorial",
3+
"image": "mcr.microsoft.com/devcontainers/rust:1-bullseye",
4+
"features": {
5+
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": {},
6+
"ghcr.io/devcontainers/features/git:1": {},
7+
"ghcr.io/devcontainers/features/common-utils:2": {
8+
"installZsh": true,
9+
"configureZshAsDefaultShell": true
10+
}
11+
},
12+
"initializeCommand": "docker network create drasi-network 2>/dev/null || true",
13+
"postCreateCommand": "bash .devcontainer/getting-started/post-create.sh",
14+
"runArgs": ["--network=drasi-network"],
15+
"forwardPorts": [8180, 8181, 5532],
16+
"portsAttributes": {
17+
"8180": {
18+
"label": "Drasi Server API",
19+
"onAutoForward": "notify"
20+
},
21+
"8181": {
22+
"label": "SSE Stream",
23+
"onAutoForward": "notify"
24+
},
25+
"5532": {
26+
"label": "PostgreSQL",
27+
"onAutoForward": "silent"
28+
}
29+
},
30+
"customizations": {
31+
"vscode": {
32+
"extensions": [
33+
"rust-lang.rust-analyzer",
34+
"tamasfe.even-better-toml",
35+
"humao.rest-client",
36+
"serayuzgur.crates",
37+
"vadimcn.vscode-lldb"
38+
],
39+
"settings": {
40+
"rust-analyzer.cargo.features": "all",
41+
"rust-analyzer.check.command": "clippy",
42+
"editor.formatOnSave": true
43+
}
44+
}
45+
},
46+
"remoteUser": "vscode",
47+
"containerEnv": {
48+
"RUST_BACKTRACE": "1",
49+
"DB_HOST": "getting-started-postgres",
50+
"SERVER_PORT": "8180",
51+
"SSE_PORT": "8181",
52+
"POSTGRES_PORT": "5532",
53+
"POSTGRES_HOST_PORT": "5532"
54+
}
55+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/bash
2+
# Post-create script for Drasi Server Getting Started tutorial
3+
4+
set -e
5+
6+
echo "🔧 Initializing Drasi Server Getting Started tutorial environment..."
7+
8+
# Ensure the shared Docker network exists (for connecting to PostgreSQL container)
9+
echo "🌐 Creating shared Docker network..."
10+
docker network create drasi-network 2>/dev/null || true
11+
12+
# Install system dependencies
13+
echo "🐘 Installing system dependencies (PostgreSQL client, OpenSSL, Protobuf, Clang)..."
14+
sudo apt-get update && sudo apt-get install -y \
15+
postgresql-client \
16+
libssl-dev \
17+
pkg-config \
18+
protobuf-compiler \
19+
clang \
20+
libclang-dev
21+
22+
# Build and install Drasi Server
23+
echo "🔨 Building Drasi Server (this may take a few minutes)..."
24+
cargo install --path . --root . --locked
25+
26+
# Make scripts executable
27+
if [ -d "examples/getting-started/scripts" ]; then
28+
echo "📜 Making example scripts executable..."
29+
chmod +x examples/getting-started/scripts/*.sh
30+
fi
31+
32+
echo ""
33+
echo "✅ Drasi Server Getting Started tutorial environment is ready!"
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{
2+
"name": "Drasi Server - Playground",
3+
"image": "mcr.microsoft.com/devcontainers/rust:1-bullseye",
4+
"features": {
5+
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": {},
6+
"ghcr.io/devcontainers/features/git:1": {},
7+
"ghcr.io/devcontainers/features/common-utils:2": {
8+
"installZsh": true,
9+
"configureZshAsDefaultShell": true
10+
},
11+
"ghcr.io/devcontainers/features/node:1": {
12+
"version": "22"
13+
}
14+
},
15+
"postCreateCommand": "bash .devcontainer/playground/post-create.sh",
16+
"forwardPorts": [8380, 5373],
17+
"portsAttributes": {
18+
"8380": {
19+
"label": "Drasi Server API",
20+
"onAutoForward": "notify"
21+
},
22+
"5373": {
23+
"label": "Playground App",
24+
"onAutoForward": "notify"
25+
}
26+
},
27+
"customizations": {
28+
"vscode": {
29+
"extensions": [
30+
"rust-lang.rust-analyzer",
31+
"tamasfe.even-better-toml",
32+
"humao.rest-client",
33+
"serayuzgur.crates",
34+
"vadimcn.vscode-lldb"
35+
],
36+
"settings": {
37+
"rust-analyzer.cargo.features": "all",
38+
"rust-analyzer.check.command": "clippy",
39+
"editor.formatOnSave": true
40+
}
41+
}
42+
},
43+
"remoteUser": "vscode",
44+
"containerEnv": {
45+
"RUST_BACKTRACE": "1"
46+
}
47+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash
2+
# Post-create script for Drasi Server Playground
3+
4+
set -e
5+
6+
echo "🔧 Initializing Drasi Server Playground environment..."
7+
8+
# Install system dependencies
9+
echo "📦 Installing system dependencies (OpenSSL, Protobuf, Clang)..."
10+
sudo apt-get update && sudo apt-get install -y \
11+
libssl-dev \
12+
pkg-config \
13+
protobuf-compiler \
14+
clang \
15+
libclang-dev
16+
17+
# Build Drasi Server
18+
echo "🔨 Building Drasi Server (this may take a few minutes)..."
19+
cargo build --release
20+
21+
# Make scripts executable
22+
chmod +x examples/playground/start.sh examples/playground/stop.sh
23+
24+
# Start the playground in background
25+
echo "🚀 Starting Playground..."
26+
nohup bash examples/playground/start.sh > /tmp/playground-startup.log 2>&1 &
27+
28+
echo ""
29+
echo "✅ Drasi Server Playground is starting!"
30+
echo " Check startup progress: tail -f /tmp/playground-startup.log"
31+
echo " Playground App: http://localhost:5373"
32+
echo " Drasi API: http://localhost:8380"

.devcontainer/post-create.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/bash
2+
# Post-create script for Drasi Server default development environment
3+
4+
set -e
5+
6+
echo "🔧 Initializing Drasi Server development environment..."
7+
8+
# Install system dependencies
9+
echo "📦 Installing system dependencies (OpenSSL, Protobuf, Clang)..."
10+
sudo apt-get update && sudo apt-get install -y \
11+
libssl-dev \
12+
pkg-config \
13+
protobuf-compiler \
14+
clang \
15+
libclang-dev
16+
17+
# Build Drasi Server
18+
echo "🔨 Building Drasi Server (this may take a few minutes)..."
19+
cargo build
20+
21+
echo ""
22+
echo "✅ Drasi Server development environment is ready!"
23+
echo ""
24+
echo "Getting started:"
25+
echo " cargo run -- --config <your-config.yaml>"
26+
echo " cargo test"
27+
echo ""
28+
echo "See examples/ for sample configurations."
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
{
2+
"name": "Drasi Server - Trading Demo",
3+
"image": "mcr.microsoft.com/devcontainers/rust:1-bullseye",
4+
"features": {
5+
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": {},
6+
"ghcr.io/devcontainers/features/git:1": {},
7+
"ghcr.io/devcontainers/features/common-utils:2": {
8+
"installZsh": true,
9+
"configureZshAsDefaultShell": true
10+
},
11+
"ghcr.io/devcontainers/features/node:1": {
12+
"version": "22"
13+
},
14+
"ghcr.io/devcontainers/features/python:2": {
15+
"version": "3.12"
16+
}
17+
},
18+
"initializeCommand": "docker network create drasi-network 2>/dev/null || true",
19+
"postCreateCommand": "bash .devcontainer/trading/post-create.sh",
20+
"runArgs": ["--network=drasi-network"],
21+
"forwardPorts": [8280, 9100, 5632, 5273],
22+
"portsAttributes": {
23+
"8280": {
24+
"label": "Drasi Server API",
25+
"onAutoForward": "notify"
26+
},
27+
"9100": {
28+
"label": "HTTP Source",
29+
"onAutoForward": "silent"
30+
},
31+
"5632": {
32+
"label": "PostgreSQL",
33+
"onAutoForward": "silent"
34+
},
35+
"5273": {
36+
"label": "Trading App",
37+
"onAutoForward": "notify"
38+
}
39+
},
40+
"customizations": {
41+
"vscode": {
42+
"extensions": [
43+
"rust-lang.rust-analyzer",
44+
"tamasfe.even-better-toml",
45+
"humao.rest-client",
46+
"serayuzgur.crates",
47+
"vadimcn.vscode-lldb"
48+
],
49+
"settings": {
50+
"rust-analyzer.cargo.features": "all",
51+
"rust-analyzer.check.command": "clippy",
52+
"editor.formatOnSave": true
53+
}
54+
}
55+
},
56+
"remoteUser": "vscode",
57+
"containerEnv": {
58+
"RUST_BACKTRACE": "1"
59+
}
60+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/bin/bash
2+
# Post-create script for Drasi Server Trading Demo
3+
4+
set -e
5+
6+
echo "🔧 Initializing Drasi Server Trading Demo environment..."
7+
8+
# Ensure the shared Docker network exists
9+
echo "🌐 Creating shared Docker network..."
10+
docker network create drasi-network 2>/dev/null || true
11+
12+
# Install system dependencies
13+
echo "📦 Installing system dependencies (PostgreSQL client, OpenSSL, Protobuf, Clang)..."
14+
sudo apt-get update && sudo apt-get install -y \
15+
postgresql-client \
16+
libssl-dev \
17+
pkg-config \
18+
protobuf-compiler \
19+
clang \
20+
libclang-dev
21+
22+
# Build Drasi Server
23+
echo "🔨 Building Drasi Server (this may take a few minutes)..."
24+
cargo build --release
25+
26+
# Install Python dependencies for price generator
27+
echo "🐍 Installing Python dependencies..."
28+
pip3 install requests
29+
30+
# Make scripts executable
31+
chmod +x examples/trading/start-demo.sh examples/trading/stop-demo.sh
32+
33+
# Start the trading demo in background
34+
echo "🚀 Starting Trading Demo..."
35+
nohup bash examples/trading/start-demo.sh > /tmp/trading-demo-startup.log 2>&1 &
36+
37+
echo ""
38+
echo "✅ Drasi Server Trading Demo is starting!"
39+
echo " Check startup progress: tail -f /tmp/trading-demo-startup.log"
40+
echo " Trading App: http://localhost:5273"
41+
echo " Drasi API: http://localhost:8280"

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,7 @@ logs/
2828

2929
# Exception: Allow .env files in examples (for tutorials)
3030
!examples/**/.env
31+
32+
# Cargo install metadata
33+
.crates.toml
34+
.crates2.json

0 commit comments

Comments
 (0)