Class: FlagManager
- Inherits:
-
Object
- Object
- FlagManager
- Defined in:
- lib/tailslide/flag_manager.rb
Direct Known Subclasses
Instance Method Summary collapse
- #disconnect ⇒ Object
- #get_flags ⇒ Object
- #get_user_context ⇒ Object
-
#initialize(nats_server: '', stream: '', app_id: '', sdk_key: '', user_context: '', redis_host: '', redis_port: '') ⇒ FlagManager
constructor
A new instance of FlagManager.
- #initialize_flags ⇒ Object
- #new_toggler(config) ⇒ Object
- #set_flags(flags) ⇒ Object
- #set_user_context(new_user_context) ⇒ Object
Constructor Details
#initialize(nats_server: '', stream: '', app_id: '', sdk_key: '', user_context: '', redis_host: '', redis_port: '') ⇒ FlagManager
Returns a new instance of FlagManager.
7 8 9 10 11 12 13 |
# File 'lib/tailslide/flag_manager.rb', line 7 def initialize(nats_server: '', stream: '', app_id: '', sdk_key: '', user_context: '', redis_host: '', redis_port: '') @nats_client = NatsClient.new(server_url: nats_server, stream: stream, subject: app_id, callback: method(:set_flags), token: sdk_key) @redis_ts_client = RedisTimeSeriesClient.new(redis_host, redis_port) @user_context = user_context @flags = [] end |
Instance Method Details
#disconnect ⇒ Object
36 37 38 39 |
# File 'lib/tailslide/flag_manager.rb', line 36 def disconnect @nats_client.disconnect @redis_ts_client.disconnect end |
#get_flags ⇒ Object
24 25 26 |
# File 'lib/tailslide/flag_manager.rb', line 24 def get_flags @flags end |
#get_user_context ⇒ Object
32 33 34 |
# File 'lib/tailslide/flag_manager.rb', line 32 def get_user_context @user_context end |
#initialize_flags ⇒ Object
15 16 17 18 |
# File 'lib/tailslide/flag_manager.rb', line 15 def initialize_flags @nats_client.initialize_flags @redis_ts_client.init end |
#new_toggler(config) ⇒ Object
41 42 43 44 |
# File 'lib/tailslide/flag_manager.rb', line 41 def new_toggler(config) Toggler.new(**config, get_flags: method(:get_flags), user_context: get_user_context, emit_redis_signal: @redis_ts_client.method(:emit_signal)) end |
#set_flags(flags) ⇒ Object
20 21 22 |
# File 'lib/tailslide/flag_manager.rb', line 20 def set_flags(flags) @flags = flags end |
#set_user_context(new_user_context) ⇒ Object
28 29 30 |
# File 'lib/tailslide/flag_manager.rb', line 28 def set_user_context(new_user_context) @user_context = new_user_context end |