Learn LedgerQ through runnable examples. Start with simple and progress through features.
- simple - Basic enqueue/dequeue operations ⭐ Start here!
- producer-consumer - Concurrent access patterns
- ttl - Message expiration with time-to-live
- headers - Message metadata and key-value pairs
- replay - Seeking and time-travel through message history
- streaming - Real-time event processing with push-based API
- priority - Priority ordering (v1.1.0)
- dlq - Dead Letter Queue and retry handling (v1.2.0)
- compression - Payload compression with GZIP (v1.3.0)
- deduplication - Idempotent message processing (v1.4.0)
- metrics - Monitoring and observability
All examples are self-contained with clear output:
cd examples/simple
go run main.go| Example | Feature | Use Case |
|---|---|---|
| simple | Basic ops | First-time users |
| producer-consumer | Concurrency | Multi-threaded processing |
| ttl | Expiration | Temporary messages, caches |
| headers | Metadata | Message tagging, routing |
| replay | Seeking | Reprocessing, debugging |
| streaming | Real-time | Event-driven architectures |
| priority | Ordering | Urgent task processing |
| dlq | Failures | Error handling, retries |
| compression | Disk saving | Large payloads (JSON, logs) |
| deduplication | Idempotency | Exactly-once semantics |
| metrics | Monitoring | Production observability |
Each example demonstrates:
- Setup: How to configure the queue
- Core API: Key operations for that feature
- Output: What you'll see when running
- Use cases: When to use this pattern
- Documentation: See docs/USAGE.md for complete API reference
- Issues: Report problems at https://github.com/1mb-dev/ledgerq/issues
- Questions: Check existing issues or open a discussion
Found a useful pattern? Consider contributing an example:
- Create directory:
examples/your-feature/ - Add
main.gowith clear comments - Add
README.mdfollowing our template (seestreaming/README.md) - Update this index
- Submit PR
Total Examples: 11 | Difficulty: 🟢 Beginner → 🟡 Intermediate → 🔴 Advanced