stem_sqlite 0.1.0-alpha.4 copy "stem_sqlite: ^0.1.0-alpha.4" to clipboard
stem_sqlite: ^0.1.0-alpha.4 copied to clipboard

SQLite broker and result backend for Stem.

stem_sqlite #

pub package Dart License Buy Me A Coffee

SQLite broker and result backend implementations for the Stem runtime. Use it to embed Stem into single-node or desktop deployments without external infrastructure.

Install #

dart pub add stem_sqlite

Add the core runtime if you haven't already:

dart pub add stem

Usage #

Direct enqueue #

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

Future<void> main() async {
  final registry = SimpleTaskRegistry()
    ..register(FunctionTaskHandler(name: 'demo.sqlite', handler: print));

  final broker = await SqliteBroker.open(
    SqliteConnection.inMemory(), // or SqliteConnection.file('stem.db')
  );
  final backend = await SqliteResultBackend.open(
    SqliteConnection.inMemory(),
  );

  final stem = Stem(broker: broker, backend: backend, registry: registry);
  await stem.enqueue('demo.sqlite', args: {'name': 'Stem'});
}

Typed TaskDefinition #

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 broker = await SqliteBroker.open(SqliteConnection.inMemory());
  final backend = await SqliteResultBackend.open(SqliteConnection.inMemory());

  final stem = Stem(broker: broker, backend: backend, registry: registry);
  await stem.enqueueCall(demoSqlite(const SqliteArgs(name: 'Stem')));
}

Tests #

The package bundles compliance tests from stem_adapter_tests. Running

dart test

executes the shared broker and backend contract suites against the SQLite adapters.

Support #

Report issues or feature requests on the GitHub tracker. Commercial support is available via Buy Me A Coffee.

0
likes
120
points
250
downloads

Publisher

unverified uploader

Weekly Downloads

SQLite broker and result backend for Stem.

Repository (GitHub)
View/report issues

Documentation

API reference

License

unknown (license)

Dependencies

collection, drift, meta, path, sqlite3, stem

More

Packages that depend on stem_sqlite