Skip to content

Commit

Permalink
fix: create readme file to help with package integration
Browse files Browse the repository at this point in the history
  • Loading branch information
Subhash703 committed Jul 15, 2024
1 parent 7b4a501 commit 0279d1f
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 33 deletions.
90 changes: 65 additions & 25 deletions clients/dart/dart_cac_client/README.md
Original file line number Diff line number Diff line change
@@ -1,39 +1,79 @@
<!--
This README describes the package. If you publish this package to pub.dev,
this README's contents appear on the landing page for your package.
# Dart CAC Client

For information about how to write a good package README, see the guide for
[writing package pages](https://dart.dev/guides/libraries/writing-package-pages).
This package provides a Dart interface for the CAC (Configuration as Code) client, allowing you to interact with the CAC server to retrieve and manage configurations.

For general information about developing packages, see the Dart guide for
[creating packages](https://dart.dev/guides/libraries/create-library-packages)
and the Flutter guide for
[developing packages and plugins](https://flutter.dev/developing-packages).
-->
## 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: [email protected]: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("<tenant name>");
```

### 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();
```
11 changes: 3 additions & 8 deletions clients/dart/dart_cac_client/lib/cac_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0279d1f

Please sign in to comment.