File tree Expand file tree Collapse file tree 2 files changed +60
-0
lines changed
examples/hello-lua-server Expand file tree Collapse file tree 2 files changed +60
-0
lines changed Original file line number Diff line number Diff line change 95
95
# what the C++ Server-side SDK shared object expects. Same for hiredis which is bundled
96
96
# with the SDK release.
97
97
LD_LIBRARY_PATH : ${{ steps.install-boost.outputs.BOOST_ROOT }}/lib;./cpp-sdk/build-dynamic/release/lib
98
+
99
+ - name : Run hello-lua-server example
100
+ if : ${{ !contains(inputs.lua-version, 'jit') }}
101
+ shell : bash
102
+ env :
103
+ LD_SDK_KEY : " fake-sdk-key"
104
+ # Needed because boost isn't installed in default system paths, which is
105
+ # what the C++ Server-side SDK shared object expects.
106
+ LD_LIBRARY_PATH : ${{ steps.install-boost.outputs.BOOST_ROOT }}/lib
107
+ run : |
108
+ lua ./examples/hello-lua-server/hello.lua
109
+
110
+
111
+ - name : Run hello-lua-server example (JIT)
112
+ if : ${{ contains(inputs.lua-version, 'jit') }}
113
+ shell : bash
114
+ env :
115
+ LD_SDK_KEY : " fake-sdk-key"
116
+ # Needed because boost isn't installed in default system paths, which is
117
+ # what the C++ Server-side SDK shared object expects.
118
+ LD_LIBRARY_PATH : ${{ steps.install-boost.outputs.BOOST_ROOT }}/lib
119
+ run : |
120
+ luajit ./examples/hello-lua-server/hello.lua
Original file line number Diff line number Diff line change
1
+ local ld = require (" launchdarkly_server_sdk" )
2
+
3
+ -- Allows the LaunchDarkly SDK key to be specified as an environment variable (LD_SDK_KEY)
4
+ -- or locally in this example code (YOUR_SDK_KEY).
5
+ function get_key_from_env_or (existing_key )
6
+ if existing_key ~= " " then
7
+ return existing_key
8
+ end
9
+
10
+ local env_key = os.getenv (" LD_SDK_KEY" )
11
+ if env_key ~= " " then
12
+ return env_key
13
+ end
14
+
15
+ error (" No SDK key specified (use LD_SDK_KEY environment variable or set local YOUR_SDK_KEY)" )
16
+ end
17
+
18
+ -- Set YOUR_SDK_KEY to your LaunchDarkly SDK key.
19
+ local YOUR_SDK_KEY = " "
20
+
21
+ -- Set YOUR_FEATURE_KEY to the feature flag key you want to evaluate.
22
+ local YOUR_FEATURE_KEY = " my-boolean-flag"
23
+
24
+
25
+ local config = {}
26
+
27
+ local client = ld .clientInit (get_key_from_env_or (YOUR_SDK_KEY ), 1000 , config )
28
+
29
+ local user = ld .makeContext ({
30
+ user = {
31
+ key = " example-user-key" ,
32
+ name = " Sandy"
33
+ }
34
+ })
35
+
36
+ local value = client :boolVariation (user , YOUR_FEATURE_KEY , false )
37
+ print (" feature flag " .. YOUR_FEATURE_KEY .. " is " .. tostring (value ).. " for this user" )
You can’t perform that action at this time.
0 commit comments