Skip to content

Commit

Permalink
chore: more docs cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
markphelps committed Dec 3, 2023
1 parent 0cbc2ae commit 612b651
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 50 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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).
Expand Down
54 changes: 26 additions & 28 deletions flipt-client-go/README.md
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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:

Expand All @@ -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()
Expand Down
10 changes: 8 additions & 2 deletions flipt-client-node/README.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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();
```
4 changes: 2 additions & 2 deletions flipt-client-python/README.md
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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`
Expand Down
Empty file removed flipt-client-ruby/Makefile
Empty file.
16 changes: 1 addition & 15 deletions flipt-client-ruby/README.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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 .
```
2 changes: 0 additions & 2 deletions flipt-engine/README.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 612b651

Please sign in to comment.