-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add dart-client Signed-off-by: Mark Phelps <[email protected]> * chore: fix readme Signed-off-by: Mark Phelps <[email protected]> * chore: add to pubspec Signed-off-by: Mark Phelps <[email protected]> * feat: evaluate batch impl Signed-off-by: Mark Phelps <[email protected]> * chore: impl list flags Signed-off-by: Mark Phelps <[email protected]> * chore: fix linter errors Signed-off-by: Mark Phelps <[email protected]> * chore: update dart readme to remove await Signed-off-by: Mark Phelps <[email protected]> * chore: update dart readme Signed-off-by: Mark Phelps <[email protected]> * chore: fix per PR feedback Signed-off-by: Mark Phelps <[email protected]> --------- Signed-off-by: Mark Phelps <[email protected]>
- Loading branch information
1 parent
f1ed36e
commit 2cd64f8
Showing
20 changed files
with
1,049 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# https://dart.dev/guides/libraries/private-files | ||
# Created by `dart pub` | ||
.dart_tool/ | ||
|
||
# Avoid committing pubspec.lock for library packages; see | ||
# https://dart.dev/guides/libraries/private-files#pubspeclock. | ||
pubspec.lock | ||
|
||
# Shared libraries | ||
lib/src/ffi/**/*.so | ||
lib/src/ffi/**/*.dylib |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2024 Flipt Software Inc. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
# Flipt Client Dart | ||
|
||
[![pub package](https://img.shields.io/pub/v/flipt_client.svg)](https://pub.dev/packages/flipt_client) | ||
|
||
The `flipt-client-dart` library contains the Dart source code for the Flipt [client-side evaluation](https://www.flipt.io/docs/integration/client) client. | ||
|
||
## Installation | ||
|
||
Add this to your package's `pubspec.yaml` file: | ||
|
||
```yaml | ||
dependencies: | ||
flipt_client: ^0.1.0 | ||
``` | ||
Then run `dart pub get` to install the package. | ||
|
||
## Supported Architectures | ||
|
||
This SDK currently supports the following OSes/architectures: | ||
|
||
- Linux x86_64 | ||
- Linux arm64 | ||
- MacOS x86_64 | ||
- MacOS arm64 | ||
|
||
> [!IMPORTANT] | ||
> This SDK currently only supports desktop platforms (MacOS and Linux). | ||
> We are working on adding support for mobile platforms such as iOS and Android. | ||
|
||
## Usage | ||
|
||
```dart | ||
import 'package:flipt_client/flipt_client.dart'; | ||
void main() { | ||
// Initialize the client | ||
final client = FliptEvaluationClient( | ||
'default', | ||
Options.withClientToken( | ||
'your-token', | ||
url: 'http://localhost:8080', | ||
), | ||
); | ||
// Evaluate a variant flag | ||
final result = client.evaluateVariant( | ||
flagKey: 'flag1', | ||
entityId: 'someentity', | ||
context: {'fizz': 'buzz'}, | ||
); | ||
print('Variant: ${result.variantKey}'); | ||
// Evaluate a boolean flag | ||
final result = client.evaluateBoolean( | ||
flagKey: 'flag2', | ||
entityId: 'user123', | ||
context: {'key': 'value'}, | ||
); | ||
print('Enabled: ${result.enabled}'); | ||
// Don't forget to close the client when you're done | ||
client.close(); | ||
} | ||
``` | ||
|
||
### Authentication | ||
|
||
The `FliptEvaluationClient` supports the following authentication strategies: | ||
|
||
- No Authentication (default) | ||
- [Client Token Authentication](https://docs.flipt.io/authentication/using-tokens) | ||
- [JWT Authentication](https://docs.flipt.io/authentication/using-jwts) | ||
|
||
## Development | ||
|
||
To generate the JSON serialization code, run: | ||
|
||
```bash | ||
dart run build_runner build --delete-conflicting-outputs | ||
``` | ||
|
||
## Contributing | ||
|
||
Contributions are welcome! Please feel free to open an issue or submit a Pull Request. | ||
|
||
## License | ||
|
||
This project is licensed under the [MIT License](LICENSE). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# This file configures the static analysis results for your project (errors, | ||
# warnings, and lints). | ||
# | ||
# This enables the 'recommended' set of lints from `package:lints`. | ||
# This set helps identify many issues that may lead to problems when running | ||
# or consuming Dart code, and enforces writing Dart using a single, idiomatic | ||
# style and format. | ||
# | ||
# If you want a smaller set of lints you can change this to specify | ||
# 'package:lints/core.yaml'. These are just the most critical lints | ||
# (the recommended set includes the core lints). | ||
# The core lints are also what is used by pub.dev for scoring packages. | ||
|
||
include: package:lints/recommended.yaml | ||
|
||
# Uncomment the following section to specify additional rules. | ||
|
||
# linter: | ||
# rules: | ||
# - camel_case_types | ||
|
||
# analyzer: | ||
# exclude: | ||
# - path/to/excluded/files/** | ||
|
||
# For more information about the core and recommended set of lints, see | ||
# https://dart.dev/go/core-lints | ||
|
||
# For additional information about configuring this file, see | ||
# https://dart.dev/guides/language/analysis-options |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
targets: | ||
$default: | ||
sources: | ||
exclude: | ||
- 'example/**' | ||
builders: | ||
json_serializable: | ||
options: | ||
explicit_to_json: true | ||
field_rename: snake |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
library flipt_client; | ||
|
||
export 'src/models.dart'; | ||
export 'src/flipt_evaluation_client.dart'; |
Empty file.
Oops, something went wrong.