stem 0.1.0-alpha.2 copy "stem: ^0.1.0-alpha.2" to clipboard
stem: ^0.1.0-alpha.2 copied to clipboard

Stem is a Dart-native background job platform with Redis Streams, retries, scheduling, observability, and security tooling.

example/stem_example.dart

import 'dart:async';
import 'package:stem/stem.dart';

class HelloTask implements TaskHandler<void> {
  @override
  String get name => 'demo.hello';

  @override
  TaskOptions get options => const TaskOptions(
    queue: 'default',
    maxRetries: 3,
    rateLimit: '10/s',
    visibilityTimeout: Duration(seconds: 60),
  );

  @override
  Future<void> call(TaskContext context, Map<String, Object?> args) async {
    final who = args['name'] as String? ?? 'world';
    print('Hello $who (attempt ${context.attempt})');
  }

  @override
  TaskEntrypoint? get isolateEntrypoint => null;
}

Future<void> main() async {
  final registry = SimpleTaskRegistry()..register(HelloTask());
  final broker = await RedisStreamsBroker.connect('redis://localhost:6379');
  final backend = await RedisResultBackend.connect('redis://localhost:6379/1');

  final stem = Stem(broker: broker, registry: registry, backend: backend);
  final worker = Worker(broker: broker, registry: registry, backend: backend);

  unawaited(worker.start());
  await stem.enqueue('demo.hello', args: {'name': 'Stem'});
  await Future<void>.delayed(const Duration(seconds: 1));
  await worker.shutdown();
  await broker.close();
  await backend.close();
}
0
likes
140
points
26
downloads

Publisher

unverified uploader

Weekly Downloads

Stem is a Dart-native background job platform with Redis Streams, retries, scheduling, observability, and security tooling.

Repository (GitHub)

Topics

#background-processing #message-queue #redis #observability

Documentation

API reference

License

MIT (license)

Dependencies

args, collection, contextual, crypto, cryptography, dartastic_opentelemetry, dartastic_opentelemetry_api, glob, path, postgres, redis, timezone, yaml

More

Packages that depend on stem