diff --git a/clients/dart/dart_cac_client/README.md b/clients/dart/dart_cac_client/README.md index 02fe8ecab..fd5c7b7a1 100644 --- a/clients/dart/dart_cac_client/README.md +++ b/clients/dart/dart_cac_client/README.md @@ -1,39 +1,79 @@ - +## Table of Contents +- [Dart CAC Client](#dart-cac-client) + - [Table of Contents](#table-of-contents) + - [Installation](#installation) + - [Usage](#usage) + - [Creating a Client](#creating-a-client) + - [Starting Polling for Updates](#starting-polling-for-updates) + - [Retrieving Configurations](#retrieving-configurations) + - [Getting Default Configurations](#getting-default-configurations) + - [Getting Resolved Configurations](#getting-resolved-configurations) + - [Getting Last Modified Timestamp](#getting-last-modified-timestamp) + - [Disposing the Client](#disposing-the-client) -TODO: Put a short description of the package here that helps potential users -know whether this package might be useful for them. +## Installation -## Features +Add the following dependency to your `pubspec.yaml` file: -TODO: List what your package can do. Maybe include images, gifs, or videos. +```yaml +dependencies: + dart_cac_client: + git: + url: git@github.com:your_repo/dart_cac_client.git +``` -## Getting started +## Usage -TODO: List prerequisites and provide or point to information on how to -start using the package. +### Creating a Client +To create a new CAC client, instantiate the DartCacClient class with the tenant name, update frequency (in seconds), and host URL -## Usage +```dart +final client = DartCacClient('dev', 60, 'http://localhost:8080'); +``` + +### Starting Polling for Updates +Use the cacStartPolling method to start polling for configuration updates for the specified tenant: + +```dart +client.cacStartPolling(""); +``` + +### Retrieving Configurations +Use the getConfigs method to retrieve configurations based on a filter query and filter prefix: +```dart +String configs = client.getConfigs('{"country": "India"}', 'country'); +``` -TODO: Include short and useful examples for package users. Add longer examples -to `/example` folder. +### Getting Default Configurations +Use the getDefaultConfig method to retrieve the default configurations for the specified keys: ```dart -const like = 'sample'; +String defaultConfigs = client.getDefaultConfig("india"); ``` -## Additional information +### Getting Resolved Configurations +Use the getResolvedConfig method to retrieve resolved configurations based on the provided query, keys, and merge strategy: -TODO: Tell users more about the package: where to find more information, how to -contribute to the package, how to file issues, what response they can expect -from the package authors, and more. + +```dart +String resolvedConfigs = client.getResolvedConfig( + '{"query": "example"}', "key1, key2", MergeStrategy.MERGE/MergeStrategy.REPLACE); +``` + + +### Getting Last Modified Timestamp +Use the getCacLastModified method to get the last modified timestamp of the configurations: + +```dart +String lastModified = client.getCacLastModified(); +``` + +### Disposing the Client +Ensure that you dispose of the client properly to free up resources: +```dart +client.dispose(); +``` diff --git a/clients/dart/dart_cac_client/lib/cac_client.dart b/clients/dart/dart_cac_client/lib/cac_client.dart index 8b3a61e15..2ace65717 100644 --- a/clients/dart/dart_cac_client/lib/cac_client.dart +++ b/clients/dart/dart_cac_client/lib/cac_client.dart @@ -10,18 +10,13 @@ final ffi.DynamicLibrary _lib = ffi.DynamicLibrary.open(_libName); // Helper to get the correct library name based on the platform String get _libName { if (Platform.isWindows) { - return path.join( - '/Users/subhash/working-repos/github/superposition/target/debug/', - 'cac_client.dll'); + return path.join(path.current, '/../../../target/debug/', 'cac_client.dll'); } if (Platform.isMacOS) { return path.join( - '/Users/subhash/working-repos/github/superposition/target/debug/', - 'libcac_client.dylib'); + path.current, '/../../../target/debug/', 'libcac_client.dylib'); } - return path.join( - '/Users/subhash/working-repos/github/superposition/target/debug/', - 'libcac_client.so'); + return path.join(path.current, '/../../../target/debug/', 'libcac_client.so'); } // Bind the C functions diff --git a/clients/dart/dart_cac_client/lib/dart_cac_client.dart b/clients/dart/dart_cac_client/lib/dart_cac_client.dart index 954f355a6..ea2144d42 100644 --- a/clients/dart/dart_cac_client/lib/dart_cac_client.dart +++ b/clients/dart/dart_cac_client/lib/dart_cac_client.dart @@ -18,8 +18,8 @@ class DartCacClient { /// final client = CacClient('dev', 60, 'http://localhost:8080'); /// ``` - DartCacClient(String s, int i, String t) { - client = CacClient('dev', 1, 'http://localhost:8080'); + DartCacClient(String tenant, int updateFrequency, String hostUrl) { + client = CacClient(tenant, updateFrequency, hostUrl); } /// Retrieves configurations based on the provided query and filter prefix.