SQLite broker and result backend implementations for the Stem runtime. Use it to embed Stem into single-node or desktop deployments without external infrastructure.
dart pub add stem_sqliteAdd the core runtime if you haven't already:
dart pub add stemimport 'dart:io';
import 'package:stem/stem.dart';
import 'package:stem_sqlite/stem_sqlite.dart';
Future<void> main() async {
final registry = SimpleTaskRegistry()
..register(
FunctionTaskHandler(
name: 'demo.sqlite',
entrypoint: (context, args) async {
print('Hello ${(args['name'] as String?) ?? 'world'}');
},
),
);
final dbFile = File('stem.db'); // or File(':memory:') for in-memory
final broker = await SqliteBroker.open(dbFile);
final backend = await SqliteResultBackend.open(dbFile);
final stem = Stem(broker: broker, backend: backend, registry: registry);
await stem.enqueue('demo.sqlite', args: {'name': 'Stem'});
}import 'dart:io';
import 'package:stem/stem.dart';
import 'package:stem_sqlite/stem_sqlite.dart';
final demoSqlite = TaskDefinition<SqliteArgs, void>(
name: 'demo.sqlite',
encodeArgs: (args) => {'name': args.name},
metadata: TaskMetadata(description: 'SQLite-backed demo task'),
);
class SqliteArgs {
const SqliteArgs({required this.name});
final String name;
}
Future<void> main() async {
final registry = SimpleTaskRegistry()
..register(
FunctionTaskHandler<void>(
name: demoSqlite.name,
entrypoint: (context, args) async {
print('Hello ${(args['name'] as String?) ?? 'world'}');
},
metadata: demoSqlite.metadata,
),
);
final dbFile = File('stem.db'); // or File(':memory:') for in-memory
final broker = await SqliteBroker.open(dbFile);
final backend = await SqliteResultBackend.open(dbFile);
final stem = Stem(broker: broker, backend: backend, registry: registry);
await stem.enqueueCall(demoSqlite(const SqliteArgs(name: 'Stem')));
}The Stem CLI can target a SQLite result backend via a connection string. When you only need backend-backed commands, set a memory broker alongside the SQLite URL:
export STEM_BROKER_URL=memory://
export STEM_RESULT_BACKEND_URL=sqlite:///absolute/path/to/stem.db
stem observe tasks show --id <task-id>Broker-required commands (enqueue, control, DLQ replay) still need a real broker URL.
The package bundles compliance tests from stem_adapter_tests. Running
dart testexecutes the shared broker and backend contract suites against the SQLite adapters.
Report issues or feature requests on the GitHub tracker. Commercial support is available via Buy Me A Coffee.
