PatchbayRetryPolicy.fromJson constructor
PatchbayRetryPolicy.fromJson(
- Object? value
Implementation
factory PatchbayRetryPolicy.fromJson(Object? value) {
if (value is! Map<Object?, Object?> ||
value.keys.any(
(Object? key) => key != 'maxAttempts' && key != 'backoffMs',
)) {
throw const FormatException('invalid retryPolicy shape');
}
final Object? maxAttempts = value['maxAttempts'];
final Object? backoffMs = value['backoffMs'];
if (maxAttempts is! int ||
maxAttempts < 2 ||
maxAttempts > 3 ||
backoffMs is! int ||
backoffMs < 0 ||
backoffMs > 5000) {
throw const FormatException('invalid retryPolicy bounds');
}
return PatchbayRetryPolicy(maxAttempts: maxAttempts, backoffMs: backoffMs);
}