open method

  1. @override
Future open(
  1. String? correlationId
)

Opens the component.

  • correlationId (optional) transaction id to trace execution through call chain. Return Future that receives null no errors occured. Throws error

Implementation

@override
Future open(String? correlationId) async {
  if (isOpen()) {
    return null;
  }

  var connection = await _connectionResolver.resolve(correlationId);
  if (connection == null) {
    throw ConfigException(
        correlationId, 'NO_CONNECTION', 'Connection is not configured');
  }

  var uri = connection.getAsString('uri');

  // var options = {
  //     host: uri,
  //     requestTimeout: this._timeout,
  //     deadTimeout: this._reconnect,
  //     maxRetries: this._maxRetries
  // };

  _transport = HttpTransport(url: Uri.parse(uri));
  _client = elastic.Client(_transport!);

  await _createIndexIfNeeded(correlationId, true);
  _timer = Timer.periodic(Duration(milliseconds: interval), (tm) {
    dump();
  });
}