tarantool-rails 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/README.md +7 -3
- data/lib/tarantool/rails/log_subscriber.rb +4 -0
- data/lib/tarantool/rails/tasks/schema.rake +29 -6
- data/lib/tarantool/rails/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 80ffc3cc37871dc29b1b3fb3b9da05958369823bca8e9685ed6f341ebbb9212e
|
|
4
|
+
data.tar.gz: e8428bdd33eb1e8ecb1107bd3b8eb657b8906f0220325048aa1bea8402303a69
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d10aff0d221c3ab0c395a6e1dea3e106c50befda2dd38425f6ac2e926158350ac2859aa39bee54335e21d4e78ac679fc6e291cc2576b31768616006e820084c7
|
|
7
|
+
data.tar.gz: 19c895b419c10098ea3d347848f74d216d29b76206630d6979f0ae14ad8d59f0b0a50274c51ea10b854d89fef50a1ab9716aa7c597481f4f2f7dd287093487e4
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.2.0 (2026-10-17)
|
|
4
|
+
|
|
5
|
+
- `tarantool:schema:dump` writes the live schema to `config/tarantool_schema.rb` (`FORCE=1` to overwrite,
|
|
6
|
+
`dump[users,codes]` to limit the spaces).
|
|
7
|
+
- `plan`, `apply` and `check` take `alter` names as a task argument: `"tarantool:schema:apply[add_field]"`.
|
|
8
|
+
- `LogSubscriber` logs `shutdown.tarantool` (tarantool-client 0.3.0) at info.
|
|
9
|
+
- Depends on `tarantool-schema ~> 0.2`.
|
|
10
|
+
|
|
3
11
|
## 0.1.0 (2026-10-17)
|
|
4
12
|
|
|
5
13
|
First release.
|
data/README.md
CHANGED
|
@@ -101,7 +101,7 @@ Completed 200 OK in 4ms (Views: 1.9ms | Tarantool: 0.5ms)
|
|
|
101
101
|
Request lines are debug, colored like ActiveRecord's when `colorize_logging` is on. Keys, tuples and
|
|
102
102
|
arguments never appear: the client does not put them in the event payload. A failed request shows the error
|
|
103
103
|
class and code, not the message. Lifecycle events are logged too: `disconnect` at warn, `reconnect_failed` at
|
|
104
|
-
error, `reconnect`, `fork` and `
|
|
104
|
+
error, `reconnect`, `fork`, `role_change` and `shutdown` at info.
|
|
105
105
|
|
|
106
106
|
## Schema
|
|
107
107
|
|
|
@@ -118,10 +118,14 @@ end
|
|
|
118
118
|
| Task | |
|
|
119
119
|
|---|---|
|
|
120
120
|
| `rails tarantool:schema:plan` | prints what `apply` would create; drift raises `MismatchError` with the diff |
|
|
121
|
-
| `rails tarantool:schema:apply` | creates the missing spaces and indexes and prints them; never
|
|
121
|
+
| `rails tarantool:schema:apply` | creates the missing spaces and indexes and prints them; never drops |
|
|
122
122
|
| `rails tarantool:schema:check` | for CI: exits 1 and prints `pending: ...` when anything would be created, 0 when live equals declared |
|
|
123
|
+
| `rails tarantool:schema:dump` | writes the live schema to `config/tarantool_schema.rb` for bootstrapping; refuses to overwrite unless `FORCE=1`; `dump[users,codes]` limits the spaces |
|
|
123
124
|
|
|
124
|
-
|
|
125
|
+
`plan`, `apply` and `check` take the tarantool-schema `alter:` names as an argument: `rails
|
|
126
|
+
"tarantool:schema:apply[add_field]"` appends nullable fields declared past the end of a live format. Without it
|
|
127
|
+
such a format is drift. The tasks connect with `admin_uri`; see the tarantool-schema README for the privileges
|
|
128
|
+
that user needs.
|
|
125
129
|
|
|
126
130
|
## Generators
|
|
127
131
|
|
|
@@ -57,6 +57,10 @@ module Tarantool
|
|
|
57
57
|
info "Tarantool #{event.payload[:address]} is now #{event.payload[:read_only] ? 'read-only' : 'writable'}"
|
|
58
58
|
end
|
|
59
59
|
|
|
60
|
+
def shutdown(event)
|
|
61
|
+
info "Tarantool #{event.payload[:address]} is shutting down, #{event.payload[:pending]} requests in flight"
|
|
62
|
+
end
|
|
63
|
+
|
|
60
64
|
private
|
|
61
65
|
|
|
62
66
|
def request_name(payload)
|
|
@@ -1,24 +1,47 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
# Task arguments are one String: rails "tarantool:schema:apply[add_field]", "tarantool:schema:dump[users,codes]".
|
|
4
|
+
TARANTOOL_SCHEMA_NAME_SEPARATOR = /[\s,]+/
|
|
5
|
+
|
|
6
|
+
def tarantool_schema_names(argument) = argument.to_s.split(TARANTOOL_SCHEMA_NAME_SEPARATOR).reject(&:empty?)
|
|
7
|
+
|
|
8
|
+
def tarantool_schema_dump(path, only)
|
|
9
|
+
abort "#{path} exists; set FORCE=1 to overwrite" if File.exist?(path) && ENV['FORCE'].to_s.empty?
|
|
10
|
+
|
|
11
|
+
definition = Tarantool::Rails.admin_client do |client|
|
|
12
|
+
Tarantool::Schema::Definition.from_live(client, only: only.empty? ? nil : only)
|
|
13
|
+
end
|
|
14
|
+
File.write(path, "# frozen_string_literal: true\n\nTarantool::Rails.schema = #{definition.to_ruby}")
|
|
15
|
+
puts path
|
|
16
|
+
end
|
|
17
|
+
|
|
3
18
|
namespace :tarantool do
|
|
4
19
|
namespace :schema do
|
|
5
20
|
desc 'Print what tarantool:schema:apply would create; fail on drift'
|
|
6
|
-
task plan: :environment do
|
|
7
|
-
|
|
21
|
+
task :plan, [:alter] => :environment do |_task, args|
|
|
22
|
+
alter = tarantool_schema_names(args[:alter]).map(&:to_sym)
|
|
23
|
+
Tarantool::Rails.admin_client { |client| puts Tarantool::Rails.schema.plan(client, alter:) }
|
|
8
24
|
end
|
|
9
25
|
|
|
10
26
|
desc 'Create missing Tarantool spaces and indexes; fail on drift'
|
|
11
|
-
task apply: :environment do
|
|
12
|
-
|
|
27
|
+
task :apply, [:alter] => :environment do |_task, args|
|
|
28
|
+
alter = tarantool_schema_names(args[:alter]).map(&:to_sym)
|
|
29
|
+
Tarantool::Rails.admin_client { |client| puts Tarantool::Rails.schema.apply(client, alter:) }
|
|
13
30
|
end
|
|
14
31
|
|
|
15
32
|
desc 'Fail unless the live schema equals the declaration, for CI'
|
|
16
|
-
task check: :environment do
|
|
17
|
-
|
|
33
|
+
task :check, [:alter] => :environment do |_task, args|
|
|
34
|
+
alter = tarantool_schema_names(args[:alter]).map(&:to_sym)
|
|
35
|
+
pending = Tarantool::Rails.admin_client { |client| Tarantool::Rails.schema.plan(client, alter:) }
|
|
18
36
|
next if pending.empty?
|
|
19
37
|
|
|
20
38
|
pending.each { |line| puts "pending: #{line}" }
|
|
21
39
|
exit 1
|
|
22
40
|
end
|
|
41
|
+
|
|
42
|
+
desc 'Write the live schema to config/tarantool_schema.rb (FORCE=1 to overwrite; spaces as [users,codes])'
|
|
43
|
+
task :dump, [:only] => :environment do |_task, args|
|
|
44
|
+
tarantool_schema_dump(Tarantool::Rails.schema_path.to_s, tarantool_schema_names(args[:only]))
|
|
45
|
+
end
|
|
23
46
|
end
|
|
24
47
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: tarantool-rails
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Starlexxx
|
|
@@ -64,14 +64,14 @@ dependencies:
|
|
|
64
64
|
requirements:
|
|
65
65
|
- - "~>"
|
|
66
66
|
- !ruby/object:Gem::Version
|
|
67
|
-
version: '0.
|
|
67
|
+
version: '0.2'
|
|
68
68
|
type: :runtime
|
|
69
69
|
prerelease: false
|
|
70
70
|
version_requirements: !ruby/object:Gem::Requirement
|
|
71
71
|
requirements:
|
|
72
72
|
- - "~>"
|
|
73
73
|
- !ruby/object:Gem::Version
|
|
74
|
-
version: '0.
|
|
74
|
+
version: '0.2'
|
|
75
75
|
description: config/tarantool.yml per environment, one connection pool per process,
|
|
76
76
|
models on it without an initializer, ActiveRecord-style log lines, schema rake tasks
|
|
77
77
|
and generators.
|