Class: Promiscuous::Publisher::Operation::NonPersistent

Inherits:
Base
  • Object
show all
Defined in:
lib/promiscuous/publisher/operation/non_persistent.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#operation

Instance Method Summary collapse

Methods inherited from Base

_acquire_lock, #acquire_op_lock, #dependencies_for, #dependency_for_op_lock, #ensure_op_still_locked, #execute, #explain_operation, #generate_payload, #get_new_op_lock, #increment_dependencies, lock_options, #on_rabbitmq_confirm, #payload_for, #publish_payload_in_rabbitmq_async, #publish_payload_in_redis, rabbitmq_staging_set_key, #record_timestamp, #recover_db_operation, recover_locks, recover_operation, recover_operation_from_lock, recover_payloads_for_rabbitmq, #recovering?, #recovery_payload, register_recovery_mechanism, #release_op_lock, run_recovery_mechanisms, #should_instrument_query?, #trace_operation, #write_dependencies

Constructor Details

#initialize(options = {}) ⇒ NonPersistent

Returns a new instance of NonPersistent.



6
7
8
9
# File 'lib/promiscuous/publisher/operation/non_persistent.rb', line 6

def initialize(options={})
  super
  @instances = options[:instances].to_a
end

Instance Attribute Details

#instancesObject

XXX As opposed to atomic operations, NonPersistent operations deals with an array of instances



4
5
6
# File 'lib/promiscuous/publisher/operation/non_persistent.rb', line 4

def instances
  @instances
end

Instance Method Details

#execute_instrumented(db_operation) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/promiscuous/publisher/operation/non_persistent.rb', line 11

def execute_instrumented(db_operation)
  db_operation.call_and_remember_result(:instrumented)

  unless db_operation.failed?
    trace_operation
  end
end

#operation_payloadsObject



19
20
21
22
# File 'lib/promiscuous/publisher/operation/non_persistent.rb', line 19

def operation_payloads
  return [] if self.failed?
  @instances.map { |instance| payloads_for(instance) }
end

#query_dependenciesObject



24
25
26
# File 'lib/promiscuous/publisher/operation/non_persistent.rb', line 24

def query_dependencies
  @instances.map { |instance| dependencies_for(instance) }
end