BeatCli class
Shared setup for a bin/beat.dart entrypoint — parses the standard
gisila_queue beat flags, builds a Redis-backed GisilaQueue and a
Beat wired with a RedisBeatLock + RedisBeatStateStore (so running
two by accident doesn't double-fire everything), and wires graceful
shutdown:
Future<void> main(List<String> argv) async {
final cli = BeatCli.parse(argv);
if (cli.help) return print(cli.usage);
final app = cli.buildApp();
final beat = cli.buildBeat(app)
..schedule('cleanup', 'tasks.cleanup', Schedule.every(Duration(minutes: 5)));
await cli.run(beat);
}
Recognized flags: --redis-host=H (default: localhost),
--redis-port=P (default: 6379), --prefix=P (default: gq),
--tick-interval=SECONDS (default: 1), --lock-ttl=SECONDS
(default: 30), --loglevel=debug|info|warning|error (default: info),
--help/-h.
Constructors
-
BeatCli.parse(List<
String> argv) -
factory
Properties
- args → CliArgs
-
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- help → bool
-
no setter
- lockTtl → Duration
-
final
- logLevel → LogLevel
-
final
- prefix → String
-
final
- redisHost → String
-
final
- redisPort → int
-
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- tickInterval → Duration
-
final
Methods
-
buildApp(
) → GisilaQueue - Builds a Redis-backed GisilaQueue from the parsed flags. Only the broker is actually used by Beat (it just enqueues); a backend is included anyway so any tasks defined on the same app can be sent synchronously for testing without a separate producer process.
-
buildBeat(
GisilaQueue app) → Beat -
Builds a Beat for
app, wired with a Redis leader lock and persisted last-run state so a second beat process started by accident sits idle instead of double-firing every entry. Register your periodic entries on the result before calling run. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
run(
Beat beat) → Future< void> -
Starts
beat, prints a startup banner, and blocks until aSIGINT/SIGTERMtriggers a graceful Beat.stop. Also closesbeat's app connections before returning, so the process actually exits instead of hanging on an open Redis socket (Beat.stop already closes the lock/state-store connections it owns). -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited