|
1 | | -# loom |
| 1 | +# Loom |
| 2 | + |
| 3 | +A lightweight, flexible worker pool framework for Dart applications. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +Loom provides a robust foundation for managing concurrent task execution with: |
| 8 | + |
| 9 | +- **Priority-based scheduling** - Critical tasks run first |
| 10 | +- **Automatic retry** - Configurable retry policies with backoff |
| 11 | +- **Graceful cancellation** - Cancel queued or running jobs |
| 12 | +- **Progress reporting** - Real-time progress streams |
| 13 | +- **Multiple execution modes** - Main isolate, background isolates, or test mode |
| 14 | +- **Lifecycle hooks** - Monitor pool activity |
| 15 | + |
| 16 | +## Packages |
| 17 | + |
| 18 | +| Package | Description | |
| 19 | +|---------|-------------| |
| 20 | +| [loom](packages/loom/) | Core worker pool framework | |
| 21 | + |
| 22 | +## Getting Started |
| 23 | + |
| 24 | +### Prerequisites |
| 25 | + |
| 26 | +- Dart SDK ^3.10.7 |
| 27 | +- [Melos](https://melos.invertase.dev/) for monorepo management |
| 28 | + |
| 29 | +### Setup |
| 30 | + |
| 31 | +```bash |
| 32 | +# Install melos globally |
| 33 | +dart pub global activate melos |
| 34 | + |
| 35 | +# Bootstrap the workspace |
| 36 | +melos bootstrap |
| 37 | +``` |
| 38 | + |
| 39 | +### Common Commands |
| 40 | + |
| 41 | +```bash |
| 42 | +# Run all tests |
| 43 | +melos run test |
| 44 | + |
| 45 | +# Run analyzer |
| 46 | +melos run analyze |
| 47 | + |
| 48 | +# Format code |
| 49 | +melos run format |
| 50 | + |
| 51 | +# Run all checks (analyze + format + test) |
| 52 | +melos run check |
| 53 | + |
| 54 | +# Run performance tests |
| 55 | +melos run test:perf |
| 56 | + |
| 57 | +# Run example |
| 58 | +melos run run:example |
| 59 | +``` |
| 60 | + |
| 61 | +## Quick Example |
| 62 | + |
| 63 | +```dart |
| 64 | +import 'package:loom/loom.dart'; |
| 65 | +
|
| 66 | +void main() async { |
| 67 | + // Define a task |
| 68 | + final task = Task<String, int>.simple( |
| 69 | + name: 'parseNumber', |
| 70 | + executor: (input, ctx) async => int.parse(input), |
| 71 | + ); |
| 72 | +
|
| 73 | + // Create a pool |
| 74 | + final pool = WorkerPool.io('my-pool'); |
| 75 | +
|
| 76 | + // Submit work |
| 77 | + final handle = pool.submit(task, '42'); |
| 78 | + final result = await handle.result; |
| 79 | +
|
| 80 | + print('Parsed: ${result.valueOrThrow}'); // 42 |
| 81 | +
|
| 82 | + await pool.shutdown(); |
| 83 | +} |
| 84 | +``` |
| 85 | + |
| 86 | +## Documentation |
| 87 | + |
| 88 | +- [Loom Package README](packages/loom/README.md) |
| 89 | +- [API Documentation](packages/loom/doc/) |
| 90 | + |
| 91 | +## Contributing |
| 92 | + |
| 93 | +1. Fork the repository |
| 94 | +2. Create a feature branch |
| 95 | +3. Make your changes |
| 96 | +4. Run `melos run check` to verify |
| 97 | +5. Submit a pull request |
| 98 | + |
| 99 | +## License |
| 100 | + |
| 101 | +See [LICENSE](LICENSE) for details. |
0 commit comments