Class: Tarantool::Crud::Client
- Inherits:
-
Object
- Object
- Tarantool::Crud::Client
- Defined in:
- tarantool-crud/lib/tarantool/crud/client.rb
Overview
Entry point: crud functions over any caller responding to call(function, arguments, timeout:).
Instance Method Summary collapse
-
#initialize(caller, read: {}, write: {}, timeout_margin: 0.5) ⇒ Client
constructor
A new instance of Client.
-
#schema(space = nil, **options) ⇒ Object
The format and indexes of one space, or of every space keyed by name, as crud sees them through the router: the same shape as a tarantool-schema declaration, so MemoryStorage.new(crud.schema, behaves_like: :crud) works.
- #space(name) ⇒ Object
-
#stats(space = nil, timeout: nil) ⇒ Object
crud.stats takes no options and encodes an empty table as an Array.
- #storage_info(**options) ⇒ Object
Constructor Details
#initialize(caller, read: {}, write: {}, timeout_margin: 0.5) ⇒ Client
Returns a new instance of Client.
7 8 9 |
# File 'tarantool-crud/lib/tarantool/crud/client.rb', line 7 def initialize(caller, read: {}, write: {}, timeout_margin: 0.5) @call = Call.new(caller, defaults: Defaults.new(read:, write:), timeout_margin:) end |
Instance Method Details
#schema(space = nil, **options) ⇒ Object
The format and indexes of one space, or of every space keyed by name, as crud sees them through the router: the same shape as a tarantool-schema declaration, so MemoryStorage.new(crud.schema, behaves_like: :crud) works. An unknown space raises SchemaError.
18 19 20 21 22 |
# File 'tarantool-crud/lib/tarantool/crud/client.rb', line 18 def schema(space = nil, **) raw = @call.value('schema', [space&.to_s], ) space ? Schema.space(raw) : Schema.all(raw) end |
#space(name) ⇒ Object
11 |
# File 'tarantool-crud/lib/tarantool/crud/client.rb', line 11 def space(name) = Space.new(name, @call) |
#stats(space = nil, timeout: nil) ⇒ Object
crud.stats takes no options and encodes an empty table as an Array.
25 26 27 28 29 |
# File 'tarantool-crud/lib/tarantool/crud/client.rb', line 25 def stats(space = nil, timeout: nil) stats = @call.('stats', [space&.to_s].compact, timeout).first stats.is_a?(Hash) ? stats : {} end |
#storage_info(**options) ⇒ Object
13 |
# File 'tarantool-crud/lib/tarantool/crud/client.rb', line 13 def storage_info(**) = @call.value('storage_info', [], ) |