Skip to content

Commit 0a37e08

Browse files
committed
added lib
1 parent 0c601f9 commit 0a37e08

24 files changed

+1057
-16
lines changed

go.mod

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
1-
module github.com/LambdaTest/lambda-featureflag-go-sdk
1+
module github.com/chandrajeetn/lambda-flag-go-server
22

33
go 1.20
44

55
require (
6-
github.com/amplitude/experiment-go-server v1.1.2
76
github.com/joho/godotenv v1.5.1
8-
github.com/sirupsen/logrus v1.9.3
9-
gopkg.in/natefinch/lumberjack.v2 v2.2.1
107
)
11-
12-
require golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 // indirect

internal/evaluation/evaluation.go

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package evaluation
2+
3+
/*
4+
#cgo darwin,amd64 CFLAGS: -I${SRCDIR}/lib/macosX64
5+
#cgo darwin,amd64 LDFLAGS: -framework Foundation -lstdc++ -L${SRCDIR}/lib/macosX64 -levaluation_interop
6+
7+
#cgo darwin,arm64 CFLAGS: -I${SRCDIR}/lib/macosArm64
8+
#cgo darwin,arm64 LDFLAGS: -framework Foundation -lstdc++ -L${SRCDIR}/lib/macosArm64 -levaluation_interop
9+
10+
#cgo linux,amd64 CFLAGS: -I${SRCDIR}/lib/linuxX64
11+
#cgo linux,amd64 LDFLAGS: -L${SRCDIR}/lib/linuxX64 -levaluation_interop -lstdc++ -lpthread -lc -ldl -lm
12+
13+
#cgo linux,arm64 CFLAGS: -I${SRCDIR}/lib/linuxArm64
14+
#cgo linux,arm64 LDFLAGS: -L${SRCDIR}/lib/linuxArm64 -levaluation_interop -lstdc++ -lpthread -lc -ldl -lm
15+
16+
#include "libevaluation_interop_api.h"
17+
#include <stdlib.h>
18+
19+
typedef const char * (*evaluate) (const char * r, const char * u);
20+
typedef void (*DisposeString) (const char* s);
21+
22+
const char * bridge_evaluate(evaluate f, const char * r, const char * u)
23+
{
24+
return f(r, u);
25+
}
26+
27+
void bridge_dispose(DisposeString f, const char * s)
28+
{
29+
return f(s);
30+
}
31+
*/
32+
import "C"
33+
import (
34+
"unsafe"
35+
)
36+
37+
var lib = C.libevaluation_interop_symbols()
38+
var root = lib.kotlin.root
39+
40+
func Evaluate(rules, user string) string {
41+
rulesCString := C.CString(rules)
42+
userCString := C.CString(user)
43+
resultCString := C.bridge_evaluate(root.evaluate, rulesCString, userCString)
44+
result := C.GoString(resultCString)
45+
C.bridge_dispose(lib.DisposeString, resultCString)
46+
C.free(unsafe.Pointer(rulesCString))
47+
C.free(unsafe.Pointer(userCString))
48+
return result
49+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package linuxArm64
Binary file not shown.
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
#ifndef KONAN_LIBEVALUATION_INTEROP_H
2+
#define KONAN_LIBEVALUATION_INTEROP_H
3+
#ifdef __cplusplus
4+
extern "C" {
5+
#endif
6+
#ifdef __cplusplus
7+
typedef bool libevaluation_interop_KBoolean;
8+
#else
9+
typedef _Bool libevaluation_interop_KBoolean;
10+
#endif
11+
typedef unsigned short libevaluation_interop_KChar;
12+
typedef signed char libevaluation_interop_KByte;
13+
typedef short libevaluation_interop_KShort;
14+
typedef int libevaluation_interop_KInt;
15+
typedef long long libevaluation_interop_KLong;
16+
typedef unsigned char libevaluation_interop_KUByte;
17+
typedef unsigned short libevaluation_interop_KUShort;
18+
typedef unsigned int libevaluation_interop_KUInt;
19+
typedef unsigned long long libevaluation_interop_KULong;
20+
typedef float libevaluation_interop_KFloat;
21+
typedef double libevaluation_interop_KDouble;
22+
typedef float __attribute__ ((__vector_size__ (16))) libevaluation_interop_KVector128;
23+
typedef void* libevaluation_interop_KNativePtr;
24+
struct libevaluation_interop_KType;
25+
typedef struct libevaluation_interop_KType libevaluation_interop_KType;
26+
27+
typedef struct {
28+
libevaluation_interop_KNativePtr pinned;
29+
} libevaluation_interop_kref_kotlin_Byte;
30+
typedef struct {
31+
libevaluation_interop_KNativePtr pinned;
32+
} libevaluation_interop_kref_kotlin_Short;
33+
typedef struct {
34+
libevaluation_interop_KNativePtr pinned;
35+
} libevaluation_interop_kref_kotlin_Int;
36+
typedef struct {
37+
libevaluation_interop_KNativePtr pinned;
38+
} libevaluation_interop_kref_kotlin_Long;
39+
typedef struct {
40+
libevaluation_interop_KNativePtr pinned;
41+
} libevaluation_interop_kref_kotlin_Float;
42+
typedef struct {
43+
libevaluation_interop_KNativePtr pinned;
44+
} libevaluation_interop_kref_kotlin_Double;
45+
typedef struct {
46+
libevaluation_interop_KNativePtr pinned;
47+
} libevaluation_interop_kref_kotlin_Char;
48+
typedef struct {
49+
libevaluation_interop_KNativePtr pinned;
50+
} libevaluation_interop_kref_kotlin_Boolean;
51+
typedef struct {
52+
libevaluation_interop_KNativePtr pinned;
53+
} libevaluation_interop_kref_kotlin_Unit;
54+
typedef struct {
55+
libevaluation_interop_KNativePtr pinned;
56+
} libevaluation_interop_kref_kotlin_UByte;
57+
typedef struct {
58+
libevaluation_interop_KNativePtr pinned;
59+
} libevaluation_interop_kref_kotlin_UShort;
60+
typedef struct {
61+
libevaluation_interop_KNativePtr pinned;
62+
} libevaluation_interop_kref_kotlin_UInt;
63+
typedef struct {
64+
libevaluation_interop_KNativePtr pinned;
65+
} libevaluation_interop_kref_kotlin_ULong;
66+
67+
68+
typedef struct {
69+
/* Service functions. */
70+
void (*DisposeStablePointer)(libevaluation_interop_KNativePtr ptr);
71+
void (*DisposeString)(const char* string);
72+
libevaluation_interop_KBoolean (*IsInstance)(libevaluation_interop_KNativePtr ref, const libevaluation_interop_KType* type);
73+
libevaluation_interop_kref_kotlin_Byte (*createNullableByte)(libevaluation_interop_KByte);
74+
libevaluation_interop_KByte (*getNonNullValueOfByte)(libevaluation_interop_kref_kotlin_Byte);
75+
libevaluation_interop_kref_kotlin_Short (*createNullableShort)(libevaluation_interop_KShort);
76+
libevaluation_interop_KShort (*getNonNullValueOfShort)(libevaluation_interop_kref_kotlin_Short);
77+
libevaluation_interop_kref_kotlin_Int (*createNullableInt)(libevaluation_interop_KInt);
78+
libevaluation_interop_KInt (*getNonNullValueOfInt)(libevaluation_interop_kref_kotlin_Int);
79+
libevaluation_interop_kref_kotlin_Long (*createNullableLong)(libevaluation_interop_KLong);
80+
libevaluation_interop_KLong (*getNonNullValueOfLong)(libevaluation_interop_kref_kotlin_Long);
81+
libevaluation_interop_kref_kotlin_Float (*createNullableFloat)(libevaluation_interop_KFloat);
82+
libevaluation_interop_KFloat (*getNonNullValueOfFloat)(libevaluation_interop_kref_kotlin_Float);
83+
libevaluation_interop_kref_kotlin_Double (*createNullableDouble)(libevaluation_interop_KDouble);
84+
libevaluation_interop_KDouble (*getNonNullValueOfDouble)(libevaluation_interop_kref_kotlin_Double);
85+
libevaluation_interop_kref_kotlin_Char (*createNullableChar)(libevaluation_interop_KChar);
86+
libevaluation_interop_KChar (*getNonNullValueOfChar)(libevaluation_interop_kref_kotlin_Char);
87+
libevaluation_interop_kref_kotlin_Boolean (*createNullableBoolean)(libevaluation_interop_KBoolean);
88+
libevaluation_interop_KBoolean (*getNonNullValueOfBoolean)(libevaluation_interop_kref_kotlin_Boolean);
89+
libevaluation_interop_kref_kotlin_Unit (*createNullableUnit)(void);
90+
libevaluation_interop_kref_kotlin_UByte (*createNullableUByte)(libevaluation_interop_KUByte);
91+
libevaluation_interop_KUByte (*getNonNullValueOfUByte)(libevaluation_interop_kref_kotlin_UByte);
92+
libevaluation_interop_kref_kotlin_UShort (*createNullableUShort)(libevaluation_interop_KUShort);
93+
libevaluation_interop_KUShort (*getNonNullValueOfUShort)(libevaluation_interop_kref_kotlin_UShort);
94+
libevaluation_interop_kref_kotlin_UInt (*createNullableUInt)(libevaluation_interop_KUInt);
95+
libevaluation_interop_KUInt (*getNonNullValueOfUInt)(libevaluation_interop_kref_kotlin_UInt);
96+
libevaluation_interop_kref_kotlin_ULong (*createNullableULong)(libevaluation_interop_KULong);
97+
libevaluation_interop_KULong (*getNonNullValueOfULong)(libevaluation_interop_kref_kotlin_ULong);
98+
99+
/* User functions. */
100+
struct {
101+
struct {
102+
const char* (*evaluate)(const char* rules, const char* user);
103+
} root;
104+
} kotlin;
105+
} libevaluation_interop_ExportedSymbols;
106+
extern libevaluation_interop_ExportedSymbols* libevaluation_interop_symbols(void);
107+
#ifdef __cplusplus
108+
} /* extern "C" */
109+
#endif
110+
#endif /* KONAN_LIBEVALUATION_INTEROP_H */
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package linuxX64
Binary file not shown.
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
#ifndef KONAN_LIBEVALUATION_INTEROP_H
2+
#define KONAN_LIBEVALUATION_INTEROP_H
3+
#ifdef __cplusplus
4+
extern "C" {
5+
#endif
6+
#ifdef __cplusplus
7+
typedef bool libevaluation_interop_KBoolean;
8+
#else
9+
typedef _Bool libevaluation_interop_KBoolean;
10+
#endif
11+
typedef unsigned short libevaluation_interop_KChar;
12+
typedef signed char libevaluation_interop_KByte;
13+
typedef short libevaluation_interop_KShort;
14+
typedef int libevaluation_interop_KInt;
15+
typedef long long libevaluation_interop_KLong;
16+
typedef unsigned char libevaluation_interop_KUByte;
17+
typedef unsigned short libevaluation_interop_KUShort;
18+
typedef unsigned int libevaluation_interop_KUInt;
19+
typedef unsigned long long libevaluation_interop_KULong;
20+
typedef float libevaluation_interop_KFloat;
21+
typedef double libevaluation_interop_KDouble;
22+
typedef float __attribute__ ((__vector_size__ (16))) libevaluation_interop_KVector128;
23+
typedef void* libevaluation_interop_KNativePtr;
24+
struct libevaluation_interop_KType;
25+
typedef struct libevaluation_interop_KType libevaluation_interop_KType;
26+
27+
typedef struct {
28+
libevaluation_interop_KNativePtr pinned;
29+
} libevaluation_interop_kref_kotlin_Byte;
30+
typedef struct {
31+
libevaluation_interop_KNativePtr pinned;
32+
} libevaluation_interop_kref_kotlin_Short;
33+
typedef struct {
34+
libevaluation_interop_KNativePtr pinned;
35+
} libevaluation_interop_kref_kotlin_Int;
36+
typedef struct {
37+
libevaluation_interop_KNativePtr pinned;
38+
} libevaluation_interop_kref_kotlin_Long;
39+
typedef struct {
40+
libevaluation_interop_KNativePtr pinned;
41+
} libevaluation_interop_kref_kotlin_Float;
42+
typedef struct {
43+
libevaluation_interop_KNativePtr pinned;
44+
} libevaluation_interop_kref_kotlin_Double;
45+
typedef struct {
46+
libevaluation_interop_KNativePtr pinned;
47+
} libevaluation_interop_kref_kotlin_Char;
48+
typedef struct {
49+
libevaluation_interop_KNativePtr pinned;
50+
} libevaluation_interop_kref_kotlin_Boolean;
51+
typedef struct {
52+
libevaluation_interop_KNativePtr pinned;
53+
} libevaluation_interop_kref_kotlin_Unit;
54+
typedef struct {
55+
libevaluation_interop_KNativePtr pinned;
56+
} libevaluation_interop_kref_kotlin_UByte;
57+
typedef struct {
58+
libevaluation_interop_KNativePtr pinned;
59+
} libevaluation_interop_kref_kotlin_UShort;
60+
typedef struct {
61+
libevaluation_interop_KNativePtr pinned;
62+
} libevaluation_interop_kref_kotlin_UInt;
63+
typedef struct {
64+
libevaluation_interop_KNativePtr pinned;
65+
} libevaluation_interop_kref_kotlin_ULong;
66+
67+
68+
typedef struct {
69+
/* Service functions. */
70+
void (*DisposeStablePointer)(libevaluation_interop_KNativePtr ptr);
71+
void (*DisposeString)(const char* string);
72+
libevaluation_interop_KBoolean (*IsInstance)(libevaluation_interop_KNativePtr ref, const libevaluation_interop_KType* type);
73+
libevaluation_interop_kref_kotlin_Byte (*createNullableByte)(libevaluation_interop_KByte);
74+
libevaluation_interop_KByte (*getNonNullValueOfByte)(libevaluation_interop_kref_kotlin_Byte);
75+
libevaluation_interop_kref_kotlin_Short (*createNullableShort)(libevaluation_interop_KShort);
76+
libevaluation_interop_KShort (*getNonNullValueOfShort)(libevaluation_interop_kref_kotlin_Short);
77+
libevaluation_interop_kref_kotlin_Int (*createNullableInt)(libevaluation_interop_KInt);
78+
libevaluation_interop_KInt (*getNonNullValueOfInt)(libevaluation_interop_kref_kotlin_Int);
79+
libevaluation_interop_kref_kotlin_Long (*createNullableLong)(libevaluation_interop_KLong);
80+
libevaluation_interop_KLong (*getNonNullValueOfLong)(libevaluation_interop_kref_kotlin_Long);
81+
libevaluation_interop_kref_kotlin_Float (*createNullableFloat)(libevaluation_interop_KFloat);
82+
libevaluation_interop_KFloat (*getNonNullValueOfFloat)(libevaluation_interop_kref_kotlin_Float);
83+
libevaluation_interop_kref_kotlin_Double (*createNullableDouble)(libevaluation_interop_KDouble);
84+
libevaluation_interop_KDouble (*getNonNullValueOfDouble)(libevaluation_interop_kref_kotlin_Double);
85+
libevaluation_interop_kref_kotlin_Char (*createNullableChar)(libevaluation_interop_KChar);
86+
libevaluation_interop_KChar (*getNonNullValueOfChar)(libevaluation_interop_kref_kotlin_Char);
87+
libevaluation_interop_kref_kotlin_Boolean (*createNullableBoolean)(libevaluation_interop_KBoolean);
88+
libevaluation_interop_KBoolean (*getNonNullValueOfBoolean)(libevaluation_interop_kref_kotlin_Boolean);
89+
libevaluation_interop_kref_kotlin_Unit (*createNullableUnit)(void);
90+
libevaluation_interop_kref_kotlin_UByte (*createNullableUByte)(libevaluation_interop_KUByte);
91+
libevaluation_interop_KUByte (*getNonNullValueOfUByte)(libevaluation_interop_kref_kotlin_UByte);
92+
libevaluation_interop_kref_kotlin_UShort (*createNullableUShort)(libevaluation_interop_KUShort);
93+
libevaluation_interop_KUShort (*getNonNullValueOfUShort)(libevaluation_interop_kref_kotlin_UShort);
94+
libevaluation_interop_kref_kotlin_UInt (*createNullableUInt)(libevaluation_interop_KUInt);
95+
libevaluation_interop_KUInt (*getNonNullValueOfUInt)(libevaluation_interop_kref_kotlin_UInt);
96+
libevaluation_interop_kref_kotlin_ULong (*createNullableULong)(libevaluation_interop_KULong);
97+
libevaluation_interop_KULong (*getNonNullValueOfULong)(libevaluation_interop_kref_kotlin_ULong);
98+
99+
/* User functions. */
100+
struct {
101+
struct {
102+
const char* (*evaluate)(const char* rules, const char* user);
103+
} root;
104+
} kotlin;
105+
} libevaluation_interop_ExportedSymbols;
106+
extern libevaluation_interop_ExportedSymbols* libevaluation_interop_symbols(void);
107+
#ifdef __cplusplus
108+
} /* extern "C" */
109+
#endif
110+
#endif /* KONAN_LIBEVALUATION_INTEROP_H */
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package macosArm64
Binary file not shown.

0 commit comments

Comments
 (0)