Module: Grumlin

Defined in:
lib/grumlin.rb,
lib/grumlin/version.rb

Defined Under Namespace

Modules: Features, Repository, Shortcuts, Typing, WithExtension Classes: AlreadyConnectedError, AlreadyExistsError, CannotConnectError, Client, ClientClosedError, ClientSideError, ConcurrentEdgeInsertFailedError, ConcurrentEdgePropertyInsertFailedError, ConcurrentInsertFailedError, ConcurrentModificationError, ConcurrentVertexInsertFailedError, ConcurrentVertexPropertyInsertFailedError, Config, ConnectionError, ConnectionStatusError, DisconnectError, DummyTransaction, Edge, EdgeAlreadyExistsError, Error, FailStepError, InternalClientError, InvalidRequestArgumentsError, NotConnectedError, Path, Property, ProtocolError, RepositoryError, RequestDispatcher, RequestErrorFactory, ResourceLeakError, Rollback, ScriptEvaluationError, ServerError, ServerSerializationError, ServerSideError, ServerTimeoutError, Shortcut, ShortcutsApplyer, StatusError, Step, StepData, Steppable, Steps, Transaction, TransactionError, Transport, TraversalStart, Traverser, TypedValue, UnknownError, UnknownMapKey, UnknownRequestStoppedError, UnknownResponseStatus, UnknownTypeError, Vertex, VertexAlreadyExistsError, VertexProperty, WrongQueryResult

Constant Summary collapse

VERSION =
"1.3.0"

Class Method Summary collapse

Class Method Details

.closeObject



173
174
175
176
177
178
179
180
181
# File 'lib/grumlin.rb', line 173

def close
  t = Thread.current
  return if t.thread_variable_get(:grumlin_default_pool).nil?

  pool = t.thread_variable_get(:grumlin_default_pool)
  pool.wait while pool.busy?
  pool.close
  t.thread_variable_set(:grumlin_default_pool, nil)
end

.configObject



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

def config
  @config ||= Config.new
end

.configure {|config| ... } ⇒ Object

Yields:



143
144
145
146
147
# File 'lib/grumlin.rb', line 143

def configure
  yield config

  config.validate!
end

.default_middlewaresObject



153
154
155
# File 'lib/grumlin.rb', line 153

def default_middlewares
  config.middlewares
end

.default_poolObject



164
165
166
167
168
169
170
171
# File 'lib/grumlin.rb', line 164

def default_pool
  t = Thread.current
  return t.thread_variable_get(:grumlin_default_pool) if t.thread_variable_get(:grumlin_default_pool)

  t.thread_variable_set(:grumlin_default_pool,
                        Async::Pool::Controller.new(Grumlin::Client::PoolResource,
                                                    limit: config.pool_size))
end

.definitionsObject



183
184
185
# File 'lib/grumlin.rb', line 183

def definitions
  @definitions ||= YAML.safe_load_file(File.join(__dir__, "definitions.yml"), symbolize_names: true)
end

.fake_uuid(*parts, separator: "->") ⇒ Object



187
188
189
190
191
192
193
194
195
196
197
198
# File 'lib/grumlin.rb', line 187

def fake_uuid(*parts, separator: "->")
  uuid = Digest::MD5.hexdigest(parts.join(separator))

  segments = [8, 4, 4, 4, 12]
  parts = segments.map do |n|
    uuid[0...n].tap do
      uuid = uuid[n..]
    end
  end

  parts.join("-")
end

.featuresObject

returns a subset of features for currently configured backend. The features lists are hardcoded as there is no way to get them from the remote server.



160
161
162
# File 'lib/grumlin.rb', line 160

def features
  Features.for(config.provider) # no memoization as provider may be changed
end