Module: Tarantool::Rails

Defined in:
tarantool-rails/lib/tarantool/rails.rb,
tarantool-rails/lib/tarantool/rails/errors.rb,
tarantool-rails/lib/tarantool/rails/railtie.rb,
tarantool-rails/lib/tarantool/rails/version.rb,
tarantool-rails/lib/tarantool/rails/schema_tasks.rb,
tarantool-rails/lib/tarantool/rails/configuration.rb,
tarantool-rails/lib/tarantool/rails/log_subscriber.rb,
tarantool-rails/lib/tarantool/rails/controller_runtime.rb

Overview

Rails integration: configuration from config/tarantool.yml, one Pool per process, models on it, log lines, schema rake tasks and generators.

Defined Under Namespace

Modules: ControllerRuntime Classes: Configuration, Error, LogSubscriber, Railtie

Constant Summary collapse

VERSION =
'0.3.0'

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.config ⇒ Object

Returns the value of attribute config.



24
25
26
# File 'tarantool-rails/lib/tarantool/rails.rb', line 24

def config
  @config
end

.instrumenter ⇒ Object

What the pool reports requests to; the log subscriber listens to ActiveSupport::Notifications, so an instrumenter of your own should chain it (tarantool-opentelemetry's does with instrumenter:).



29
30
31
# File 'tarantool-rails/lib/tarantool/rails.rb', line 29

def instrumenter
  @instrumenter || ActiveSupport::Notifications
end

.schema ⇒ Object



41
42
43
# File 'tarantool-rails/lib/tarantool/rails.rb', line 41

def schema
  LOCK.synchronize { @schema ||= load_schema }
end

.schema_path ⇒ Object

Returns the value of attribute schema_path.



24
25
26
# File 'tarantool-rails/lib/tarantool/rails.rb', line 24

def schema_path
  @schema_path
end

Class Method Details

.admin_client ⇒ Object



45
46
47
48
49
50
51
52
53
54
# File 'tarantool-rails/lib/tarantool/rails.rb', line 45

def admin_client
  uri = configured.admin_uri
  raise Error, 'admin_uri is not set in config/tarantool.yml' unless uri

  client = Tarantool::Client.new(uri)

  yield client
ensure
  client&.close
end

.disconnect! ⇒ Object



62
63
64
65
66
67
68
69
# File 'tarantool-rails/lib/tarantool/rails.rb', line 62

def disconnect!
  LOCK.synchronize do
    @pool&.close
    @pool = nil
    @storage = nil
    use_default_storage! if @owns_default_storage
  end
end

.pool ⇒ Object



33
34
35
# File 'tarantool-rails/lib/tarantool/rails.rb', line 33

def pool
  LOCK.synchronize { @pool ||= build_pool }
end

.storage ⇒ Object



37
38
39
# File 'tarantool-rails/lib/tarantool/rails.rb', line 37

def storage
  LOCK.synchronize { @storage ||= build_storage }
end

.use_default_storage! ⇒ Object

Models without a storage of their own use the configured one, built on first use.



57
58
59
60
# File 'tarantool-rails/lib/tarantool/rails.rb', line 57

def use_default_storage!
  @owns_default_storage = true
  Model.default_storage = -> { storage }
end