Class: UpdateProcessor
- Defined in:
- lib/ff/ruby/server/sdk/api/update_processor.rb
Instance Method Summary collapse
- #close ⇒ Object
- #init(connector, repository, callback, logger) ⇒ Object
- #start ⇒ Object
- #stop ⇒ Object
- #update(message) ⇒ Object
Instance Method Details
#close ⇒ Object
76 77 78 79 80 81 |
# File 'lib/ff/ruby/server/sdk/api/update_processor.rb', line 76 def close @logger.info "Closing UpdateProcessor" stop end |
#init(connector, repository, callback, logger) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/ff/ruby/server/sdk/api/update_processor.rb', line 7 def init( connector, repository, callback, logger ) @connector = connector @repository = repository @updater = callback @executor = Concurrent::FixedThreadPool.new(100) if logger != nil @logger = logger else @logger = Logger.new(STDOUT) end end |
#start ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/ff/ruby/server/sdk/api/update_processor.rb', line 29 def start @logger.debug "Starting updater (EventSource)" if @updater != nil unless @updater.kind_of?(Updater) raise "The 'callback' parameter must be of '" + Updater.to_s + "' data type" end end if @connector != nil unless @connector.kind_of?(Connector) raise "The 'connector' must be of '" + Connector.to_s + "' data type" end @executor.post do @stream = @connector.stream(@updater) @stream.start end end end |
#stop ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/ff/ruby/server/sdk/api/update_processor.rb', line 56 def stop @logger.info "Stopping updater (EventSource)" if @stream != nil @stream.stop end @executor.shutdown @executor.wait_for_termination(3) if @executor.shuttingdown? @executor.kill end @logger.info "Updater stopped (EventSource)" end |
#update(message) ⇒ Object
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/ff/ruby/server/sdk/api/update_processor.rb', line 83 def update() if ["domain"] == "flag" @executor.post do process_flag() end return end if ["domain"] == "target-segment" @executor.post do process_segment() end end end |