mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-25 00:07:47 +01:00
docs: remove references to deprecated proxy config variable (#1902)
This commit is contained in:
parent
a34c674971
commit
b06cbb0f75
@ -16,7 +16,6 @@ In this example we want to define an activation strategy offers a scheduled rele
|
|||||||
|
|
||||||
![A strategy creation form. It has fields labeled "strategy name" — "TimeStamp" — and "description" — "activate toggle after a given timestamp". It also has fields for a parameter named "enableAfter". The parameter is of type "string" and the parameter description is "Expected format: YYYY-MM-DD HH:MM". The parameter is required.](/img/timestamp_create_strategy.png)
|
![A strategy creation form. It has fields labeled "strategy name" — "TimeStamp" — and "description" — "activate toggle after a given timestamp". It also has fields for a parameter named "enableAfter". The parameter is of type "string" and the parameter description is "Expected format: YYYY-MM-DD HH:MM". The parameter is required.](/img/timestamp_create_strategy.png)
|
||||||
|
|
||||||
|
|
||||||
## Step 2: Apply your custom strategy to a feature toggle {#step-2}
|
## Step 2: Apply your custom strategy to a feature toggle {#step-2}
|
||||||
|
|
||||||
**Navigate to your feature toggle** and **apply the strategy** you just created.
|
**Navigate to your feature toggle** and **apply the strategy** you just created.
|
||||||
@ -27,8 +26,8 @@ In this example we want to define an activation strategy offers a scheduled rele
|
|||||||
|
|
||||||
The steps to implement a custom strategy for your client depend on the kind of client SDK you're using:
|
The steps to implement a custom strategy for your client depend on the kind of client SDK you're using:
|
||||||
|
|
||||||
- if you're using a server-side client SDK, follow the steps in [option A](#step-3-a "Step 3 option A: implement the strategy for a server-side client SDK").
|
- if you're using a server-side client SDK, follow the steps in [option A](#step-3-a 'Step 3 option A: implement the strategy for a server-side client SDK').
|
||||||
- if you're using a front-end client SDK ([Android](../sdks/android-proxy.md), [JavaScript](../sdks/proxy-javascript.md), [React](../sdks/proxy-react.md), [iOS](../sdks/proxy-ios.md)), follow the steps in [option B](#step-3-b "Step 3 option B: implementing the strategy for a front-end client SDK")
|
- if you're using a front-end client SDK ([Android](../sdks/android-proxy.md), [JavaScript](../sdks/proxy-javascript.md), [React](../sdks/proxy-react.md), [iOS](../sdks/proxy-ios.md)), follow the steps in [option B](#step-3-b 'Step 3 option B: implementing the strategy for a front-end client SDK')
|
||||||
|
|
||||||
### Option A: Implement the strategy for a server-side client SDK {#step-3-a}
|
### Option A: Implement the strategy for a server-side client SDK {#step-3-a}
|
||||||
|
|
||||||
@ -78,12 +77,12 @@ The steps to implement a custom strategy for your client depend on the kind of c
|
|||||||
console.log(isEnabled('demo.TimeStampRollout'));
|
console.log(isEnabled('demo.TimeStampRollout'));
|
||||||
}, 1000);
|
}, 1000);
|
||||||
});
|
});
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Option B: Implement the strategy for a front-end client SDK {#step-3-b}
|
### Option B: Implement the strategy for a front-end client SDK {#step-3-b}
|
||||||
|
|
||||||
Front-end client SDKs don't evaluate strategies directly, so you need to implement the **custom strategy in the [Unleash Proxy](../sdks/unleash-proxy.md)**. Depending on how you run the Unleash Proxy, follow one of the below series of steps:
|
Front-end client SDKs don't evaluate strategies directly, so you need to implement the **custom strategy in the [Unleash Proxy](../sdks/unleash-proxy.md)**. Depending on how you run the Unleash Proxy, follow one of the below series of steps:
|
||||||
|
|
||||||
- If you're running the Unleash Proxy as a Docker container, refer to the [steps for using a containerized Proxy](#step-3-b-docker).
|
- If you're running the Unleash Proxy as a Docker container, refer to the [steps for using a containerized Proxy](#step-3-b-docker).
|
||||||
- If you're using the Unleash Proxy via Node.js, refer to the [steps for using custom strategies via Node.js](#step-3-b-node).
|
- If you're using the Unleash Proxy via Node.js, refer to the [steps for using custom strategies via Node.js](#step-3-b-node).
|
||||||
|
|
||||||
@ -94,14 +93,14 @@ Strategies are stored in separate JavaScript files and loaded into the container
|
|||||||
1. **Create a strategies directory.** Create a directory that Docker has access to where you can store your strategies. The next steps assume you called it `strategies`
|
1. **Create a strategies directory.** Create a directory that Docker has access to where you can store your strategies. The next steps assume you called it `strategies`
|
||||||
2. **Initialize a Node.js project** and **install the Unleash Client**:
|
2. **Initialize a Node.js project** and **install the Unleash Client**:
|
||||||
|
|
||||||
``` shell npm2yarn
|
```shell npm2yarn
|
||||||
npm init -y && \
|
npm init -y && \
|
||||||
npm install unleash-client
|
npm install unleash-client
|
||||||
```
|
```
|
||||||
|
|
||||||
3. **Create a strategy file** and **implement your strategies**. Remember to **export your list of strategies**. The next steps will assume you called the file `timestamp.js`. An example implementation looks like this:
|
3. **Create a strategy file** and **implement your strategies**. Remember to **export your list of strategies**. The next steps will assume you called the file `timestamp.js`. An example implementation looks like this:
|
||||||
|
|
||||||
``` js
|
```js
|
||||||
const { Strategy } = require('unleash-client');
|
const { Strategy } = require('unleash-client');
|
||||||
|
|
||||||
class TimeStampStrategy extends Strategy {
|
class TimeStampStrategy extends Strategy {
|
||||||
@ -119,9 +118,9 @@ Strategies are stored in separate JavaScript files and loaded into the container
|
|||||||
|
|
||||||
4. **Mount the strategies directory** and **point the [Unleash Proxy docker container](https://hub.docker.com/r/unleashorg/unleash-proxy) at your strategies file**. The highlighted lines below show the extra options you need to add. The following command assumes that your strategies directory is a direct subdirectory of your current working directory. Modify the rest of the command to suit your needs.
|
4. **Mount the strategies directory** and **point the [Unleash Proxy docker container](https://hub.docker.com/r/unleashorg/unleash-proxy) at your strategies file**. The highlighted lines below show the extra options you need to add. The following command assumes that your strategies directory is a direct subdirectory of your current working directory. Modify the rest of the command to suit your needs.
|
||||||
|
|
||||||
``` shell
|
```shell
|
||||||
docker run --name unleash-proxy --pull=always \
|
docker run --name unleash-proxy --pull=always \
|
||||||
-e UNLEASH_PROXY_SECRETS=some-secret \
|
-e UNLEASH_PROXY_CLIENT_KEYS=some-secret \
|
||||||
-e UNLEASH_URL='http://unleash:4242/api/' \
|
-e UNLEASH_URL='http://unleash:4242/api/' \
|
||||||
-e UNLEASH_API_TOKEN=${API_TOKEN} \
|
-e UNLEASH_API_TOKEN=${API_TOKEN} \
|
||||||
# highlight-start
|
# highlight-start
|
||||||
@ -137,13 +136,13 @@ The Unleash Proxy accepts a `customStrategies` property as part of its initializ
|
|||||||
|
|
||||||
1. **Install the `unleash-client` package**. You'll need this to implement the custom strategy:
|
1. **Install the `unleash-client` package**. You'll need this to implement the custom strategy:
|
||||||
|
|
||||||
``` shell npm2yarn
|
```shell npm2yarn
|
||||||
npm install unleash-client
|
npm install unleash-client
|
||||||
```
|
```
|
||||||
|
|
||||||
2. **Implement your strategy**. You can import it from a different file or put it in the same file as the Proxy initialization. For instance, a `TimeStampStrategy` could look like this:
|
2. **Implement your strategy**. You can import it from a different file or put it in the same file as the Proxy initialization. For instance, a `TimeStampStrategy` could look like this:
|
||||||
|
|
||||||
``` js
|
```js
|
||||||
const { Strategy } = require('unleash-client');
|
const { Strategy } = require('unleash-client');
|
||||||
|
|
||||||
class TimeStampStrategy extends Strategy {
|
class TimeStampStrategy extends Strategy {
|
||||||
@ -159,7 +158,7 @@ The Unleash Proxy accepts a `customStrategies` property as part of its initializ
|
|||||||
|
|
||||||
3. **Pass the strategy to the Proxy Client** using the **`customStrategies`** option. A full code example:
|
3. **Pass the strategy to the Proxy Client** using the **`customStrategies`** option. A full code example:
|
||||||
|
|
||||||
``` javascript
|
```javascript
|
||||||
const { createApp } = require('@unleash/proxy');
|
const { createApp } = require('@unleash/proxy');
|
||||||
const { Strategy } = require('unleash-client');
|
const { Strategy } = require('unleash-client');
|
||||||
|
|
||||||
@ -177,11 +176,12 @@ The Unleash Proxy accepts a `customStrategies` property as part of its initializ
|
|||||||
|
|
||||||
const app = createApp({
|
const app = createApp({
|
||||||
unleashUrl: 'https://app.unleash-hosted.com/demo/api/',
|
unleashUrl: 'https://app.unleash-hosted.com/demo/api/',
|
||||||
unleashApiToken: '*:default.56907a2fa53c1d16101d509a10b78e36190b0f918d9f122d',
|
unleashApiToken:
|
||||||
proxySecrets: ['proxy-secret', 'another-proxy-secret', 's1'],
|
'*:default.56907a2fa53c1d16101d509a10b78e36190b0f918d9f122d',
|
||||||
|
clientKeys: ['proxy-secret', 'another-proxy-secret', 's1'],
|
||||||
refreshInterval: 1000,
|
refreshInterval: 1000,
|
||||||
// highlight-next-line
|
// highlight-next-line
|
||||||
customStrategies: [new TimeStampStrategy()]
|
customStrategies: [new TimeStampStrategy()],
|
||||||
});
|
});
|
||||||
|
|
||||||
app.listen(port, () =>
|
app.listen(port, () =>
|
||||||
|
@ -282,7 +282,7 @@ Follow steps outlined in the [Run Unleash with Docker](#run-unleash-with-docker)
|
|||||||
|
|
||||||
```sh
|
```sh
|
||||||
docker run \
|
docker run \
|
||||||
-e UNLEASH_PROXY_SECRETS=some-secret \
|
-e UNLEASH_PROXY_CLIENT_KEYS=some-secret \
|
||||||
-e UNLEASH_URL='http://unleash:4242/api/' \
|
-e UNLEASH_URL='http://unleash:4242/api/' \
|
||||||
-e UNLEASH_API_TOKEN='${API_KEY}' \
|
-e UNLEASH_API_TOKEN='${API_KEY}' \
|
||||||
-p 3000:3000 \
|
-p 3000:3000 \
|
||||||
|
Loading…
Reference in New Issue
Block a user