verify method

Future<void> verify()

Verify that EventStoreClientSettings.apiVersion is compatible with server version. Throws a UnsupportedApiVersionException if MemberInfo.apiVersion is incompatible with requested EventStoreClientSettings.apiVersion.

Implementation

Future<void> verify() async {
  if (_shouldVerify) {
    final version = await _getServerApiVersion();
    _api = Versions._(
      client: Api._(settings.apiVersion),
      server: Api._(version),
    );
    final constraint = VersionConstraint.parse(
      '<=${_api.server!.version}',
    );
    final isSupported = constraint.allows(Version.parse(
      settings.apiVersion,
    ));
    if (!isSupported) {
      throw UnsupportedApiVersionException(
        'Server version ${_api.server!.version} is not supported '
        'for node $leader. Requested version is ${settings.apiVersion}.',
      );
    }
    _shouldVerify = false;
  }
}