redcord 0.1.3 → 0.1.6
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/lib/redcord/actions.rb +14 -9
- data/lib/redcord/attribute.rb +1 -4
- data/lib/redcord/errors.rb +18 -0
- data/lib/redcord/relation.rb +4 -7
- data/lib/redcord/serializer.rb +1 -9
- data/lib/redcord/vacuum_helper.rb +3 -3
- data/lib/redcord.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 91184713358e549897cc7d1a544a8f8244b2aa267b623a6af947711219983ce5
|
4
|
+
data.tar.gz: d24d9e8f1f5cfa72afc6c4f2bfe64933f8f7278ed3dd7a3a53f4ae026168a732
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 828c660a25ea131fc013ba261cb3395fbbcc637170f5b8601f68e30f7095cda8f5e3ed5781bcbb0bf39fcec693438953b76b4a106b9fd9966e3c5f3ff6469145
|
7
|
+
data.tar.gz: e3a6469ae8778ea5c110922c7324c43e394e273c0392a16524bbe489fd24df4bffca4cd83c7a225430b05ac134e346dad9de64e2514f87caddf249704209961d
|
data/lib/redcord/actions.rb
CHANGED
@@ -3,15 +3,8 @@
|
|
3
3
|
# typed: strict
|
4
4
|
|
5
5
|
require 'sorbet-coerce'
|
6
|
-
|
7
6
|
require 'redcord/relation'
|
8
7
|
|
9
|
-
module Redcord
|
10
|
-
# Raised by Model.find
|
11
|
-
class RecordNotFound < StandardError; end
|
12
|
-
class InvalidAction < StandardError; end
|
13
|
-
end
|
14
|
-
|
15
8
|
module Redcord::Actions
|
16
9
|
extend T::Sig
|
17
10
|
extend T::Helpers
|
@@ -171,6 +164,13 @@ module Redcord::Actions
|
|
171
164
|
)
|
172
165
|
end
|
173
166
|
end
|
167
|
+
# TODO: break down Redis::CommandError further by parsing the error message
|
168
|
+
rescue Redis::CommandError => e
|
169
|
+
if e.message.include?('has been deleted')
|
170
|
+
raise Redcord::RedcordDeletedError.new(e)
|
171
|
+
else
|
172
|
+
raise e
|
173
|
+
end
|
174
174
|
end
|
175
175
|
|
176
176
|
sig { returns(T::Boolean) }
|
@@ -179,7 +179,6 @@ module Redcord::Actions
|
|
179
179
|
|
180
180
|
true
|
181
181
|
rescue Redis::CommandError
|
182
|
-
# TODO: break down Redis::CommandError by parsing the error message
|
183
182
|
false
|
184
183
|
end
|
185
184
|
|
@@ -213,6 +212,13 @@ module Redcord::Actions
|
|
213
212
|
)
|
214
213
|
end
|
215
214
|
end
|
215
|
+
# TODO: break down Redis::CommandError further by parsing the error message
|
216
|
+
rescue Redis::CommandError => e
|
217
|
+
if e.message.include?('has been deleted')
|
218
|
+
raise Redcord::RedcordDeletedError.new(e)
|
219
|
+
else
|
220
|
+
raise e
|
221
|
+
end
|
216
222
|
end
|
217
223
|
|
218
224
|
sig { params(args: T::Hash[Symbol, T.untyped]).returns(T::Boolean) }
|
@@ -221,7 +227,6 @@ module Redcord::Actions
|
|
221
227
|
|
222
228
|
true
|
223
229
|
rescue Redis::CommandError
|
224
|
-
# TODO: break down Redis::CommandError by parsing the error message
|
225
230
|
false
|
226
231
|
end
|
227
232
|
|
data/lib/redcord/attribute.rb
CHANGED
@@ -1,9 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# typed: strict
|
4
|
-
module Redcord
|
5
|
-
class InvalidAttribute < StandardError; end
|
6
|
-
end
|
7
4
|
|
8
5
|
module Redcord::Attribute
|
9
6
|
extend T::Sig
|
@@ -37,7 +34,7 @@ module Redcord::Attribute
|
|
37
34
|
klass.include(InstanceMethods)
|
38
35
|
klass.class_variable_set(:@@index_attributes, Set.new)
|
39
36
|
klass.class_variable_set(:@@range_index_attributes, Set.new)
|
40
|
-
klass.class_variable_set(:@@custom_index_attributes, Hash.new
|
37
|
+
klass.class_variable_set(:@@custom_index_attributes, Hash.new)
|
41
38
|
klass.class_variable_set(:@@ttl, nil)
|
42
39
|
klass.class_variable_set(:@@shard_by_attribute, nil)
|
43
40
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Redcord
|
4
|
+
# Raised by Model.find
|
5
|
+
class RecordNotFound < StandardError; end
|
6
|
+
class InvalidAction < StandardError; end
|
7
|
+
|
8
|
+
# Raised by Model.where
|
9
|
+
class InvalidQuery < StandardError; end
|
10
|
+
class AttributeNotIndexed < StandardError; end
|
11
|
+
class WrongAttributeType < TypeError; end
|
12
|
+
class CustomIndexInvalidQuery < StandardError; end
|
13
|
+
class CustomIndexInvalidDesign < StandardError; end
|
14
|
+
class RedcordDeletedError < ::Redis::CommandError; end
|
15
|
+
|
16
|
+
# Raised by shared_by_attribute
|
17
|
+
class InvalidAttribute < StandardError; end
|
18
|
+
end
|
data/lib/redcord/relation.rb
CHANGED
@@ -2,13 +2,10 @@
|
|
2
2
|
|
3
3
|
# typed: strict
|
4
4
|
|
5
|
+
require 'active_support'
|
5
6
|
require 'active_support/core_ext/array'
|
6
7
|
require 'active_support/core_ext/module'
|
7
8
|
|
8
|
-
module Redcord
|
9
|
-
class InvalidQuery < StandardError; end
|
10
|
-
end
|
11
|
-
|
12
9
|
class Redcord::Relation
|
13
10
|
extend T::Sig
|
14
11
|
|
@@ -98,7 +95,7 @@ class Redcord::Relation
|
|
98
95
|
extract_query_conditions!,
|
99
96
|
index_attrs: model._script_arg_index_attrs,
|
100
97
|
range_index_attrs: model._script_arg_range_index_attrs,
|
101
|
-
custom_index_attrs: model._script_arg_custom_index_attrs[custom_index_name],
|
98
|
+
custom_index_attrs: model._script_arg_custom_index_attrs[custom_index_name] || [],
|
102
99
|
hash_tag: extract_hash_tag!,
|
103
100
|
custom_index_name: custom_index_name
|
104
101
|
)
|
@@ -222,7 +219,7 @@ class Redcord::Relation
|
|
222
219
|
select_attrs: select_attrs,
|
223
220
|
index_attrs: model._script_arg_index_attrs,
|
224
221
|
range_index_attrs: model._script_arg_range_index_attrs,
|
225
|
-
custom_index_attrs: model._script_arg_custom_index_attrs[custom_index_name],
|
222
|
+
custom_index_attrs: model._script_arg_custom_index_attrs[custom_index_name] || [],
|
226
223
|
hash_tag: extract_hash_tag!,
|
227
224
|
custom_index_name: custom_index_name
|
228
225
|
)
|
@@ -238,7 +235,7 @@ class Redcord::Relation
|
|
238
235
|
extract_query_conditions!,
|
239
236
|
index_attrs: model._script_arg_index_attrs,
|
240
237
|
range_index_attrs: model._script_arg_range_index_attrs,
|
241
|
-
custom_index_attrs: model._script_arg_custom_index_attrs[custom_index_name],
|
238
|
+
custom_index_attrs: model._script_arg_custom_index_attrs[custom_index_name] || [],
|
242
239
|
hash_tag: extract_hash_tag!,
|
243
240
|
custom_index_name: custom_index_name
|
244
241
|
)
|
data/lib/redcord/serializer.rb
CHANGED
@@ -4,14 +4,6 @@
|
|
4
4
|
|
5
5
|
require 'redcord/range_interval'
|
6
6
|
|
7
|
-
module Redcord
|
8
|
-
# Raised by Model.where
|
9
|
-
class AttributeNotIndexed < StandardError; end
|
10
|
-
class WrongAttributeType < TypeError; end
|
11
|
-
class CustomIndexInvalidQuery < StandardError; end
|
12
|
-
class CustomIndexInvalidDesign < StandardError; end
|
13
|
-
end
|
14
|
-
|
15
7
|
# This module defines various helper methods on Redcord for serialization
|
16
8
|
# between the Ruby client and Redis server.
|
17
9
|
module Redcord::Serializer
|
@@ -81,7 +73,7 @@ module Redcord::Serializer
|
|
81
73
|
attr_keys.each do |attr_key|
|
82
74
|
next if attr_key == shard_by_attribute
|
83
75
|
|
84
|
-
if !custom_index_attributes.empty?
|
76
|
+
if !custom_index_attributes.nil? && !custom_index_attributes.empty?
|
85
77
|
if !custom_index_attributes.include?(attr_key)
|
86
78
|
raise(
|
87
79
|
Redcord::AttributeNotIndexed,
|
@@ -9,15 +9,15 @@ module Redcord::VacuumHelper
|
|
9
9
|
sig { params(model: T.class_of(Redcord::Base)).void }
|
10
10
|
def self.vacuum(model)
|
11
11
|
model.class_variable_get(:@@index_attributes).each do |index_attr|
|
12
|
-
puts "Vacuuming index attribute: #{index_attr}"
|
12
|
+
puts "Vacuuming index attribute: #{index_attr} for model: #{model.name}"
|
13
13
|
_vacuum_index_attribute(model, index_attr)
|
14
14
|
end
|
15
15
|
model.class_variable_get(:@@range_index_attributes).each do |range_index_attr|
|
16
|
-
puts "Vacuuming range index attribute: #{range_index_attr}"
|
16
|
+
puts "Vacuuming range index attribute: #{range_index_attr} for model: #{model.name}"
|
17
17
|
_vacuum_range_index_attribute(model, range_index_attr)
|
18
18
|
end
|
19
19
|
model.class_variable_get(:@@custom_index_attributes).keys.each do |index_name|
|
20
|
-
puts "Vacuuming custom index: #{index_name}"
|
20
|
+
puts "Vacuuming custom index: #{index_name} for model: #{model.name}"
|
21
21
|
_vacuum_custom_index(model, index_name)
|
22
22
|
end
|
23
23
|
end
|
data/lib/redcord.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redcord
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chan Zuckerberg Initiative
|
@@ -177,6 +177,7 @@ files:
|
|
177
177
|
- lib/redcord/base.rb
|
178
178
|
- lib/redcord/configurations.rb
|
179
179
|
- lib/redcord/connection_pool.rb
|
180
|
+
- lib/redcord/errors.rb
|
180
181
|
- lib/redcord/logger.rb
|
181
182
|
- lib/redcord/lua_script_reader.rb
|
182
183
|
- lib/redcord/migration.rb
|
@@ -220,7 +221,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
220
221
|
- !ruby/object:Gem::Version
|
221
222
|
version: '0'
|
222
223
|
requirements: []
|
223
|
-
rubygems_version: 3.
|
224
|
+
rubygems_version: 3.1.6
|
224
225
|
signing_key:
|
225
226
|
specification_version: 4
|
226
227
|
summary: A Ruby ORM like Active Record, but for Redis
|