Skip to content

Commit 0c159a8

Browse files
author
LaunchDarklyReleaseBot
committed
Releasing version 1.2.1
1 parent 05aeef5 commit 0c159a8

File tree

4 files changed

+1381
-1
lines changed

4 files changed

+1381
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
All notable changes to the LaunchDarkly Lua Server-side SDK will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org).
44

5+
## [1.2.1] - 2022-02-08
6+
### Changed:
7+
- Updated release configuration.
8+
59
## [1.2.0] - 2022-02-07
610
### Added:
711
- Added `version()` function to retrieve SDK version

launchdarkly-server-sdk.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Server-side SDK for LaunchDarkly.
1111

1212
#include <launchdarkly/api.h>
1313

14-
#define SDKVersion "1.2.0"
14+
#define SDKVersion "1.2.1"
1515

1616
static struct LDJSON *
1717
LuaValueToJSON(lua_State *const l, const int i);
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
/***
2+
Server-side SDK for LaunchDarkly Redis store.
3+
@module launchdarkly-server-sdk-redis
4+
*/
5+
6+
#include <lua.h>
7+
#include <lauxlib.h>
8+
#include <stdlib.h>
9+
#include <stdbool.h>
10+
#include <string.h>
11+
12+
#include <launchdarkly/api.h>
13+
#include <launchdarkly/store/redis.h>
14+
15+
/***
16+
Initialize a store backend
17+
@function makeStore
18+
@tparam table fields list of configuration options
19+
@tparam[opt] string fields.host Hostname for Redis.
20+
@tparam[opt] int fields.port Port for Redis.
21+
@tparam[opt] string fields.prefix Redis key prefix for SDK values.
22+
@tparam[opt] int fields.poolSize Number of Redis connections to maintain.
23+
@return A fresh Redis store backend.
24+
*/
25+
static int
26+
LuaLDRedisMakeStore(lua_State *const l)
27+
{
28+
struct LDRedisConfig *config;
29+
struct LDStoreInterface *storeInterface;
30+
31+
if (lua_gettop(l) != 1) {
32+
return luaL_error(l, "expecting exactly 1 argument");
33+
}
34+
35+
luaL_checktype(l, 1, LUA_TTABLE);
36+
37+
config = LDRedisConfigNew();
38+
39+
lua_getfield(l, 1, "host");
40+
41+
if (lua_isstring(l, -1)) {
42+
LDRedisConfigSetHost(config, luaL_checkstring(l, -1));
43+
}
44+
45+
lua_getfield(l, 1, "prefix");
46+
47+
if (lua_isstring(l, -1)) {
48+
LDRedisConfigSetPrefix(config, luaL_checkstring(l, -1));
49+
}
50+
51+
lua_getfield(l, 1, "port");
52+
53+
if (lua_isnumber(l, -1)) {
54+
LDRedisConfigSetPort(config, luaL_checkinteger(l, -1));
55+
}
56+
57+
lua_getfield(l, 1, "poolSize");
58+
59+
if (lua_isnumber(l, -1)) {
60+
LDRedisConfigSetPoolSize(config, luaL_checkinteger(l, -1));
61+
}
62+
63+
storeInterface = LDStoreInterfaceRedisNew(config);
64+
65+
struct LDStoreInterface **i =
66+
(struct LDStoreInterface **)lua_newuserdata(l, sizeof(storeInterface));
67+
68+
*i = storeInterface;
69+
70+
luaL_getmetatable(l, "LaunchDarklyStoreInterface");
71+
lua_setmetatable(l, -2);
72+
73+
return 1;
74+
}
75+
76+
static const struct luaL_Reg launchdarkly_functions[] = {
77+
{ "makeStore", LuaLDRedisMakeStore },
78+
{ NULL, NULL }
79+
};
80+
81+
#if !defined LUA_VERSION_NUM || LUA_VERSION_NUM==501
82+
/*
83+
** Adapted from Lua 5.2.0
84+
*/
85+
static void luaL_setfuncs (lua_State *L, const luaL_Reg *l, int nup) {
86+
luaL_checkstack(L, nup+1, "too many upvalues");
87+
for (; l->name != NULL; l++) { /* fill the table with given functions */
88+
int i;
89+
lua_pushstring(L, l->name);
90+
for (i = 0; i < nup; i++) /* copy upvalues to the top */
91+
lua_pushvalue(L, -(nup+1));
92+
lua_pushcclosure(L, l->func, nup); /* closure with those upvalues */
93+
lua_settable(L, -(nup + 3));
94+
}
95+
lua_pop(L, nup); /* remove upvalues */
96+
}
97+
#endif
98+
99+
int
100+
luaopen_launchdarkly_server_sdk_redis(lua_State *const l)
101+
{
102+
#if LUA_VERSION_NUM == 503 || LUA_VERSION_NUM == 502
103+
luaL_newlib(l, launchdarkly_functions);
104+
#else
105+
luaL_register(l, "launchdarkly-server-sdk-redis",
106+
launchdarkly_functions);
107+
#endif
108+
109+
return 1;
110+
}

0 commit comments

Comments
 (0)