Class: LanGrove::Plugin::BufferedPersistor
- Inherits:
-
Persistor
- Object
- Base
- DataSource
- Persistor
- LanGrove::Plugin::BufferedPersistor
- Defined in:
- lib/langrove/plugin/buffered_persistor.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Persistor
#all_capsules, #fetch, #fetch_all, #fetch_all_handler, #fetch_handler, #gen_key, #initialize, #next_seq, #store_handler, #transform, type
Methods inherited from DataSource
Methods inherited from Base
#config_exception, #initialize, #type
Constructor Details
This class inherits a constructor from LanGrove::Plugin::Persistor
Instance Method Details
#store(handler) ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/langrove/plugin/buffered_persistor.rb', line 71 def store( handler ) gen_key( handler ) if handler.key.nil? @key_column = handler.key['key'].first[0] key = handler.key['key'].first[1] @stored[key] = false @capsules[key] = YAML.load( # # LAZY... deep copy through YAML serialize # YAML.dump( handler.capsule ) ) end |
#store_all ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/langrove/plugin/buffered_persistor.rb', line 7 def store_all # # OVERRIDE # # To store all capsules accumulated in # @capsules # @capsules.is_a? Hash end |
#validate_config ⇒ Object
20 21 22 23 24 25 26 27 28 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 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/langrove/plugin/buffered_persistor.rb', line 20 def validate_config unless defined?( EM ) and EM.reactor_running? raise LanGrove::PluginException.new( "#{self.class} only runs inside EventMachine enabled daemons" ) end super @capsules = {} @stored = {} @interval = @config[:interval] if @interval.nil? # # default to call store every 10 minutes # @logger.info "#{self.class} defaulting :interval: to 10 minutes" @interfal = 600 end EM.add_periodic_timer( @interval ) do if @running @logger.warn "#{self.class} already running store_all" break end @running = true store_all @running = false end end |