Configuration constructor
Configuration(
- String apiKey, {
- Set<
Node> ? nodes, - Node? nearestNode,
- int? numRetries,
- Duration retryInterval = const Duration(milliseconds: 100),
- Duration connectionTimeout = const Duration(seconds: 10),
- Duration healthcheckInterval = const Duration(seconds: 15),
- Duration cachedSearchResultsTTL = Duration.zero,
- 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);
}