Module: Rhoconnect::Handler::PluginCallbacks::ExecuteMethods
- Included in:
- Server
- Defined in:
- lib/rhoconnect/handler/plugin_callbacks/execute_methods.rb
Instance Method Summary collapse
- #do_fast_delete ⇒ Object
-
#do_fast_insert ⇒ Object
the following methods are not exposed as handlers - instead they’re used directly TODO: potentially deprecate them - push_* are fast enough already.
- #do_fast_update ⇒ Object
- #execute_push_objects_handler(route_handler) ⇒ Object (also: #execute_push_deletes_handler)
Instance Method Details
#do_fast_delete ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/rhoconnect/handler/plugin_callbacks/execute_methods.rb', line 70 def do_fast_delete source = _load_source timeout = params[:timeout] || 10 raise_on_expire = params[:raise_on_expire] || false delete_objs = params[:data] source.lock(:md,timeout,raise_on_expire) do |s| diff_count = -delete_objs.size source.delete_data(:md, delete_objs) source.update_count(:md_size,diff_count) end source.announce_changes 'done' end |
#do_fast_insert ⇒ Object
the following methods are not exposed as handlers - instead they’re used directly TODO: potentially deprecate them - push_* are fast enough already
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/rhoconnect/handler/plugin_callbacks/execute_methods.rb', line 17 def do_fast_insert source = _load_source timeout = params[:timeout] || 10 raise_on_expire = params[:raise_on_expire] || false new_objs = params[:data] source.lock(:md,timeout,raise_on_expire) do |s| diff_count = new_objs.size source.put_data(:md, new_objs, true) source.update_count(:md_size,diff_count) end source.announce_changes 'done' end |
#do_fast_update ⇒ Object
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 |
# File 'lib/rhoconnect/handler/plugin_callbacks/execute_methods.rb', line 31 def do_fast_update source = _load_source timeout = params[:timeout] || 10 raise_on_expire = params[:raise_on_expire] || false remove_hash = params[:delete_data] new_hash = params[:data] if ((remove_hash and remove_hash.size > 0) or (new_hash and new_hash.size > 0)) source.lock(:md,timeout,raise_on_expire) do |s| # get the objects from DB, remove prev attr data, add new attr data update_keys = Set.new update_keys += Set.new(remove_hash.keys) if remove_hash update_keys += Set.new(new_hash.keys) if new_hash objs_to_update = source.get_objects(:md, update_keys.to_a) || {} diff_count = -objs_to_update.size # remove old values from DB source.delete_data(:md, objs_to_update) # update data remove_hash.each do |key, obj| next unless objs_to_update[key] obj.each do |attrib, value| objs_to_update[key].delete(attrib) objs_to_update.delete(key) if objs_to_update[key].empty? end end if remove_hash new_hash.each do |key, obj| objs_to_update[key] ||= {} objs_to_update[key].merge!(obj) end if new_hash # store new data into DB source.put_data(:md, objs_to_update, true) diff_count += objs_to_update.size source.update_count(:md_size,diff_count) end source.announce_changes end 'done' end |
#execute_push_objects_handler(route_handler) ⇒ Object Also known as: execute_push_deletes_handler
5 6 7 8 9 10 11 |
# File 'lib/rhoconnect/handler/plugin_callbacks/execute_methods.rb', line 5 def execute_push_objects_handler(route_handler) source = _load_source @model = Rhoconnect::Model::Base.create(source) @handler = Rhoconnect::Handler::PluginCallbacks::Runner.new(route_handler, @model, params) @handler.run 'done' end |