Configuration constructor

Configuration(
  1. String apiKey, {
  2. Set<Node>? nodes,
  3. Node? nearestNode,
  4. int? numRetries,
  5. Duration retryInterval = const Duration(milliseconds: 100),
  6. Duration connectionTimeout = const Duration(seconds: 10),
  7. Duration healthcheckInterval = const Duration(seconds: 15),
  8. Duration cachedSearchResultsTTL = Duration.zero,
  9. bool sendApiKeyAsQueryParam = false,
})

Implementation

Configuration(
  this.apiKey, {
  this.nodes,
  this.nearestNode,
  int? numRetries,
  this.retryInterval = const Duration(milliseconds: 100),
  this.connectionTimeout = const Duration(seconds: 10),
  this.healthcheckInterval = const Duration(seconds: 15),
  this.cachedSearchResultsTTL = Duration.zero,
  this.sendApiKeyAsQueryParam = false,
}) {
  if (apiKey.isEmpty) {
    throw MissingConfiguration(
        'Ensure that Configuration.apiKey is not empty');
  }
  if (nodes?.isEmpty ?? false) {
    throw MissingConfiguration(
        'Ensure that Configuration.nodes is not empty');
  }
  if (nodes == null && nearestNode == null) {
    throw MissingConfiguration(
        'Ensure that at least one node is present in Configuration');
  }
  this.numRetries =
      numRetries ?? (nodes?.length ?? 0) + (nearestNode == null ? 0 : 1);
}