configure method

Future<void> configure()

Configures the native automator.

Must be called before using any native features.

Implementation

Future<void> configure() async {
  const retries = 60;

  PatrolActionException? exception;
  for (var i = 0; i < retries; i++) {
    try {
      await _wrapRequest(
        'configure',
        () => _client.configure(
          ConfigureRequest(
            findTimeoutMillis: _config.findTimeout.inMilliseconds,
          ),
        ),
      );
      exception = null;
      break;
    } on PatrolActionException catch (err) {
      _config.logger('configure() failed: (${err.message})');
      exception = err;
    }

    _config.logger('trying to configure() again in 1 second');
    await Future<void>.delayed(const Duration(seconds: 1));
  }

  if (exception != null) {
    throw PatrolActionException(
      'configure() failed after $retries retries (${exception.message}',
    );
  }
}