Class: Pacer::Orient::FactoryContainer
- Inherits:
-
Object
- Object
- Pacer::Orient::FactoryContainer
- Defined in:
- lib/pacer-orient/factory_container.rb
Instance Attribute Summary collapse
-
#edge_classes ⇒ Object
Returns the value of attribute edge_classes.
-
#encoder ⇒ Object
Returns the value of attribute encoder.
-
#factory ⇒ Object
readonly
Returns the value of attribute factory.
-
#lightweight_edges ⇒ Object
Returns the value of attribute lightweight_edges.
-
#transactional ⇒ Object
Returns the value of attribute transactional.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
-
#use_pool ⇒ Object
readonly
Returns the value of attribute use_pool.
-
#vertex_classes ⇒ Object
Returns the value of attribute vertex_classes.
Instance Method Summary collapse
- #get ⇒ Object
- #getNoTx ⇒ Object
- #getTx ⇒ Object
- #graph ⇒ Object
-
#initialize(f, url, args) ⇒ FactoryContainer
constructor
A new instance of FactoryContainer.
- #setupPool(min, max) ⇒ Object
-
#shutdown ⇒ Object
Pacer calls shutdown on all cached graphs when it exits.
- #stay_open ⇒ Object
- #stay_open=(b) ⇒ Object
- #surrender(g) ⇒ Object
Constructor Details
#initialize(f, url, args) ⇒ FactoryContainer
Returns a new instance of FactoryContainer.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/pacer-orient/factory_container.rb', line 6 def initialize(f, url, args) @factory = f @url = url Pacer.open_graphs[url] = self if args @transactional = args[:transactional] @lightweight_edges = args[:lightweight_edges] @edge_classes = args[:edge_classes] @vertex_classes = args[:vertex_classes] self.stay_open = args[:stay_open] @encoder = args.fetch :encoder, Encoder min = args[:pool_min] max = args[:pool_max] if min and max setupPool min, max end else @encoder = Encoder end end |
Instance Attribute Details
#edge_classes ⇒ Object
Returns the value of attribute edge_classes.
4 5 6 |
# File 'lib/pacer-orient/factory_container.rb', line 4 def edge_classes @edge_classes end |
#encoder ⇒ Object
Returns the value of attribute encoder.
4 5 6 |
# File 'lib/pacer-orient/factory_container.rb', line 4 def encoder @encoder end |
#factory ⇒ Object (readonly)
Returns the value of attribute factory.
3 4 5 |
# File 'lib/pacer-orient/factory_container.rb', line 3 def factory @factory end |
#lightweight_edges ⇒ Object
Returns the value of attribute lightweight_edges.
4 5 6 |
# File 'lib/pacer-orient/factory_container.rb', line 4 def lightweight_edges @lightweight_edges end |
#transactional ⇒ Object
Returns the value of attribute transactional.
4 5 6 |
# File 'lib/pacer-orient/factory_container.rb', line 4 def transactional @transactional end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
3 4 5 |
# File 'lib/pacer-orient/factory_container.rb', line 3 def url @url end |
#use_pool ⇒ Object (readonly)
Returns the value of attribute use_pool.
3 4 5 |
# File 'lib/pacer-orient/factory_container.rb', line 3 def use_pool @use_pool end |
#vertex_classes ⇒ Object
Returns the value of attribute vertex_classes.
4 5 6 |
# File 'lib/pacer-orient/factory_container.rb', line 4 def vertex_classes @vertex_classes end |
Instance Method Details
#get ⇒ Object
56 57 58 59 60 61 62 |
# File 'lib/pacer-orient/factory_container.rb', line 56 def get if transactional == false getNoTx else getTx end end |
#getNoTx ⇒ Object
68 69 70 |
# File 'lib/pacer-orient/factory_container.rb', line 68 def getNoTx configure factory.getNoTx end |
#getTx ⇒ Object
64 65 66 |
# File 'lib/pacer-orient/factory_container.rb', line 64 def getTx configure factory.getTx end |
#graph ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/pacer-orient/factory_container.rb', line 40 def graph # Shutdown releases the graph to the pool in this case. g = Graph.new encoder, proc { get }, proc { |g| g.blueprints_graph.shutdown } if block_given? r = yield g g.shutdown if use_pool r else g end end |
#setupPool(min, max) ⇒ Object
27 28 29 30 |
# File 'lib/pacer-orient/factory_container.rb', line 27 def setupPool(min, max) @use_pool = true factory.setupPool min, max end |
#shutdown ⇒ Object
Pacer calls shutdown on all cached graphs when it exits. Orient caches this factory.
73 74 75 76 |
# File 'lib/pacer-orient/factory_container.rb', line 73 def shutdown factory.close Pacer.open_graphs.delete url end |
#stay_open ⇒ Object
36 37 38 |
# File 'lib/pacer-orient/factory_container.rb', line 36 def stay_open #factory.getLeaveGraphsOpen end |
#stay_open=(b) ⇒ Object
32 33 34 |
# File 'lib/pacer-orient/factory_container.rb', line 32 def stay_open=(b) #factory.setLeaveGraphsOpen b end |
#surrender(g) ⇒ Object
52 53 54 |
# File 'lib/pacer-orient/factory_container.rb', line 52 def surrender(g) g.shutdown if use_pool end |