Class: StrokeDB::RemoteStore::DRb::Server

Inherits:
Object
  • Object
show all
Defined in:
lib/stores/remote_store.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#addrObject (readonly)

Returns the value of attribute addr.



95
96
97
# File 'lib/stores/remote_store.rb', line 95

def addr
  @addr
end

#storeObject (readonly)

Returns the value of attribute store.



95
96
97
# File 'lib/stores/remote_store.rb', line 95

def store
  @store
end

#threadObject (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

#documentObject



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(options = {}, &block)
  @mutex.synchronize { @store.each(options, &block) }
end

#empty?Boolean

Returns:

  • (Boolean)


149
150
151
# File 'lib/stores/remote_store.rb', line 149

def empty?
  @mutex.synchronize { @store.empty? }
end

#exists?(*args) ⇒ Boolean

Returns:

  • (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_storeObject



165
166
167
# File 'lib/stores/remote_store.rb', line 165

def index_store
  @store.index_store
end

#inspectObject



161
162
163
# File 'lib/stores/remote_store.rb', line 161

def inspect
  @store.inspect
end

#next_timestampObject



137
138
139
# File 'lib/stores/remote_store.rb', line 137

def next_timestamp
  @mutex.synchronize { @store.next_timestamp }
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

#startObject



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

#timestampObject



133
134
135
# File 'lib/stores/remote_store.rb', line 133

def timestamp
  @mutex.synchronize { @store.timestamp }
end

#uuidObject



141
142
143
# File 'lib/stores/remote_store.rb', line 141

def uuid
  @store.uuid
end