Class: StrokeDB::RemoteStore::DRb::Server
- Defined in:
- lib/stores/remote_store.rb
Instance Attribute Summary collapse
-
#addr ⇒ Object
readonly
Returns the value of attribute addr.
-
#store ⇒ Object
readonly
Returns the value of attribute store.
-
#thread ⇒ Object
readonly
Returns the value of attribute thread.
Instance Method Summary collapse
- #autosync! ⇒ Object
- #document ⇒ Object
- #each(options = {}, &block) ⇒ Object
- #empty? ⇒ Boolean
- #exists?(*args) ⇒ Boolean
- #find(*args) ⇒ Object
- #head_version(uuid) ⇒ Object
- #index_store ⇒ Object
-
#initialize(store, addr) ⇒ Server
constructor
A new instance of Server.
- #inspect ⇒ Object
- #next_timestamp ⇒ Object
- #save!(document) ⇒ Object
- #search(*args) ⇒ Object
- #start ⇒ Object
- #stop_autosync! ⇒ Object
- #timestamp ⇒ Object
- #uuid ⇒ Object
Constructor Details
#initialize(store, addr) ⇒ Server
Returns a new instance of Server.
96 97 98 99 |
# File 'lib/stores/remote_store.rb', line 96 def initialize(store, addr) @store, @addr = store, addr @mutex = Mutex.new end |
Instance Attribute Details
#addr ⇒ Object (readonly)
Returns the value of attribute addr.
95 96 97 |
# File 'lib/stores/remote_store.rb', line 95 def addr @addr end |
#store ⇒ Object (readonly)
Returns the value of attribute store.
95 96 97 |
# File 'lib/stores/remote_store.rb', line 95 def store @store end |
#thread ⇒ Object (readonly)
Returns the value of attribute thread.
95 96 97 |
# File 'lib/stores/remote_store.rb', line 95 def thread @thread end |
Instance Method Details
#autosync! ⇒ Object
153 154 155 |
# File 'lib/stores/remote_store.rb', line 153 def autosync! @mutex.synchronize { @store.autosync! } end |
#document ⇒ Object
145 146 147 |
# File 'lib/stores/remote_store.rb', line 145 def document @mutex.synchronize { @store.document } end |
#each(options = {}, &block) ⇒ Object
129 130 131 |
# File 'lib/stores/remote_store.rb', line 129 def each( = {}, &block) @mutex.synchronize { @store.each(, &block) } end |
#empty? ⇒ Boolean
149 150 151 |
# File 'lib/stores/remote_store.rb', line 149 def empty? @mutex.synchronize { @store.empty? } end |
#exists?(*args) ⇒ Boolean
114 115 116 |
# File 'lib/stores/remote_store.rb', line 114 def exists?(*args) !!@mutex.synchronize { @store.exists?(*args) } end |
#find(*args) ⇒ Object
106 107 108 |
# File 'lib/stores/remote_store.rb', line 106 def find(*args) @mutex.synchronize { @store.find(*args) } end |
#head_version(uuid) ⇒ Object
118 119 120 121 122 |
# File 'lib/stores/remote_store.rb', line 118 def head_version(uuid) raw_doc = @mutex.synchronize { find(uuid, nil, :no_instantiation => true) } return raw_doc['version'] if raw_doc nil end |
#index_store ⇒ Object
165 166 167 |
# File 'lib/stores/remote_store.rb', line 165 def index_store @store.index_store end |
#inspect ⇒ Object
161 162 163 |
# File 'lib/stores/remote_store.rb', line 161 def inspect @store.inspect end |
#next_timestamp ⇒ Object
137 138 139 |
# File 'lib/stores/remote_store.rb', line 137 def @mutex.synchronize { @store. } end |
#save!(document) ⇒ Object
124 125 126 127 |
# File 'lib/stores/remote_store.rb', line 124 def save!(document) document.instance_variable_set(:@store, @store) @mutex.synchronize { @store.save!(document) } end |
#search(*args) ⇒ Object
110 111 112 |
# File 'lib/stores/remote_store.rb', line 110 def search(*args) @mutex.synchronize { @store.search(*args) } end |
#start ⇒ Object
101 102 103 104 |
# File 'lib/stores/remote_store.rb', line 101 def start ::DRb.start_service(addr, self) @thread = ::DRb.thread end |
#stop_autosync! ⇒ Object
157 158 159 |
# File 'lib/stores/remote_store.rb', line 157 def stop_autosync! @mutex.synchronize { @store.stop_autosync! } end |
#timestamp ⇒ Object
133 134 135 |
# File 'lib/stores/remote_store.rb', line 133 def @mutex.synchronize { @store. } end |
#uuid ⇒ Object
141 142 143 |
# File 'lib/stores/remote_store.rb', line 141 def uuid @store.uuid end |