Skip to content

Commit 50053f4

Browse files
committed
Fill out README
1 parent 4982d31 commit 50053f4

File tree

1 file changed

+74
-1
lines changed

1 file changed

+74
-1
lines changed

README.md

Lines changed: 74 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,76 @@
11
# Unleash SDK
22

3-
## Library for interacting with Unleash feature flags
3+
## Library for interacting with [Unleash](https://www.getunleash.io/) feature flags
4+
5+
### Requirements
6+
7+
Adobe ColdFusion 2018+
8+
Lucee 5+
9+
ColdBox 6+
10+
11+
This module takes heavy advantage of ColdBox's async scheduling. There are no plans to make this module work outside of ColdBox.
12+
13+
### Configuration
14+
15+
Here are the settings for the UnleashSDK:
16+
17+
```cfc
18+
settings = {
19+
"appName": getApplicationName(), // Defaults to `this.name` in `Application.cfc`.
20+
"instanceId": resolveHostname(), // Attempts to resolve the hostname. "unknown", otherwise.
21+
"environment": variables.controller.getSetting( "environment" ),
22+
"contextProvider": "DefaultContextProvider@unleashsdk",
23+
"apiURL": getSystemSetting( "UNLEASH_API_URL" ),
24+
"apiToken": getSystemSetting( "UNLEASH_API_TOKEN" ),
25+
"refreshInterval": 10,
26+
"metricsInterval": 60
27+
}
28+
```
29+
30+
Any of these settings can be overridden inside your `config/ColdBox.cfc`.
31+
If you don't need to modify the default settings, you can supply your Unleash
32+
configuration directly through environment variables via `UNLEASH_API_URL` and `UNLEASH_API_TOKEN`.
33+
34+
### Usage
35+
36+
The main usage of the UnleashSDK is checking if a feature flag is enabled. This is done using the `isEnabled` method.
37+
(There is also a helper `isDisabled` method for your convenience.)
38+
39+
#### `isEnabled`
40+
41+
Evaluates the feature with the current and provided context to determine if it is enabled for the current request.
42+
43+
Returns: `boolean`
44+
45+
| Name | Type | Required | Default | Description |
46+
| ----------------- | ------- | -------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------ |
47+
| name | string | true | | The name of the feature flag to evaluate |
48+
| additionalContext | struct | false | `{}` | Any additional context items for this check. This struct will override any duplicate keys in the context from the `ContextProvider`. |
49+
| defaultValue | boolean | false | `false` | The default value to use if the feature does not exist. |
50+
51+
### Context and ContextProviders
52+
53+
Context refers to information about the current request that Unleash will use when
54+
evaluating feature toggles. Context includes the following fields:
55+
56+
```cfc
57+
context = {
58+
"appName" : getApplicationName(), // Defaults to `this.name` in `Application.cfc`
59+
"environment" : variables.environment, // `controller.getSetting( "environment" )`
60+
"userId" : "",
61+
"sessionId" : getSessionId(), // `session.sessionid`
62+
"remoteAddress" : CGI.REMOTE_ADDR,
63+
"hostname" : resolveHostname() // Attempts to resolve the hostname. "unknown", otherwise.
64+
};
65+
```
66+
67+
Context is generated using a `ContextProvider` and/or the `context` arguments to `isEnabled`.
68+
The `context` provided to `isEnabled` will overwrite any duplicate keys in the context
69+
generated by the `ContextProvider`.
70+
71+
A `ContextProvider` is a component with `getContext()` method. That method should return
72+
the context fields shown above.
73+
74+
You can register a custom `ContextProvider` by the setting `contextProvider` in your `config/ColdBox.cfc`.
75+
A custom `ContextProvider` can enabled you to always provide specific user or session information
76+
for your application without having to pass it in manually each time you call `isEnabled`.

0 commit comments

Comments
 (0)