EventKit

EventKit is a comprehensive collection of command-line tools designed for testing and interacting with various protocols and event brokers. It provides unified interfaces for CoAP, MQTT, NATS, Kafka, HTTP, Redis, Google Pub/Sub, PostgreSQL, MongoDB, and Git, making it ideal for testing event-driven systems, debugging message flows, and performance evaluation.
Features
β
Multi-Protocol Support - Works with 10 different protocols and event brokers
β
Payload Interpolation - Dynamic payload generation with variables like {nowtime}, {uuid}, {json}
β
MIME Type Support - Handles text/plain, application/json, and application/cbor
β
Graceful Shutdown - Proper signal handling (SIGINT/SIGTERM) for clean exits
β
Periodic Messaging - Send messages at configurable intervals
β
Performance Testing - Built-in timing and throughput measurement
β
Flexible CLI - Consistent command-line interface across all tools
Installation
Install all tools:
go install github.com/sandrolain/eventkit/...@latest
Or install individual tools:
go install github.com/sandrolain/eventkit/coaptool@latest
go install github.com/sandrolain/eventkit/mqtttool@latest
go install github.com/sandrolain/eventkit/natstool@latest
go install github.com/sandrolain/eventkit/kafkatool@latest
go install github.com/sandrolain/eventkit/httptool@latest
go install github.com/sandrolain/eventkit/redistool@latest
go install github.com/sandrolain/eventkit/pubsubtool@latest
go install github.com/sandrolain/eventkit/pgsqltool@latest
go install github.com/sandrolain/eventkit/mongotool@latest
go install github.com/sandrolain/eventkit/gittool@latest
Test CoAP (Constrained Application Protocol) servers - ideal for IoT and constrained environments.
# Send POST requests periodically
coaptool send --server coap://localhost:5683 --path /sensors --payload '{"temp": {rand}}' --interval 5s
# Receive CoAP requests
coaptool receive --address :5683 --path /sensors
Key Options:
--server - CoAP server URL (e.g., coap://host:port)
--path - Resource path
Test MQTT brokers with publish/subscribe messaging.
# Publish messages to topic
mqtttool send --server tcp://localhost:1883 --topic sensors/temperature --payload '{"value": {rand}}' --interval 5s
# Subscribe to topic
mqtttool receive --server tcp://localhost:1883 --topic sensors/#
Key Options:
--server - MQTT broker URL (tcp://host:port)
--topic - MQTT topic (supports wildcards in receive: +, #)
--qos - Quality of Service (0, 1, 2)
Test NATS messaging systems with subject-based routing.
# Publish to subject
natstool send --server nats://localhost:4222 --topic events.user.created --payload '{"id": "{uuid}"}' --interval 5s
# Subscribe to subject pattern
natstool receive --server nats://localhost:4222 --topic events.user.*
Key Options:
--server - NATS server URL (nats://host:port)
--topic - NATS subject (supports wildcards: *, >)
Test Apache Kafka with producer/consumer operations.
# Produce messages
kafkatool send --server localhost:9092 --topic user-events --payload '{"action": "login", "time": "{nowtime}"}' --interval 10s
# Consume messages from topic
kafkatool receive --server localhost:9092 --topic user-events --group my-consumer-group
Key Options:
--server - Kafka broker address (host:port)
--topic - Kafka topic name
--group - Consumer group ID (for receive)
--partition - Specific partition (optional)
Test HTTP endpoints with POST requests or run simple HTTP servers.
# Send POST requests
httptool send --dest http://localhost:8080/api/events --payload '{"type": "test", "ts": "{nowtime}"}' --interval 5s
# Start HTTP server to receive requests
httptool receive --address :8080 --path /api/events
Key Options:
--dest - Destination URL (for send)
--address - Listen address (for receive)
--path - HTTP path
--method - HTTP method (default: POST)
Test Redis Pub/Sub messaging.
# Publish to channel
redistool send --server localhost:6379 --topic notifications --payload '{"msg": "Hello", "time": "{nowtime}"}' --interval 5s
# Subscribe to channel
redistool receive --server localhost:6379 --topic notifications
Key Options:
--server - Redis server address (host:port)
--topic - Redis channel name
--password - Redis password (optional)
Test Google Cloud Pub/Sub messaging.
# Publish messages
pubsubtool send --project my-gcp-project --topic events-topic --payload '{"event": "click", "user": "{uuid}"}' --interval 5s
# Subscribe to messages
pubsubtool receive --project my-gcp-project --subscription events-sub
Key Options:
--project - GCP project ID
--topic - Pub/Sub topic name (for send)
--subscription - Subscription name (for receive)
π PostgreSQL Tool
Test PostgreSQL LISTEN/NOTIFY for async notifications.
# Send notifications
pgsqltool send --conn "postgres://user:pass@localhost/mydb" --channel app-events --payload '{"type": "update"}' --interval 10s
# Listen for notifications
pgsqltool receive --conn "postgres://user:pass@localhost/mydb" --channel app-events
Key Options:
--conn - PostgreSQL connection string
--channel - NOTIFY channel name
Test MongoDB with document insertion and Change Streams monitoring.
# Insert documents periodically
mongotool send --server mongodb://localhost:27017 --database testdb --collection events \
--payload '{"type": "sensor", "value": {rand}, "timestamp": "{nowtime}"}' --interval 5s
# Watch Change Streams for real-time updates
mongotool serve --server mongodb://localhost:27017 --database testdb --collection events
Key Options:
--server - MongoDB connection string (mongodb://host:port)
--database - Database name
--collection - Collection name
--username - MongoDB username (optional)
--password - MongoDB password (optional)
Note: Change Streams require a MongoDB replica set. The tool automatically adds an _insertedAt timestamp to each document.
Automated Git commits for testing CI/CD pipelines or Git hooks.
# Periodic commits to repository
gittool send \
--remote https://github.com/user/test-repo.git \
--branch main \
--filename data.log \
--payload "Automated update at {nowtime}" \
--message "Auto-commit from eventkit" \
--interval 30s
Key Options:
--remote - Git repository URL
--branch - Target branch (default: main)
--filename - File to modify
--message - Commit message
--username, --password - Authentication (for HTTPS)
Payload Interpolation
All tools support dynamic payload generation with interpolation variables:
| Variable |
Description |
Example Output |
{json} |
Random JSON object |
{"key1":"val","key2":123} |
{cbor} |
Random CBOR data |
Binary CBOR-encoded data |
{nowtime} |
Current timestamp (RFC3339) |
2024-01-15T14:30:00Z |
{nowunix} |
Unix timestamp |
1705329000 |
{rand} |
Random integer |
42857291 |
{uuid} |
UUID v4 |
550e8400-e29b-41d4-a716-446655440000 |
Example Usage:
mqtttool send \
--server tcp://localhost:1883 \
--topic sensors/data \
--payload '{"id": "{uuid}", "timestamp": "{nowtime}", "value": {rand}}' \
--mime application/json \
--interval 5s
Common Options
All send commands support these options:
--interval - Time between messages (e.g., 10s, 1m, 5m30s, 1h)
--payload - Message content (supports interpolation variables)
--mime - MIME type (text/plain, application/json, application/cbor)
--size - Payload size for auto-generated content (in bytes)
Flag aliases for server/destination (all tools accept both):
--server / --address / --broker / --conn (deprecated)
--dest / --destination / --remote (deprecated)
Use Cases
IoT Testing
# Simulate temperature sensor
coaptool send --server coap://iot.example.com:5683 --path /sensors/temp \
--payload '{"device": "sensor-01", "temp": {rand}, "time": "{nowtime}"}' --interval 30s
Microservices Events
# Publish user events to Kafka
kafkatool send --server kafka.local:9092 --topic user.events \
--payload '{"user_id": "{uuid}", "action": "login", "ts": "{nowunix}"}' --interval 2s
CI/CD Pipeline Testing
# Trigger Git commits for testing webhooks
gittool send --remote https://github.com/org/test.git --branch develop \
--filename ci-test.txt --payload "Test run {uuid}" --interval 1m
Database Async Notifications
# PostgreSQL event notification
pgsqltool send --conn "postgres://app:secret@db:5432/events" \
--channel cache-invalidate --payload '{"table": "users", "id": {rand}}'
Real-Time Data Monitoring
# Monitor MongoDB Change Streams
mongotool serve --server mongodb://localhost:27017 --database myapp --collection logs
# Generate test data
mongotool send --server mongodb://localhost:27017 --database myapp --collection logs \
--payload '{"level": "info", "msg": "Test event {uuid}", "time": "{nowtime}"}' --interval 3s
Development
Requirements
- Go 1.25 or higher
- Protocol-specific services (MQTT broker, NATS server, etc.) for testing
Running Tests
# Run all tests
go test ./...
# Run with coverage
go test -cover ./...
# Run linter
golangci-lint run ./...
Project Structure
eventkit/
βββ pkg/
β βββ common/ # Shared utilities (signal handling, CLI helpers)
β βββ testpayload/ # Payload generation and interpolation
β βββ toolutil/ # Common tool functions (formatting, flags)
βββ coaptool/ # CoAP tool
βββ mqtttool/ # MQTT tool
βββ natstool/ # NATS tool
βββ kafkatool/ # Kafka tool
βββ httptool/ # HTTP tool
βββ redistool/ # Redis tool
βββ pubsubtool/ # Google Pub/Sub tool
βββ pgsqltool/ # PostgreSQL tool
βββ mongotool/ # MongoDB tool
βββ gittool/ # Git tool
Contributing
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature)
- Write tests for your changes
- Ensure all tests pass and coverage is β₯80%
- Run linter:
golangci-lint run ./...
- Commit using conventional commits format (
feat:, fix:, etc.)
- Push to the branch
- Open a Pull Request
For major changes, please open an issue first to discuss what you would like to change.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
Built with:
EventKit - Making event-driven system testing simple and efficient.