diff --git a/README.md b/README.md index f3af6db1..52b4d80a 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,15 @@ # Client SDKs -This repository centralizes the client-side SDKs for Flipt. +![Status: Experimental](https://img.shields.io/badge/status-experimental-yellow) + +This repository centralizes the client-side SDKs for [Flipt](https://github.com/flipt-io/flipt). These client-side SDKs are responsible for evaluating context and returning the results of the evaluation. They enable developers to easily integrate Flipt into their applications without relying on server-side SDKs. ## Architecture +The client SDKs are designed to be embedded in end-user applications. + The evaluation logic is written in Rust and can be found in the `flipt-engine` directory. The language clients that are used in end-user applications wrap the engine can be found in the `flipt-client-{language}` directories. See [ARCHITECTURE.md](./ARCHITECTURE.md). diff --git a/flipt-client-go/README.md b/flipt-client-go/README.md index dd2fca17..64b5081a 100644 --- a/flipt-client-go/README.md +++ b/flipt-client-go/README.md @@ -1,6 +1,6 @@ # Flipt Client Go -The `flipt-client-go` directory contains the Golang source code for a Flipt evaluation client using FFI to make calls to a core built in Rust. +The `flipt-client-go` directory contains the Go source code for a Flipt evaluation client. ## Instructions @@ -10,7 +10,7 @@ To use this client, you can run the following command from the root of the repos cargo build --release ``` -This should generate a `target/` directory in the root of this repository, which contains the dynamic linking library built for your platform. This dynamic library will contain the functionality necessary for the Golang client to make FFI calls. +This should generate a `target/` directory in the root of this repository, which contains the dynamic linking library built for your platform. This dynamic library will contain the functionality necessary for the Go client to make FFI calls. You can import the module that contains the evaluation client: `go.flipt.io/flipt/flipt-client-go` and build your Go project with the `CGO_LDFLAGS` environment variable set: @@ -26,44 +26,42 @@ The `path/to/lib` will be the path to the dynamic library which will have the fo You can then use the client like so: -```golang +```go package main import ( - "context" - "fmt" - "log" + "context" + "fmt" + "log" - evaluation "go.flipt.io/flipt/flipt-client-go" + evaluation "go.flipt.io/flipt/flipt-client-go" ) func main() { - // The NewClient() accepts options which are the following: - // evaluation.WithNamespace(string): configures which namespace you will be making evaluations on - // evaluation.WithURL(string): configures which upstream Flipt data should be fetched from - // evaluation.WithUpdateInterval(int): configures how often data should be fetched from the upstream - evaluationClient, err := evaluation.NewClient() - if err != nil { - log.Fatal(err) - } - defer evaluationClient.Close() - - variantResult, err := evaluationClient.Variant(context.Background(), "flag1", "someentity", map[string]string{ - "fizz": "buzz", - }) - if err != nil { - log.Fatal(err) - } - - fmt.Println(*variantResult.Result) + // The NewClient() accepts options which are the following: + // evaluation.WithNamespace(string): configures which namespace you will be making evaluations on + // evaluation.WithURL(string): configures which upstream Flipt data should be fetched from + // evaluation.WithUpdateInterval(int): configures how often data should be fetched from the upstream + evaluationClient, err := evaluation.NewClient() + if err != nil { + log.Fatal(err) + } + defer evaluationClient.Close() + + variantResult, err := evaluationClient.Variant(context.Background(), "flag1", "someentity", map[string]string{ + "fizz": "buzz", + }) + if err != nil { + log.Fatal(err) + } + + fmt.Println(*variantResult.Result) } ``` ## Memory Management -The engine that is allocated on the Rust side to compute evaluations for flag state will not be properly deallocated unless you call the `Close()` method on a `Client` instance, please be sure to do that to avoid leaking memory. - -ie: +The engine that is allocated on the Rust side to compute evaluations for flag state will not be properly deallocated unless you call the `Close()` method on a `Client` instance. Please be sure to do this to avoid leaking memory. ```go defer evaluationClient.Close() diff --git a/flipt-client-node/README.md b/flipt-client-node/README.md index c172cb22..61504e41 100644 --- a/flipt-client-node/README.md +++ b/flipt-client-node/README.md @@ -1,6 +1,6 @@ # Flipt Client Node -The `flipt-client-node` directory contains the TypeScript source code for a Flipt evaluation client using FFI to make calls to a core built in Rust. +The `flipt-client-node` directory contains the TypeScript source code for a Flipt evaluation client. ## Instructions @@ -41,4 +41,10 @@ console.log(variant); ## Memory Management -Since TypeScript/JavaScript is a garbage collected language there is no concept of "freeing" memory. We had to allocated memory for the engine through the `initialize_engine` FFI call, and with that being said please make sure to call the `freeEngine` method on the `FliptEvaluationClient` class once you are done using it. +Since TypeScript/JavaScript is a garbage collected language there is no concept of "freeing" memory. We have to allocate memory for the engine through the `initialize_engine` FFI call. + +Make sure to call the `freeEngine` method on the `FliptEvaluationClient` class once you are done using it. + +```typescript +fliptEvaluationClient.freeEngine(); +``` diff --git a/flipt-client-python/README.md b/flipt-client-python/README.md index 898ba76d..eb48bd21 100644 --- a/flipt-client-python/README.md +++ b/flipt-client-python/README.md @@ -1,6 +1,6 @@ # Flipt Client Python -The `flipt-client-python` directory contains the Python source code for a Flipt evaluation client using FFI to make calls to a core built in Rust. +The `flipt-client-python` directory contains the Python source code for a Flipt evaluation client. ## Instructions @@ -10,7 +10,7 @@ To use this client, you can run the following command from the root of the repos cargo build --release ``` -This should generate a `target/` directory in the root of this repository, which contains the dynamic linking library built for your platform. This dynamic library will contain the functionality necessary for the Python client to make FFI calls. You'll need to set the `FLIPT_ENGINE_LIB_PATH` environment variable depending on your platform: +This should generate a `target/` directory in the root of this repository which contains the dynamic linking library built for your platform. This dynamic library will contain the functionality necessary for the Python client to make FFI calls. You'll need to set the `FLIPT_ENGINE_LIB_PATH` environment variable depending on your platform: - **Linux**: `{REPO_ROOT}/target/release/libfliptengine.so` - **Windows**: `{REPO_ROOT}/target/release/libfliptengine.dll` diff --git a/flipt-client-ruby/Makefile b/flipt-client-ruby/Makefile deleted file mode 100644 index e69de29b..00000000 diff --git a/flipt-client-ruby/README.md b/flipt-client-ruby/README.md index 63c94f0a..870e3346 100644 --- a/flipt-client-ruby/README.md +++ b/flipt-client-ruby/README.md @@ -1,6 +1,6 @@ # Flipt Client Ruby -The `flipt-client-ruby` directory contains the Ruby source code for a Flipt evaluation client using FFI to make calls to a core built in Rust. +The `flipt-client-ruby` directory contains the Ruby source code for a Flipt evaluation client. ## Instructions @@ -37,17 +37,3 @@ resp = client.variant({ flag_key: 'buzz', entity_id: 'someentity', context: { fi puts resp ``` - -## Testing - -### Preqrequisites - -- Ruby -- Bundler -- Run `make ruby` from the root of the repository to build the Rust library and copy the necessary files over. - -To run the tests for this client, you can run the following command from this directory: - -```bash -rspec . -``` diff --git a/flipt-engine/README.md b/flipt-engine/README.md index b7982692..55a2103c 100644 --- a/flipt-engine/README.md +++ b/flipt-engine/README.md @@ -1,7 +1,5 @@ # Flipt Client Engine -![Status: Experimental](https://img.shields.io/badge/status-experimental-yellow) - This is the client engine for Flipt. It is responsible for evaluating context provided by the native language client SDKs and returning the results of the evaluation. ## Development