1 | | | import 'package:meta/meta.dart'; |
2 | | |
|
3 | | | /// Base statistics for worker. |
4 | | | class WorkerStat { |
5 | | 10 | WorkerStat._( |
6 | | | this.workerType, |
7 | | | this.workerHashCode, |
8 | | | this.isStopped, |
9 | | | this.status, |
10 | | | this.workload, |
11 | | | this.maxWorkload, |
12 | | | this.totalWorkload, |
13 | | | this.totalErrors, |
14 | | | this.upTime, |
15 | | | this.idleTime); |
16 | | |
|
17 | | | /// The worker's runtime type. |
18 | | | final Type workerType; |
19 | | |
|
20 | | | /// The worker's hashCode. |
21 | | | final int workerHashCode; |
22 | | |
|
23 | | | /// Worker running flag. |
24 | | | final bool isStopped; |
25 | | |
|
26 | | | /// Worker status. |
27 | | | final String status; |
28 | | |
|
29 | | | /// Current workload being processed by the worker. |
30 | | | final int workload; |
31 | | |
|
32 | | | /// Maximum concurrent workload processed by the worker. |
33 | | | final int maxWorkload; |
34 | | |
|
35 | | | /// Total workload processed by the worker. |
36 | | | final int totalWorkload; |
37 | | |
|
38 | | | /// Total errors raised during processing. |
39 | | | final int totalErrors; |
40 | | |
|
41 | | | /// The worker's up-time. |
42 | | | Duration upTime; |
43 | | |
|
44 | | | /// The worker's idle-time. |
45 | | | Duration idleTime; |
46 | | | } |
47 | | |
|
48 | | | @internal |
49 | | | extension WorkerStatExt on WorkerStat { |
50 | | 5 | static WorkerStat create( |
51 | | | Type workerType, |
52 | | | int workerHashCode, |
53 | | | bool isStopped, |
54 | | | String status, |
55 | | | int workload, |
56 | | | int maxWorkload, |
57 | | | int totalWorkload, |
58 | | | int totalErrors, |
59 | | | Duration upTime, |
60 | | | Duration idleTime) => |
61 | | 5 | WorkerStat._(workerType, workerHashCode, isStopped, status, workload, |
62 | | | maxWorkload, totalWorkload, totalErrors, upTime, idleTime); |
63 | | | } |