Class: FDB::Cluster
- Inherits:
-
FormerFuture
- Object
- FormerFuture
- FDB::Cluster
- Defined in:
- lib/fdbimpl.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(cpointer) ⇒ Cluster
constructor
A new instance of Cluster.
- #open_database(name = "DB") ⇒ Object
Methods inherited from FormerFuture
#block_until_ready, #on_ready, #ready?
Constructor Details
#initialize(cpointer) ⇒ Cluster
Returns a new instance of Cluster.
524 525 526 527 528 529 530 |
# File 'lib/fdbimpl.rb', line 524 def initialize(cpointer) @cpointer = cpointer @options = ClusterOptions.new lambda { |code, param| FDBC.check_error FDBC.fdb_cluster_set_option(cpointer, code, param, param.nil? ? 0 : param.bytesize) } ObjectSpace.define_finalizer(self, self.class.finalize(@cpointer)) end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
515 516 517 |
# File 'lib/fdbimpl.rb', line 515 def @options end |
Class Method Details
.finalize(ptr) ⇒ Object
517 518 519 520 521 522 |
# File 'lib/fdbimpl.rb', line 517 def self.finalize(ptr) proc do # puts "Destroying cluster #{ptr}" FDBC.fdb_cluster_destroy(ptr) end end |
Instance Method Details
#open_database(name = "DB") ⇒ Object
532 533 534 535 536 537 538 |
# File 'lib/fdbimpl.rb', line 532 def open_database(name="DB") f = FDBC.fdb_cluster_create_database(@cpointer, name, name.bytesize) dpointer = FFI::MemoryPointer.new :pointer FDBC.check_error FDBC.fdb_future_block_until_ready(f) FDBC.check_error FDBC.fdb_future_get_database(f, dpointer) Database.new dpointer.get_pointer(0) end |