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

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(store, addr) ⇒ Server

Returns a new instance of Server.



101
102
103
104
# File 'lib/strokedb/stores/remote_store.rb', line 101

def initialize(store, addr)
  @store, @addr = store, addr
  @mutex = Mutex.new
end

Instance Attribute Details

#addrObject (readonly)

Returns the value of attribute addr.



100
101
102
# File 'lib/strokedb/stores/remote_store.rb', line 100

def addr
  @addr
end

#storeObject (readonly)

Returns the value of attribute store.



100
101
102
# File 'lib/strokedb/stores/remote_store.rb', line 100

def store
  @store
end

#threadObject (readonly)

Returns the value of attribute thread.



100
101
102
# File 'lib/strokedb/stores/remote_store.rb', line 100

def thread
  @thread
end

Instance Method Details

#autosync!Object



159
160
161
# File 'lib/strokedb/stores/remote_store.rb', line 159

def autosync!
  @mutex.synchronize { @store.autosync! }
end

#documentObject



151
152
153
# File 'lib/strokedb/stores/remote_store.rb', line 151

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

#each(options = {}, &block) ⇒ Object



135
136
137
# File 'lib/strokedb/stores/remote_store.rb', line 135

def each(options = {}, &block)
  @mutex.synchronize { @store.each(options, &block) }
end

#empty?Boolean

Returns:

  • (Boolean)


155
156
157
# File 'lib/strokedb/stores/remote_store.rb', line 155

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

#find(*args) ⇒ Object



111
112
113
# File 'lib/strokedb/stores/remote_store.rb', line 111

def find(*args)
  @mutex.synchronize { @store.find(*args) }
end

#head_version(uuid) ⇒ Object



124
125
126
127
128
# File 'lib/strokedb/stores/remote_store.rb', line 124

def head_version(uuid)
  raw_doc = @mutex.synchronize { find(uuid, nil, :no_instantiation => true) }
  return raw_doc['version'] if raw_doc
  nil
end

#include?(*args) ⇒ Boolean Also known as: contains?

Returns:

  • (Boolean)


119
120
121
# File 'lib/strokedb/stores/remote_store.rb', line 119

def include?(*args)
  !!@mutex.synchronize { @store.include?(*args) }
end

#index_storeObject



171
172
173
# File 'lib/strokedb/stores/remote_store.rb', line 171

def index_store
  @store.index_store
end

#inspectObject



167
168
169
# File 'lib/strokedb/stores/remote_store.rb', line 167

def inspect
  @store.inspect
end

#next_timestampObject



143
144
145
# File 'lib/strokedb/stores/remote_store.rb', line 143

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

#save!(document) ⇒ Object



130
131
132
133
# File 'lib/strokedb/stores/remote_store.rb', line 130

def save!(document)
  document.instance_variable_set(:@store, @store)
  @mutex.synchronize { @store.save!(document) }
end

#search(*args) ⇒ Object



115
116
117
# File 'lib/strokedb/stores/remote_store.rb', line 115

def search(*args)
  @mutex.synchronize { @store.search(*args) }
end

#startObject



106
107
108
109
# File 'lib/strokedb/stores/remote_store.rb', line 106

def start
  ::DRb.start_service(addr, self)
  @thread = ::DRb.thread
end

#stop_autosync!Object



163
164
165
# File 'lib/strokedb/stores/remote_store.rb', line 163

def stop_autosync!
  @mutex.synchronize { @store.stop_autosync! }
end

#timestampObject



139
140
141
# File 'lib/strokedb/stores/remote_store.rb', line 139

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

#uuidObject



147
148
149
# File 'lib/strokedb/stores/remote_store.rb', line 147

def uuid
  @store.uuid
end