eventkit

module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 14, 2025 License: MIT

README ΒΆ

EventKit

Go Version License Go Report Card

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

Available Tools

πŸ”΅ CoAP Tool

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
πŸ“‘ MQTT Tool

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)
⚑ NATS Tool

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: *, >)
πŸ“¨ Kafka Tool

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)
🌐 HTTP Tool

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)
πŸ”΄ Redis Tool

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)
☁️ Google Pub/Sub Tool

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
πŸƒ MongoDB Tool

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.

πŸ“¦ Git Tool

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:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Write tests for your changes
  4. Ensure all tests pass and coverage is β‰₯80%
  5. Run linter: golangci-lint run ./...
  6. Commit using conventional commits format (feat:, fix:, etc.)
  7. Push to the branch
  8. 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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL