batch 0.0.1 copy "batch: ^0.0.1" to clipboard
batch: ^0.0.1 copied to clipboard

outdated

A lightweight and powerful batch library written in Dart.

example/example.dart

// Copyright (c) 2022, Kato Shinya. All rights reserved.
// Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'package:batch/batch.dart';

void main() {
  final job1 = Job.from(name: 'Job1', cron: '*/1 * * * *')
    ..nextStep(
      Step.from(name: 'Step1')
        ..nextTask(TestTask())
        ..nextTask(SayHelloTask())
        ..nextTask(SayWorldTask()),
    )
    ..nextStep(
      Step.from(name: 'Step2')
        ..nextTask(TestTask())
        ..nextTask(SayHelloTask())
        ..nextTask(SayWorldTask()),
    );

  final job2 = Job.from(name: 'Job2', cron: '*/3 * * * *')
    ..nextStep(
      Step.from(name: 'Step1')
        ..nextTask(SayHelloTask())
        ..nextTask(SayWorldTask()),
    );

  JobLauncher.newInstance()
    ..addJob(job1)
    ..addJob(job2)
    ..execute();
}

class TestTask extends Task {
  static int count = 0;

  @override
  RepeatStatus execute() {
    if (count == 5) {
      print('Finish.');
      return RepeatStatus.finished;
    }

    count++;

    print('Continue.');
    return RepeatStatus.continuable;
  }
}

class SayHelloTask extends Task {
  @override
  RepeatStatus execute() {
    print('Hello,');
    return RepeatStatus.finished;
  }
}

class SayWorldTask extends Task {
  @override
  RepeatStatus execute() {
    print('World!');
    return RepeatStatus.finished;
  }
}
26
likes
0
pub points
56%
popularity

Publisher

verified publishershinyakato.dev

A lightweight and powerful batch library written in Dart.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

cron

More

Packages that depend on batch