durable_workflow_sqlite 0.2.0 copy "durable_workflow_sqlite: ^0.2.0" to clipboard
durable_workflow_sqlite: ^0.2.0 copied to clipboard

SQLite implementation of CheckpointStore for durable_workflow. Uses sqlite3 FFI for high-performance local persistence.

example/example.dart

/// Example: Durable workflow with SQLite persistence.
///
/// Demonstrates running a checkpoint/resume workflow backed by
/// an on-disk SQLite database.
///
/// Run with:
///   dart run example/sqlite_workflow.dart
library;

import 'package:durable_workflow/durable_workflow.dart';
import 'package:durable_workflow_sqlite/durable_workflow_sqlite.dart';

Future<void> main() async {
  // Open an in-memory SQLite database for this demo.
  // In production, pass a file path: SqliteCheckpointStore('workflow.db')
  final store = SqliteCheckpointStore.inMemory();

  final engine = DurableEngineImpl(
    store: store,
    timerPollInterval: const Duration(milliseconds: 100),
  );

  try {
    final result = await engine.run<String>(
      'order_processing',
      (ctx) async {
        await ctx.step<bool>('validate', () async {
          print('  [validate] Checking order...');
          return true;
        });

        final paymentId = await ctx.step<String>(
          'pay',
          () async {
            print('  [pay] Charging payment...');
            return 'PAY-001';
          },
          compensate: (_) async {
            print('  [pay:compensate] Refunding...');
          },
        );

        return 'Completed with payment: $paymentId';
      },
    );

    print('Workflow result: $result');
  } finally {
    engine.dispose();
    store.close();
  }
}
0
likes
140
points
32
downloads

Documentation

API reference

Publisher

verified publisherbrodykim.work

Weekly Downloads

SQLite implementation of CheckpointStore for durable_workflow. Uses sqlite3 FFI for high-performance local persistence.

Repository (GitHub)
View/report issues

Topics

#workflow #sqlite #persistence #checkpoint

License

MIT (license)

Dependencies

durable_workflow, meta, sqlite3

More

Packages that depend on durable_workflow_sqlite