LCOV - code coverage report

Current view
top level - src/stats - worker_stat.dart
Test
lcov.info
Date
2025-07-05
Legend
Lines
hit
not hit
Branches
taken
not taken
# not executed
HitTotalCoverage
Lines3650.0%
Functions00-
Branches00-
Each row represents a line of source code
LineBranchHitsSource code
1import 'package:meta/meta.dart';
2
3/// Base statistics for worker.
4class WorkerStat {
56 WorkerStat._(
6 this.workerType,
7 this.workerHashCode,
8 this.isStopped,
9 this.workload,
10 this.maxWorkload,
11 this.totalWorkload,
12 this.totalErrors,
13 this.upTime,
14 this.idleTime,
15 this.activeConnections,
16 );
17
18 /// Timestamp of this snapshot
19 final timestamp = DateTime.now().toUtc();
20
21 /// The worker's runtime type.
22 final Type workerType;
23
24 /// The worker's hashCode.
25 final int workerHashCode;
26
27 /// Worker running flag.
28 final bool isStopped;
29
30 /// Current workload being processed by the worker.
31 final int workload;
32
33 /// Maximum concurrent workload processed by the worker.
34 final int maxWorkload;
35
36 /// Total workload processed by the worker.
37 final int totalWorkload;
38
39 /// Total errors raised during processing.
40 final int totalErrors;
41
42 /// The worker's up-time.
43 Duration upTime;
44
45 /// The worker's idle-time.
46 Duration idleTime;
47
48 /// The worker channel's count of active connections.
49 final int activeConnections;
50}
51
52extension WorkerStatsExt on Iterable<WorkerStat> {
53 /// Gets the total workload from a collection of worker stats.
540 int get workload => fold<int>(0, (p, s) => p + s.workload);
55
56 /// Gets the grand total of workloads from a collection of worker stats.
570 int get totalWorkload => fold<int>(0, (p, s) => p + s.totalWorkload);
58
59 /// Gets the grand total of errors from a collection of worker stats.
600 int get totalErrors => fold<int>(0, (p, s) => p + s.totalErrors);
61}
62
63@internal
64extension WorkerStatImpl on WorkerStat {
656 static WorkerStat create(
66 Type workerType,
67 int workerHashCode,
68 bool isStopped,
69 int workload,
70 int maxWorkload,
71 int totalWorkload,
72 int totalErrors,
73 Duration upTime,
74 Duration idleTime,
75 int activeConnections) =>
766 WorkerStat._(workerType, workerHashCode, isStopped, workload, maxWorkload,
77 totalWorkload, totalErrors, upTime, idleTime, activeConnections);
78}
Choose Features