amplitude-experiment 1.4.0 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/amplitude-experiment.gemspec +7 -6
  3. data/lib/amplitude-experiment.rb +16 -2
  4. data/lib/experiment/cohort/cohort.rb +25 -0
  5. data/lib/experiment/cohort/cohort_download_api.rb +90 -0
  6. data/lib/experiment/cohort/cohort_loader.rb +39 -0
  7. data/lib/experiment/cohort/cohort_storage.rb +91 -0
  8. data/lib/experiment/cohort/cohort_sync_config.rb +27 -0
  9. data/lib/experiment/deployment/deployment_runner.rb +135 -0
  10. data/lib/experiment/error.rb +23 -0
  11. data/lib/experiment/evaluation/evaluation.rb +311 -0
  12. data/lib/experiment/evaluation/flag.rb +123 -0
  13. data/lib/experiment/evaluation/murmur3.rb +104 -0
  14. data/lib/experiment/evaluation/select.rb +16 -0
  15. data/lib/experiment/evaluation/semantic_version.rb +52 -0
  16. data/lib/experiment/evaluation/topological_sort.rb +56 -0
  17. data/lib/experiment/{local/fetcher.rb → flag/flag_config_fetcher.rb} +7 -5
  18. data/lib/experiment/flag/flag_config_storage.rb +53 -0
  19. data/lib/experiment/local/client.rb +68 -29
  20. data/lib/experiment/local/config.rb +26 -2
  21. data/lib/experiment/persistent_http_client.rb +1 -1
  22. data/lib/experiment/remote/client.rb +8 -6
  23. data/lib/experiment/remote/config.rb +8 -1
  24. data/lib/experiment/user.rb +40 -20
  25. data/lib/experiment/util/flag_config.rb +60 -0
  26. data/lib/experiment/util/poller.rb +24 -0
  27. data/lib/experiment/util/user.rb +20 -12
  28. data/lib/experiment/version.rb +1 -1
  29. metadata +44 -25
  30. data/lib/experiment/local/evaluation/evaluation.rb +0 -76
  31. data/lib/experiment/local/evaluation/lib/linuxArm64/libevaluation_interop.so +0 -0
  32. data/lib/experiment/local/evaluation/lib/linuxArm64/libevaluation_interop_api.h +0 -110
  33. data/lib/experiment/local/evaluation/lib/linuxX64/libevaluation_interop.so +0 -0
  34. data/lib/experiment/local/evaluation/lib/linuxX64/libevaluation_interop_api.h +0 -110
  35. data/lib/experiment/local/evaluation/lib/macosArm64/libevaluation_interop.dylib +0 -0
  36. data/lib/experiment/local/evaluation/lib/macosArm64/libevaluation_interop_api.h +0 -110
  37. data/lib/experiment/local/evaluation/lib/macosX64/libevaluation_interop.dylib +0 -0
  38. data/lib/experiment/local/evaluation/lib/macosX64/libevaluation_interop_api.h +0 -110
  39. data/lib/experiment/util/topological_sort.rb +0 -39
@@ -1,110 +0,0 @@
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* flags, const char* context);
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 */
@@ -1,39 +0,0 @@
1
- module AmplitudeExperiment
2
- def self.topological_sort(flags, keys = nil, ordered: false)
3
- available = flags.dup
4
- result = []
5
- starting_keys = keys.nil? || keys.empty? ? flags.keys : keys
6
- # Used for testing to ensure consistency.
7
- starting_keys.sort! if ordered && (keys.nil? || keys.empty?)
8
-
9
- starting_keys.each do |flag_key|
10
- traversal = parent_traversal(flag_key, available, Set.new)
11
- result.concat(traversal) unless traversal.nil?
12
- end
13
- result
14
- end
15
-
16
- def self.parent_traversal(flag_key, available, path)
17
- flag = available[flag_key]
18
- return nil if flag.nil?
19
-
20
- dependencies = flag['dependencies']
21
- if dependencies.nil? || dependencies.empty?
22
- available.delete(flag_key)
23
- return [flag]
24
- end
25
-
26
- path.add(flag_key)
27
- result = []
28
- dependencies.each do |parent_key|
29
- raise CycleError, path if path.include?(parent_key)
30
-
31
- traversal = parent_traversal(parent_key, available, path)
32
- result.concat(traversal) unless traversal.nil?
33
- end
34
- result << flag
35
- path.delete(flag_key)
36
- available.delete(flag_key)
37
- result
38
- end
39
- end