Sha256: ab25d34517218d3cd842f6102fa772012691f6e1848387628cf1c6191733a9e5

Contents?: true

Size: 1.25 KB

Versions: 4

Compression:

Stored size: 1.25 KB

Contents

module Pacer
  module Neo4j2
    class BlueprintsGraph < com.tinkerpop.blueprints.impls.neo4j2.Neo4j2Graph
      attr_accessor :allow_auto_tx, :allow_auto_read_tx

      # Threadlocal tx_depth is set in Pacer's graph_transaction_mixin.rb
      def tx_depth
        graphs = Thread.current[:graphs] ||= {}
        tgi = graphs[object_id] ||= {}
        tgi[:tx_depth] || 0
      end

      # Threadlocal read_tx_depth is set in Pacer's graph_transaction_mixin.rb
      def read_tx_depth
        graphs = Thread.current[:graphs] ||= {}
        tgi = graphs[object_id] ||= {}
        depth = tgi[:read_tx_depth] || 0
        if depth == 0
          tgi[:tx_depth] || 0 # Reads are allowed in any type of tx.
        else
          depth
        end
      end

      def autoStartTransaction(for_write)
        if for_write
          if allow_auto_tx or tx_depth != 0
            super
          else
            raise Pacer::TransactionError, "Can't mutate the graph outside a transaction block"
          end
        else
          if allow_auto_read_tx or read_tx_depth != 0
            super
          else
            raise Pacer::TransactionError, "Can't read the graph outside a transaction or read_transaction block"
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
pacer-neo4j2-2.1.7-java lib/pacer-neo4j2/blueprints_graph.rb
pacer-neo4j2-2.1.6-java lib/pacer-neo4j2/blueprints_graph.rb
pacer-neo4j2-2.1.5.pre-java lib/pacer-neo4j2/blueprints_graph.rb
pacer-neo4j2-2.0.1-java lib/pacer-neo4j2/blueprints_graph.rb