Skip to content

Commit

Permalink
added comment documentation for HostReachabilityChecker
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrii committed Apr 22, 2024
1 parent 0968e48 commit add7131
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
10 changes: 1 addition & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,15 +175,7 @@ Example:
```dart
class CustomReachabilityChecker extends HostReachabilityChecker {
@override
Future<bool> canReachAnyHost() {
// TODO implement host connection
}
@override
Future<bool> hostLookup() {
// TODO implement host lookup
}
// TODO implementation
}
final connecteo = ConnectionChecker.fromReachabilityChecker(
Expand Down
23 changes: 23 additions & 0 deletions lib/src/host_reachability_checker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,32 @@ final _defaultUrls = List<ConnectionEntry>.unmodifiable([
),
]);

/// A class for custom implementation how the desired hosts are reached.
///
/// This abstract class provides a contract used by ConnectionChecker class.
/// The contract assumes own implementation of methods to perform
/// host lookup of desired url along with the reachabiltiy of provided hosts.
///
/// Example usage:
/// ```dart
/// class CustomReachabilityChecker extends HostReachabilityChecker { [...] }
///
/// final connecteo = ConnectionChecker.fromReachabilityChecker(
/// hostReachabilityChecker: CustomReachabilityChecker(), [...]
/// );
/// ```
abstract class HostReachabilityChecker {
/// Performs a host lookup to determine if the host is reachable.
///
/// Returns a [Future] that completes with a boolean value indicating whether
/// the host is reachable or not.
Future<bool> hostLookup();

/// Check if desired hosts are reachable (e.g. via opening a socket
/// connection to each address)
///
/// Returns a [Future] that completes with a boolean value indicating whether
/// host can be reached or not.
Future<bool> canReachAnyHost();
}

Expand Down

0 comments on commit add7131

Please sign in to comment.