Operational Data Models
Service Status
Classify Check Counts
Dart programs often turn a small numeric signal into a clear status label. This example keeps the check count and threshold explicit so the report line stays easy to inspect.
Program
Play the program to choose the failed check count and inspect the service status line.
service_status_model.dart
Replay: real traced execution (multi-file project)
String classify(int failedChecks, int maxAllowed) {
if (failedChecks <= maxAllowed) {
return 'ready';
}
return 'blocked';
}
void main() {
var failedChecks = 1;
var maxAllowed = 0;
var status = classify(failedChecks, maxAllowed);
var line = 'api failed=$failedChecks status=$status';
print(line);
}
String classify(int failedChecks, int maxAllowed) {
if (failedChecks <= maxAllowed) {
return 'ready';
}
return 'blocked';
}
void main() {
var failedChecks = 0;
var maxAllowed = 0;
var status = classify(failedChecks, maxAllowed);
var line = 'api failed=$failedChecks status=$status';
print(line);
}
failedChecks ← 1
8void main() {9 var failedChecks = 1;10 var maxAllowed = 0;values this step1failedChecksmaxAllowed ← 0
9var failedChecks = 1;10var maxAllowed = 0;11var status = classify(failedChecks, maxAllowed);values this step0maxAllowedcall ← classify(1, 0)
10var maxAllowed = 0;11var status = classify(failedChecks, maxAllowed);12var line = 'api failed=$failedChecks status=$status';values this stepclassify(1, 0)call1failedChecks0maxAllowedif (failedChecks <= maxAllowed)
1String classify(int failedChecks, int maxAllowed) {2 if (failedChecks <= maxAllowed) {3 return 'ready';values this step1failedChecks0maxAllowedreturn ← blocked
4 }5 return 'blocked';6}values this stepblockedreturnstatus ← blocked
10var maxAllowed = 0;11var status = classify(failedChecks, maxAllowed);12var line = 'api failed=$failedChecks status=$status';values this stepblockedstatusline ← api failed=1 status=blocked
11var status = classify(failedChecks, maxAllowed);12var line = 'api failed=$failedChecks status=$status';13print(line);values this stepapi failed=1 status=blockedline1failedChecksblockedstatusprint(line);
12 var line = 'api failed=$failedChecks status=$status';13 print(line);14}outputapi failed=1 status=blockedvalues this stepapi failed=1 status=blockedline
failedChecks ← 0
8void main() {9 var failedChecks = 0;10 var maxAllowed = 0;values this step0failedChecksmaxAllowed ← 0
9var failedChecks = 0;10var maxAllowed = 0;11var status = classify(failedChecks, maxAllowed);values this step0maxAllowedcall ← classify(0, 0)
10var maxAllowed = 0;11var status = classify(failedChecks, maxAllowed);12var line = 'api failed=$failedChecks status=$status';values this stepclassify(0, 0)call0failedChecks0maxAllowedif (failedChecks <= maxAllowed)
1String classify(int failedChecks, int maxAllowed) {2 if (failedChecks <= maxAllowed) {3 return 'ready';values this step0failedChecks0maxAllowedreturn ← ready
2if (failedChecks <= maxAllowed) {3 return 'ready';4}values this stepreadyreturnstatus ← ready
10var maxAllowed = 0;11var status = classify(failedChecks, maxAllowed);12var line = 'api failed=$failedChecks status=$status';values this stepreadystatusline ← api failed=0 status=ready
11var status = classify(failedChecks, maxAllowed);12var line = 'api failed=$failedChecks status=$status';13print(line);values this stepapi failed=0 status=readyline0failedChecksreadystatusprint(line);
12 var line = 'api failed=$failedChecks status=$status';13 print(line);14}outputapi failed=0 status=readyvalues this stepapi failed=0 status=readyline
status function
`classify` isolates the ready/blocked decision from the reporting string.
threshold
`maxAllowed` makes the policy visible instead of hiding it in a magic label.
report line
The final string combines the service signal and the derived status.