tailslide 0.1.4 → 0.1.5

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d317d72da4b918e8c57feaf8072884cbc8ecdcb10ab3e49eefc9a392cb7a71ce
4
- data.tar.gz: 4edf3d36bf65775916ed49d79ff8c28bd128c91c630bde5b21091353df495d2e
3
+ metadata.gz: 8d2f6a5d7784ee42f886c0b8e6565c283c49bdfd3b013bfa272380883f53f223
4
+ data.tar.gz: ead54dc39be41c0447981804958504b5454ee293e53709876bbfb55a3adbf50a
5
5
  SHA512:
6
- metadata.gz: 796bfd026bb228dd49a089a8ed87b8785bc21e7e667e2b6c4f3237a0b3e4de41f3ace73be4efb3b9161baf2c187abb66a74a7f21f8f76c906fef554b1d230659
7
- data.tar.gz: 41884a753fed4a3e7c77773ef76059f3cdb1ccd9e63b56cd5efa5ab040590d1726cd1862153ef0eed06eb342d19e5b61868f50a6c2fc17a2c5ef6b6776fc1345
6
+ metadata.gz: 41643f574dbc72661251707830be8abaf2ffa967d2828becbb85343a28b6346902a493ba52eb53c687c665b7ba8bd12b4bcc7dc2cca59d1a6a369286bebbefd7
7
+ data.tar.gz: 44647ce3c20988c60ea938e8d23de87e0639006a470c8711156964517b7ba9c1db05ec976855d5c340e679ac60c2a26ca0ec89999e13fc52eeeb2420e38031e5
data/README.md CHANGED
@@ -55,7 +55,7 @@ After instantiating a `FlagManager`, invoke the `initialize` method. This method
55
55
 
56
56
  ### Using Feature Flag with Toggler
57
57
 
58
- Once the `FlagManager` is initialized, it can create a `Toggler`, with the `new_toggler` method, for each feature flag that the developer wants to wrap the new and old features in. A `Toggler`’s `is_flag_active` method checks whether the flag with its `flag_name` is active or not based on the flag ruleset. A `Toggler`’s `is_flag_active` method returns a boolean value, which is intended to be used to control branching logic flow within an application at runtime, to invoke new features.
58
+ Once the `FlagManager` is initialized, it can create a `Toggler`, with the `new_toggler` method, for each feature flag that the developer wants to wrap the new and old features in. A `Toggler`’s `is_flag_active` method checks whether the flag with its `flag_name` is active or not based on the flag ruleset. A `Toggler`’s `is_flag_active` method returns a boolean value, which can be used to evaluate whether a new feature should be used or not.
59
59
 
60
60
  ```ruby
61
61
  flag_config = {
@@ -75,7 +75,7 @@ end
75
75
 
76
76
  ### Emitting Success or Failture
77
77
 
78
- To use the `Toggler` instances to record successful or failed operations, call its `emit_success` or `emit_failure` methods:
78
+ To use a `Toggler` instance to record successful or failed operations, call its `emit_success` or `emit_failure` methods:
79
79
 
80
80
  ```ruby
81
81
  if successCondition
@@ -98,7 +98,8 @@ The `FlagManager` class is the entry point of the SDK. A new `FlagManager` objec
98
98
  **Parameters:**
99
99
 
100
100
  - An object with the following keys
101
- - `server` a string that represents the URL and port of the NATS server.
101
+ - `nats_server` is the NATS JetStream server `address:port`
102
+ - `nats_stream` is the NATS JetStream’s stream name that stores all the apps and their flag rulesets
102
103
  - `app_id` a number representing the application the microservice belongs to
103
104
  - `sdk_key` a string generated via the Tower front-end for NATS JetStream authentication
104
105
  - `user_context` a string representing the user’s UUID
@@ -109,23 +110,39 @@ The `FlagManager` class is the entry point of the SDK. A new `FlagManager` objec
109
110
 
110
111
  #### Instance Methods
111
112
 
112
- ##### `FlagManager.prototype.set_user_context(new_user_context)`
113
+ ##### `flagmanager.initialize()`
114
+
115
+ Asynchronously initialize `flagmanager` connections to NATS JetStream and Redis database
116
+
117
+ **Parameters:**
118
+
119
+ - `nil`
120
+
121
+ **Return Value:**
122
+
123
+ - `nil`
124
+
125
+ ##### `flagmanaer.set_user_context(new_user_context)`
126
+
127
+ Set the current user's context for the `flagmanager`
113
128
 
114
129
  **Parameters:**
115
130
 
116
- - A UUID string that represents the current active user
131
+ - `new_user_context`: A UUID string that represents the current active user
117
132
 
118
133
  **Return Value:**
119
134
 
120
- - `null`
135
+ - `nil`
121
136
 
122
137
  ---
123
138
 
124
- ##### `FlagManager.prototype.get_user_context()`
139
+ ##### `flagmanaer.get_user_context()`
140
+
141
+ Returns the current user context
125
142
 
126
143
  **Parameters:**
127
144
 
128
- - `null`
145
+ - `nil`
129
146
 
130
147
  **Return Value:**
131
148
 
@@ -133,13 +150,13 @@ The `FlagManager` class is the entry point of the SDK. A new `FlagManager` objec
133
150
 
134
151
  ---
135
152
 
136
- ##### `FlagManager.prototype.new_toggler(options)`
153
+ ##### `flagmanaer.new_toggler(options)`
137
154
 
138
155
  Creates a new toggler to check for a feature flag's status from the current app's flag ruleset by the flag's name.
139
156
 
140
157
  **Parameters:**
141
158
 
142
- - An object with key of `flag_name` and a string value representing the name of the feature flag for the new toggler to check whether the new feature is enabled
159
+ - `options`: An object with key of `flag_name` and a string value representing the name of the feature flag for the new toggler to check whether the new feature is enabled
143
160
 
144
161
  **Return Value:**
145
162
 
@@ -147,29 +164,29 @@ Creates a new toggler to check for a feature flag's status from the current app'
147
164
 
148
165
  ---
149
166
 
150
- ##### `FlagManager.prototype.disconnect()`
167
+ ##### `flagmanaer.disconnect()`
151
168
 
152
169
  Asynchronously disconnects the `FlagManager` instance from NATS JetStream and Redis database
153
170
 
154
171
  **Parameters:**
155
172
 
156
- - `null`
173
+ - `nil`
157
174
 
158
175
  **Return Value:**
159
176
 
160
- - `null`
177
+ - `nil`
161
178
 
162
179
  ---
163
180
 
164
181
  ### Toggler
165
182
 
166
- The Toggler class provides methods that determine whether or not new feature code is run and handles success/failure emissions. Each toggler handles one feature flag, and is created by `FlagManager.prototype.new_toggler()`.
183
+ The Toggler class provides methods that determine whether or not new feature code is run and handles success/failure emissions. Each toggler handles one feature flag, and is created by `flagmanaer.new_toggler()`.
167
184
 
168
185
  ---
169
186
 
170
187
  #### Instance Methods
171
188
 
172
- ##### `is_flag_active()`
189
+ ##### `toggler.is_flag_active()`
173
190
 
174
191
  Checks for flag status, whitelisted users, and rollout percentage in that order to determine whether the new feature is enabled.
175
192
 
@@ -180,36 +197,36 @@ Checks for flag status, whitelisted users, and rollout percentage in that order
180
197
 
181
198
  **Parameters:**
182
199
 
183
- - `null`
200
+ - `nil`
184
201
 
185
202
  **Return Value**
186
203
 
187
- - `true` or `flase` depending on whether the feature flag is active
204
+ - `true` or `false` depending on whether the feature flag is active
188
205
 
189
206
  ---
190
207
 
191
- ##### `emit_success()`
208
+ ##### `toggler.emit_success()`
192
209
 
193
210
  Records a successful operation to the Redis Timeseries database, with key `flagId:success` and value of current timestamp
194
211
 
195
212
  **Parameters:**
196
213
 
197
- - `null`
214
+ - `nil`
198
215
 
199
216
  **Return Value**
200
217
 
201
- - `null`
218
+ - `nil`
202
219
 
203
220
  ---
204
221
 
205
- ##### `emit_failure()`
222
+ ##### `toggler.emit_failure()`
206
223
 
207
224
  Records a failure operation to the Redis Timeseries database, with key `flagId:success` and value of current timestamp
208
225
 
209
226
  **Parameters:**
210
227
 
211
- - `null`
228
+ - `nil`
212
229
 
213
230
  **Return Value**
214
231
 
215
- - `null`
232
+ - `nil`
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Tailslide
4
- VERSION = '0.1.4'
4
+ VERSION = '0.1.5'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tailslide
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steven Liou
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: exe
13
13
  cert_chain: []
14
- date: 2022-08-23 00:00:00.000000000 Z
14
+ date: 2022-08-24 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: async
@@ -79,8 +79,6 @@ executables: []
79
79
  extensions: []
80
80
  extra_rdoc_files: []
81
81
  files:
82
- - ".vscode/launch.json"
83
- - ".vscode/settings.json"
84
82
  - CHANGELOG.md
85
83
  - CODE_OF_CONDUCT.md
86
84
  - Gemfile
@@ -94,8 +92,6 @@ files:
94
92
  - lib/tailslide/toggler.rb
95
93
  - lib/tailslide/version.rb
96
94
  - sig/tailslide.rbs
97
- - tailslide-0.1.3.gem
98
- - test.rb
99
95
  homepage: https://github.com/tailslide-io/tailslide.rb
100
96
  licenses:
101
97
  - MIT
data/.vscode/launch.json DELETED
@@ -1,14 +0,0 @@
1
- {
2
- // Use IntelliSense to learn about possible attributes.
3
- // Hover to view descriptions of existing attributes.
4
- // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5
- "version": "0.2.0",
6
- "configurations": [
7
- {
8
- "name": "Debug Local File",
9
- "type": "Ruby",
10
- "request": "launch",
11
- "program": "./test.rb"
12
- }
13
- ]
14
- }
@@ -1,11 +0,0 @@
1
- {
2
- "workbench.colorCustomizations": {
3
- "sash.hoverBorder": "#3b3b3b",
4
- "titleBar.activeBackground": "#222222",
5
- "titleBar.activeForeground": "#e7e7e7",
6
- "titleBar.inactiveBackground": "#22222299",
7
- "titleBar.inactiveForeground": "#e7e7e799",
8
- "commandCenter.border": "#e7e7e799"
9
- },
10
- "editor.acceptSuggestionOnEnter": "on"
11
- }
data/tailslide-0.1.3.gem DELETED
Binary file
data/test.rb DELETED
@@ -1,132 +0,0 @@
1
- require "async"
2
- # require "./lib/tailslide/nats_client.rb"
3
- require_relative "lib/tailslide/flag_manager.rb"
4
-
5
- # def logMessage(message)
6
- # p message
7
- # end
8
-
9
- # config = {server_url: "localhost:4222", callback: :p, token: 'myToken', stream:"flags", subject:'1'}
10
- app_id = "1"
11
- flag_name = 'App 1 Flag 1'
12
- flag_config = {"flag_name": flag_name}
13
-
14
- config = {nats_server:'localhost:4222', stream:'flags_ruleset', app_id:app_id, sdk_key:'myToken', user_context:'375d39e6-9c3f-4f58-80bd-e5960b710295',
15
- redis_host:'localhost', redis_port:6379}
16
-
17
-
18
- Async do |task|
19
- manager = FlagManager.new(**config)
20
- manager.initialize_flags
21
- flag_toggler = manager.new_toggler(flag_config)
22
-
23
-
24
- if flag_toggler.is_flag_active
25
- puts "Flag in #{app_id} with name \"#{flag_name}\" is active!"
26
- flag_toggler.emit_success()
27
- else
28
- puts "Flag in #{app_id} with name \"#{flag_name}\" is not active!"
29
- flag_toggler.emit_failure()
30
- end
31
-
32
- count = 0
33
- limit = 20
34
- while count < limit do
35
- if rand < 1
36
- flag_toggler.emit_success
37
- puts "Emitting success"
38
- else
39
- flag_toggler.emit_failure
40
- puts "Emitting failure"
41
- end
42
- sleep 1
43
- end
44
- end
45
-
46
-
47
- # require "nats/client"
48
- # require "async"
49
- # TimeoutError = NATS::IO::Timeout
50
- # require 'json'
51
-
52
- # token = "myToken"
53
-
54
- # nats_client = NATS.connect("nats://#{token}@127.0.0.1:4222")
55
- # jet_stream = nats_client.jetstream
56
-
57
- # # get last message
58
- # latest_msg = jet_stream.get_last_msg("flags", "test")
59
- # json_data = JSON.parse latest_msg.data
60
- # p json_data
61
-
62
-
63
- # # pull subscribe for new onging messages (workaround until Nats.rb make new update)
64
- # subscribed_stream = jet_stream.pull_subscribe("test", 'mydurable', config: { deliver_policy: 'new' })
65
- # Async do |task|
66
- # task.async do
67
- # begin
68
- # messages = subscribed_stream.fetch(1)
69
- # messages.each do |message|
70
- # message.ack
71
- # json_data = JSON.parse message.data
72
- # p json_data
73
- # end
74
- # rescue NATS::Timeout => e
75
- # p e
76
- # end until nats_client.closed?
77
- # end
78
- # p "hello past async"
79
- # end
80
-
81
-
82
-
83
- # push subscribe for new ongoing messages
84
- # setting deliver_policy still results in delivering all messages in "test" subject
85
- # push_sub = jetStream.subscribe("test", {manual_ack: true, deliver_policy:"new"} ) do |msg|
86
- # msg.ack
87
- # puts msg.data
88
- # end
89
-
90
- # Get ongoing messages
91
- # Push subscribe
92
- # consumer_req = {
93
- # stream_name: "test",
94
- # config: {
95
- # durable_name: "sample",
96
- # deliver_policy: "new",
97
- # ack_policy: "explicit",
98
- # max_deliver: -1,
99
- # replay_policy: "instant"
100
- # }
101
- # }
102
-
103
- # config = NATS::JetStream::API::ConsumerConfig.new({ deliver_policy: "new" })
104
- # Create inbox for push consumer.
105
- # deliver = natsClient.new_inbox
106
- # config.deliver_subject = deliver
107
-
108
- # push_sub = jetStream.subscribe("test", {manual_ack: true, deliver_policy:"new"} ) do |msg|
109
- # puts msg.data
110
- # end
111
-
112
- # cinfo = push_sub.consumer_info["config"]
113
- # puts cinfo
114
- # msg = push_sub.next_msg(timeout: 10000000000)
115
- # msg.ack
116
- # puts msg.data
117
- # push_sub.consumer_info["config"]["deliver_policy"] = "new"
118
- # puts cinfo
119
-
120
- # loop do
121
- # msgs = push_sub.next_msg()
122
- # puts msgs.data
123
- # rescue TimeoutError => e
124
- # puts e
125
- # sleep 1
126
- # end
127
-
128
- # js.publish("9", "Hello JetStream! 1")
129
- # js.publish("9", "Hello JetStream! 2")
130
- # js.publish("9", "Hello JetStream! 3")
131
- # js.publish("9", "Hello JetStream! 4")
132
- # js.publish("9", "Hello JetStream! Latest")