1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-03-18 00:19:49 +01:00

chore: fix SDK docs

This commit is contained in:
Ivar Conradi Østhus 2021-05-04 16:08:21 +02:00
parent 2f2c2b74db
commit b5a36a6d42
No known key found for this signature in database
GPG Key ID: 31AC596886B0BD09
9 changed files with 111 additions and 203 deletions

View File

@ -5,13 +5,12 @@ title: .net SDK
In this guide we explain how to use feature toggles in a .NET application using Unleash-hosted. We will be using the open source Unleash [.net Client SDK](https://github.com/Unleash/unleash-client-dotnet).
> **Important details**
>
>Make sure you have the following details available:
> **Required details**
>
> - **API URL** Where you should connect your client SDK
> - **API Secret** Your API secret required to connect to your instance.
>You can find this information in your “Instance admin” available in your Unleash management UI.
>
> You can find this information in the “Admin” section Unleash management UI.
## Step 1: Install client SDK
@ -59,7 +58,7 @@ else
}
```
Pleas note the client SDK will synchronize with the Unleash-hosted API on initialization, and thus it can take a few milliseconds the first time before the client has the correct state. You can use the *SynchronousInitialization* option to block the client until it has successfully synced with the server.
Pleas note the client SDK will synchronize with the Unleash-hosted API on initialization, and thus it can take a few milliseconds the first time before the client has the correct state. You can use the _SynchronousInitialization_ option to block the client until it has successfully synced with the server.
Read more about the [Unleash architecture](https://www.unleash-hosted.com/articles/our-unique-architecture) to learn how it works in more details

View File

@ -3,6 +3,13 @@ id: go_sdk
title: GO SDK
---
> **Required details**
>
> - **API URL** Where you should connect your client SDK
> - **API Secret** Your API secret required to connect to your instance.
>
> You can find this information in the “Admin” section Unleash management UI.
### 1. Install unleash-client-go
To install the latest version of the client use:
@ -38,8 +45,7 @@ func init() {
### 3. Use unleash
After you have initialized the unleash-client you can easily check if a feature
toggle is enabled or not.
After you have initialized the unleash-client you can easily check if a feature toggle is enabled or not.
```go
unleash.IsEnabled("app.ToggleX")
@ -47,15 +53,13 @@ unleash.IsEnabled("app.ToggleX")
### 4. Stop unleash
To shut down the client (turn off the polling) you can simply call the
destroy-method. This is typically not required.
To shut down the client (turn off the polling) you can simply call the destroy-method. This is typically not required.
unleash.Close()
### Built in activation strategies
The Go client comes with implementations for the built-in activation strategies
provided by unleash.
The Go client comes with implementations for the built-in activation strategies provided by unleash.
- DefaultStrategy
- UserIdStrategy
@ -70,9 +74,7 @@ Read more about the strategies in [activation-strategy.md]().
### Unleash context
In order to use some of the common activation strategies you must provide a
[unleash-context](https://github.com/Unleash/unleash/blob/master/docs/unleash-context.md).
This client SDK allows you to send in the unleash context as part of the `isEnabled` call:
In order to use some of the common activation strategies you must provide a [unleash-context](https://github.com/Unleash/unleash/blob/master/docs/unleash-context.md). This client SDK allows you to send in the unleash context as part of the `isEnabled` call:
```go
ctx := context.Context{

35
docs/sdks/index.md Normal file
View File

@ -0,0 +1,35 @@
---
id: index
title: Introduction
---
In order to connect your application to Unleash you need to use a client SDK (software developer kit) for your programming language. The SDK will handle connecting to the Unleash server instance and retrieve feature toggles based upon your configuration. Both open-source and the Unleash enterprise offering utilize the same set of client SDKs.
If you are an Unleash customer, our hosted instances will always be a protected instance, you will therefore have to specify a client secret as the authorization header when you are connecting your client SDK, which you will receive from us when you sign up for one of our packages. In the open source version you must generate your own secret.
On this page you will find examples for connecting your application to the demo instance. If you are connecting to your own private instance you will have to remember to replace the client secret and the API url given in the examples.
We have examples for all official client SDKs:
- [Java SDK](./java_sdk)
- [Node.js SDK](./node_sdk)
- [Go SDK](./go_sdk)
- [Ruby SDK](./ruby_sdk)
- [Python SDK](./python_sdk)
- [.Net SDK](./dot_net_sdk)
- [Javascript SDK](https://github.com/unleash-hosted/unleash-proxy-client-js) (Used by single-page applications)
### Clients written by awesome enthusiasts:
- [cognitedata/unleash-client-rust](https://github.com/cognitedata/unleash-client-rust) (Rust)
- [silvercar/unleash-client-kotlin](https://github.com/silvercar/unleash-client-kotlin) (Kotlin)
- [uekoetter.dev/unleash-client-dart](https://pub.dev/packages/unleash) (Dart)
- [minds/unleash-client-php](https://gitlab.com/minds/unleash-client-php) (PHP)
- [Stogon/unleash-bundle](https://git.stogon.io/Stogon/unleash-bundle/) (PHP - Symfony)
- [afontaine/unleash_ex](https://gitlab.com/afontaine/unleash_ex) (Elixir)
- [mikefrancis/laravel-unleash](https://github.com/mikefrancis/laravel-unleash) (Laravel - PHP)
- [AppsFlyer/clojure-unleash](https://github.com/AppsFlyer/unleash-client-clojure) (Clojure)
- [pmb0/nestjs-unleash](https://github.com/pmb0/nestjs-unleash) (NestJS - Node.js)
- _...your implementation for your favorite language._
When you get access to your instance we will provide you with your Client secret and your API url for your instance.

View File

@ -5,14 +5,12 @@ title: Java SDK
In this guide we explain how to use feature toggles in a Java application using Unleash-hosted. We will be using the open source Unleash [Java Client SDK](https://github.com/Unleash/unleash-client-java).
> **Important details**
>
>Make sure you have the following details available:
> **Required details**
>
> - **API URL** Where you should connect your client SDK
> - **API Secret** Your API secret required to connect to your instance.
>You can find this information in your “Instance admin” available in your Unleash management UI.
>
> You can find this information in the “Admin” section Unleash management UI.
## Step 1: Install the client SDK
@ -46,8 +44,6 @@ In your app you typically just want one instance of Unleash, and inject that whe
You should change the URL and the Authorization header (API secret) with the correct values for your instance, which you may locate under “Instance admin” in the menu.
## Step 3: Use the feature toggle
Now that we have initialized the client SDK we can start using feature toggles defined in Unleash in our application. To achieve this we have the “isEnabled” method available, which will allow us to check the value of a feature toggle. This method will return **true** or **false** based on whether the feature should be enabled or disabled for the current request.
@ -60,7 +56,7 @@ if(unleash.isEnabled("AwesomeFeature")) {
}
```
Pleas note the client SDK will synchronize with the Unleash-hosted API on initialization, and thus it can take a few milliseconds the first time before the client has the correct state. You can use the *synchronousFetchOnInitialisation* option to block the client until it has successfully synced with the server.
Pleas note the client SDK will synchronize with the Unleash-hosted API on initialization, and thus it can take a few milliseconds the first time before the client has the correct state. You can use the _synchronousFetchOnInitialisation_ option to block the client until it has successfully synced with the server.
Read more about the [Unleash architecture](https://www.unleash-hosted.com/articles/our-unique-architecture) to learn how it works in more details

View File

@ -5,13 +5,12 @@ title: Node SDK
In this guide we explain how to use feature toggles in a Node application using Unleash-hosted. We will be using the open source Unleash [Node.js Client SDK](https://github.com/Unleash/unleash-client-node).
> **Important details**
>
>Make sure your have the following details available:
> **Required details**
>
> - **API URL** Where you should connect your client SDK
> - **API Secret** Your API secret required to connect to your instance.
>You can find this information in your “Instance admin” available in your Unleash management UI.
>
> You can find this information in the “Admin” section Unleash management UI.
## Step 1: Install the client SDK
@ -32,7 +31,7 @@ unleash.initialize({
url: 'https://YOUR-API-URL',
appName: 'my-node-name',
environment: process.env.APP_ENV,
customHeaders: {'Authorization': 'SOME-SECRET'}
customHeaders: { Authorization: 'SOME-SECRET' },
});
```
@ -40,8 +39,6 @@ The example code above will initialize the client SDK, and connect to the Unleas
Please also pay attention to the “environment” option. Setting this will allow you to use [strategy constraints](../user_guide/strategy-constraints) which enables different roll-out strategies per environment.
## Step 3: Use the feature toggle
Now that we have initialized the client SDK in our application we can start using feature toggles defined in Unleash in our application. To achieve this we have the “isEnabled” method available, which will allow us to check the value of a feature toggle. This method will return **true** or **false** based on whether the feature should be enabled or disabled for the current request.

View File

@ -3,7 +3,14 @@ id: python_sdk
title: Python SDK
---
```java
> **Required details**
>
> - **API URL** Where you should connect your client SDK
> - **API Secret** Your API secret required to connect to your instance.
>
> You can find this information in the “Admin” section Unleash management UI.
```python
from UnleashClient import UnleashClient
client = UnleashClient(

View File

@ -3,6 +3,13 @@ id: ruby_sdk
title: Ruby SDK
---
> **Required details**
>
> - **API URL** Where you should connect your client SDK
> - **API Secret** Your API secret required to connect to your instance.
>
> You can find this information in the “Admin” section Unleash management UI.
```sh
require 'unleash'

View File

@ -3,25 +3,10 @@ id: client_sdk
title: Client SDK
---
To use Unleash in your application, you will need an Unleash Client SDK. Unleash has official client SDKs for Java, Node.js, Go, Ruby, Python and .Net. We will be happy to add implementations in other languages written by you! These libraries make it very easy to use Unleash in your application.
<script>
window.location = '/docs/sdks';
</script>
### Official client SDKs:
Please see <a href="/docs/sdks">/docs/sdks</a>
- [unleash/unleash-client-java](https://github.com/unleash/unleash-client-java)
- [unleash/unleash-client-node](https://github.com/unleash/unleash-client-node)
- [unleash/unleash-client-go](https://github.com/unleash/unleash-client-go)
- [unleash/unleash-client-ruby](https://github.com/unleash/unleash-client-ruby)
- [unleash/unleash-client-python](https://github.com/Unleash/unleash-client-python)
- [unleash/unleash-client-core](https://github.com/Unleash/unleash-client-core) (.Net Core)
### Clients written by awesome enthusiasts:
- [cognitedata/unleash-client-rust](https://github.com/cognitedata/unleash-client-rust) (Rust)
- [silvercar/unleash-client-kotlin](https://github.com/silvercar/unleash-client-kotlin) (Kotlin)
- [uekoetter.dev/unleash-client-dart](https://pub.dev/packages/unleash) (Dart)
- [minds/unleash-client-php](https://gitlab.com/minds/unleash-client-php) (PHP)
- [afontaine/unleash_ex](https://gitlab.com/afontaine/unleash_ex) (Elixir)
- [mikefrancis/laravel-unleash](https://github.com/mikefrancis/laravel-unleash) (Laravel - PHP)
- [AppsFlyer/clojure-unleash](https://github.com/AppsFlyer/unleash-client-clojure) (Clojure)
- [pmb0/nestjs-unleash](https://github.com/pmb0/nestjs-unleash) (NestJS - Node.js)
- _...your implementation for your favorite language._
<meta http-equiv="refresh" content="0; URL=//docs/sdks">

View File

@ -3,130 +3,10 @@ id: connect_sdk
title: Connect your SDK
---
In order to connect your application to Unleash you need to use a client SDK (software developer kit) for your programming language. The SDK will handle connecting to the Unleash server instance and retrieve feature toggles based upon your configuration. Both open-source and the Unleash enterprise offering utilize the same set of client SDKs.
<script>
window.location = '/docs/sdks';
</script>
If you are an Unleash customer, our hosted instances will always be a protected instance, you will therefore have to specify a client secret as the authorization header when you are connecting your client SDK, which you will receive from us when you sign up for one of our packages. In the open source version you must generate your own secret.
Please see <a href="/docs/sdks">/docs/sdks</a>
On this page you will find examples for connecting your application to the demo instance. If you are connecting to your own private instance you will have to remember to replace the client secret and the API url given in the examples.
We have examples for all official client SDKs:
- [Java SDK](https://github.com/Unleash/unleash-client-java)
- [Node.js SDK](https://github.com/Unleash/unleash-client-node)
- [.NET SDK](https://github.com/Unleash/unleash-client-dotnet)
- [Go SDK](https://github.com/Unleash/unleash-client-go)
- [Ruby SDK](https://github.com/Unleash/unleash-client-ruby)
- [Python SDK](https://github.com/Unleash/unleash-client-python)
When you get access to your instance we will provide you with your Client secret and your API url for your instance.
## Demo instance secrets
Our demo instance has the following settings use these in case you would like to connect your test-app to our demo environment.
### Client secret
```sh
56907a2fa53c1d16101d509a10b78e36190b0f918d9f122d
```
### API url:
```sh
https://app.unleash-hosted.com/demo/api/
```
### Test with curl:
```sh
curl https://app.unleash-hosted.com/demo/api/client/features \
-H "Authorization: 56907a2fa53c1d16101d509a10b78e36190b0f918d9f122d";
```
## Java SDK
```java
UnleashConfig unleashConfig = UnleashConfig.builder()
.appName("my.java-app")
.instanceId("your-instance-1")
.unleashAPI("<API url>")
.customHttpHeader("Authorization", "<client secret>")
.build();
Unleash unleash = new DefaultUnleash(config);
```
Read more at [github.com/Unleash/unleash-client-java](https://github.com/Unleash/unleash-client-java)
## Node.js SDK
```js
const unleash = require('unleash-client');
unleash.initialize({
url: '<API url>',
appName: 'my-node-name',
instanceId: 'my-unique-instance-id',
customHeaders: {'Authorization': '<Client secret>'}
});
```
Read more at [github.com/Unleash/unleash-client-node](https://github.com/Unleash/unleash-client-node)
## Go SDK
```golang
import (
"github.com/Unleash/unleash-client-go/v3"
)
func init() {
unleash.Initialize(
unleash.WithAppName("my-node-app"),
unleash.WithUrl("<API url>"),
unleash.WithCustomHeaders(http.Header{"Authorization": {"<Client secret>"}}),
)
}
```
Read more at [github.com/Unleash/unleash-client-go](https://github.com/Unleash/unleash-client-go)
## Ruby SDK
```ruby
require 'unleash'
@unleash = Unleash::Client.new(
url: '<API url>',
app_name: 'simple-test',
custom_http_headers = {'Authorization': '<Client secret>'},
)
```
Read more at [github.com/Unleash/unleash-client-ruby](https://github.com/Unleash/unleash-client-ruby)
## Python SDK
```python
from UnleashClient import UnleashClient
client = UnleashClient(
url="<API url>",
app_name="my-python-app",
custom_headers={'Authorization': '<Client secret>'})
client.initialize_client()
client.is_enabled("unleash.beta.variants")
```
Read more at [github.com/Unleash/unleash-client-python](https://github.com/Unleash/unleash-client-python)
## .NET SDK
```csharp
var settings = new UnleashSettings()
{
AppName = "dotnet-test",
InstanceTag = "instance z",
UnleashApi = new Uri("<API url>"),
SendMetricsInterval = TimeSpan.FromSeconds(20),
CustomHttpHeaders = new Dictionary<string, string>()
{
{"Authorization","<Client secret>" }
}
};
var unleash = new DefaultUnleash(settings);
```
Read more at [https://github.com/Unleash/unleash-client-dotnet](https://github.com/Unleash/unleash-client-dotnet)
<meta http-equiv="refresh" content="0; URL=//docs/sdks">