ReadPreference constructor

ReadPreference(
  1. ReadPreferenceMode mode, {
  2. List? tags,
  3. int? maxStalenessSeconds,
  4. Map<String, Object>? hedgeOptions,
})

Implementation

ReadPreference(this.mode,
    {this.tags, this.maxStalenessSeconds, this.hedgeOptions}) {
  if (mode == ReadPreferenceMode.primary) {
    if (tags != null && tags!.isNotEmpty) {
      throw ArgumentError(
          'Primary read preference cannot be combined with tags');
    }
    if (maxStalenessSeconds != null) {
      throw ArgumentError(
          'Primary read preference cannot be combined with maxStalenessSeconds');
    }
  }
  if (maxStalenessSeconds != null && maxStalenessSeconds! < 0) {
    throw ArgumentError('maxStalenessSeconds must be a positive integer');
  }
}