ocean-dynamo 0.2.5 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.rdoc +32 -30
- data/lib/ocean-dynamo/attributes.rb +7 -5
- data/lib/ocean-dynamo/engine.rb +2 -0
- data/lib/ocean-dynamo/persistence.rb +6 -6
- data/lib/ocean-dynamo/schema.rb +2 -2
- data/lib/ocean-dynamo/version.rb +1 -1
- metadata +14 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ec5cc85dff191d7167a21eb63097edebd85390b4
|
4
|
+
data.tar.gz: 26d74600e6253dfa77c4bbd3a66be11bf03e5130
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1b192785b2e8f0befeb1241154a0c1d652d6511a13cb44d12b940beedbb13f05685a5791e2cbecd1abccf883da51a95bb6a8219ade4f7cb915ff4b6e3ee6b338
|
7
|
+
data.tar.gz: 8d00dccf68667873f1a2173198969923307d8285f74ce59ed8ffeacbfa80bafb8b4310aeb1c0fb227d0adc5f79fdffb6cab7e3f89bc7fb0a8538ef297369fe54
|
data/README.rdoc
CHANGED
@@ -17,19 +17,18 @@ OceanDynamo requires Ruby 2.0 and Ruby on Rails 4.0.0 or later.
|
|
17
17
|
|
18
18
|
As one important use case for OceanDynamo is to facilitate the conversion of SQL based
|
19
19
|
ActiveRecord models to DynamoDB based models, it is important that the syntax and semantics
|
20
|
-
of OceanDynamo's operations are as close as possible to those of ActiveRecord
|
21
|
-
|
22
|
-
called in the same order as in ActiveRecord. OceanDynamo follows this pattern closely and
|
20
|
+
of OceanDynamo's operations are as close as possible to those of ActiveRecord, including
|
21
|
+
callbacks, exceptions and support methods. Ocean-dynamo follows this pattern closely and
|
23
22
|
is of course based on ActiveModel.
|
24
23
|
|
25
24
|
The attribute and persistence layer of OceanDynamo is modeled on that of ActiveRecord:
|
26
|
-
there's +save+, +save!+, +create+, +update+, +update!+, +
|
25
|
+
there's +save+, +save!+, +create+, +update+, +update!+, +update_attributes+ and all the other
|
27
26
|
methods you're used to. The design goal is always to implement as much as possible of the
|
28
|
-
ActiveRecord interface, without sacrificing scalability. This makes the task of switching
|
29
|
-
SQL to no-SQL much easier.
|
27
|
+
ActiveRecord interface, without sacrificing scalability. This makes the task of switching
|
28
|
+
from SQL to no-SQL much easier.
|
30
29
|
|
31
|
-
|
32
|
-
|
30
|
+
Thanks to its structural similarity to ActiveRecord, OceanDynamo works with FactoryGirl.
|
31
|
+
To facilitate testing, future versions will keep track of and delete instances after tests.
|
33
32
|
|
34
33
|
OceanDynamo will use secondary indices to retrieve related table items,
|
35
34
|
which means it will scale without limits.
|
@@ -61,37 +60,40 @@ The following example shows the syntax.
|
|
61
60
|
|
62
61
|
end
|
63
62
|
|
64
|
-
Each attribute has a name, a type (
|
65
|
-
|
66
|
-
value, which can be a Proc. The hash key attribute is by default
|
67
|
-
course be specified) and is a
|
63
|
+
Each attribute has a name, a type (+:string+, +:integer+, +:float+, +:datetime+, +:boolean+,
|
64
|
+
or +:serialized+) where +:string+ is the default. Each attribute also optionally has a default
|
65
|
+
value, which can be a Proc. The hash key attribute is by default +:uuid+ (this can of
|
66
|
+
course be specified) and is a +:string+. The keys can also be explicitly declared.
|
68
67
|
|
69
|
-
The
|
70
|
-
Sets are represented as arrays
|
68
|
+
The +:string+, +:integer+, +:float+ and +:datetime+ types can also store sets of their type.
|
69
|
+
Sets are represented as arrays, may not contain duplicates and may not be empty.
|
71
70
|
|
72
|
-
All attributes except the
|
73
|
-
value will return the empty string, ""
|
71
|
+
All attributes except the +:string+ type can take the value +nil+. Storing +nil+ for a string
|
72
|
+
value will return the empty string, <tt>""</tt>.
|
74
73
|
|
75
74
|
Also, dynamo_schema takes args and many options. Here's the full syntax:
|
76
75
|
|
77
76
|
dynamo_schema(
|
78
|
-
table_hash_key = :uuid,
|
79
|
-
table_range_key = nil,
|
80
|
-
table_name: compute_table_name,
|
81
|
-
table_name_prefix: nil,
|
82
|
-
table_name_suffix: nil,
|
83
|
-
read_capacity_units: 10,
|
84
|
-
write_capacity_units: 5,
|
85
|
-
connect: :late,
|
86
|
-
create: false,
|
87
|
-
locking: :lock_version,
|
88
|
-
timestamps: [:created_at, :updated_at]
|
89
|
-
|
90
|
-
|
77
|
+
table_hash_key = :uuid, # The name of the hash key attribute
|
78
|
+
table_range_key = nil, # The name of the range key attribute (or nil)
|
79
|
+
table_name: compute_table_name, # The basename of the DynamoDB table
|
80
|
+
table_name_prefix: nil, # A basename prefix string or nil
|
81
|
+
table_name_suffix: nil, # A basename suffix string or nil
|
82
|
+
read_capacity_units: 10, # Used only when creating a table
|
83
|
+
write_capacity_units: 5, # Used only when creating a table
|
84
|
+
connect: :late, # true, :late, nil/false
|
85
|
+
create: false, # If true, create the table if nonexistent
|
86
|
+
locking: :lock_version, # The name of the lock attribute or nil/false
|
87
|
+
timestamps: [:created_at, :updated_at] # An array of timestamp columns or nil/false
|
88
|
+
) do
|
89
|
+
# Attribute definitions
|
90
|
+
...
|
91
|
+
...
|
92
|
+
end
|
91
93
|
|
92
94
|
At the moment, OceanDynamo is fully usable as an ActiveModel and can be used by Rails
|
93
95
|
controllers. Furthermore, OceanDynamo implements much of the infrastructure of ActiveRecord;
|
94
|
-
for instance, read_attribute
|
96
|
+
for instance, +read_attribute+, +write_attribute+, and much of the control logic and
|
95
97
|
parameters.
|
96
98
|
|
97
99
|
Relations are not yet implemented, but are underway. Relations will use secondary
|
@@ -1,12 +1,14 @@
|
|
1
1
|
module OceanDynamo
|
2
2
|
class Base
|
3
|
-
#include ActiveModel::DeprecatedMassAssignmentSecurity
|
4
|
-
#include ActiveModel::ForbiddenAttributesProtection
|
5
3
|
|
4
|
+
#
|
5
|
+
# The hash of attributes and their values. Keys are strings.
|
6
|
+
#
|
6
7
|
attr_reader :attributes
|
7
|
-
|
8
|
-
attr_reader :
|
9
|
-
attr_reader :
|
8
|
+
|
9
|
+
attr_reader :destroyed # :nodoc:
|
10
|
+
attr_reader :new_record # :nodoc:
|
11
|
+
attr_reader :dynamo_item # :nodoc:
|
10
12
|
|
11
13
|
|
12
14
|
def initialize(attrs={})
|
data/lib/ocean-dynamo/engine.rb
CHANGED
@@ -183,7 +183,7 @@ module OceanDynamo
|
|
183
183
|
|
184
184
|
protected
|
185
185
|
|
186
|
-
def self._late_connect?
|
186
|
+
def self._late_connect? # :nodoc:
|
187
187
|
return false if table_connected
|
188
188
|
return false unless table_connect_policy
|
189
189
|
establish_db_connection
|
@@ -191,7 +191,7 @@ module OceanDynamo
|
|
191
191
|
end
|
192
192
|
|
193
193
|
|
194
|
-
def _late_connect?
|
194
|
+
def _late_connect? # :nodoc:
|
195
195
|
self.class._late_connect?
|
196
196
|
end
|
197
197
|
|
@@ -215,7 +215,7 @@ module OceanDynamo
|
|
215
215
|
end
|
216
216
|
|
217
217
|
|
218
|
-
def dynamo_delete(lock: nil)
|
218
|
+
def dynamo_delete(lock: nil) # :nodoc:
|
219
219
|
_late_connect?
|
220
220
|
begin
|
221
221
|
options = _handle_locking(lock)
|
@@ -250,7 +250,7 @@ module OceanDynamo
|
|
250
250
|
end
|
251
251
|
|
252
252
|
|
253
|
-
def set_timestamps(name=nil)
|
253
|
+
def set_timestamps(name=nil) # :nodoc:
|
254
254
|
attrs = []
|
255
255
|
attrs << timestamp_attributes[0] if timestamp_attributes && new_record?
|
256
256
|
attrs << timestamp_attributes[1] if timestamp_attributes
|
@@ -260,7 +260,7 @@ module OceanDynamo
|
|
260
260
|
end
|
261
261
|
|
262
262
|
|
263
|
-
def _set_timestamp_attributes(attrs)
|
263
|
+
def _set_timestamp_attributes(attrs) # :nodoc:
|
264
264
|
return if attrs.blank?
|
265
265
|
t = Time.zone.now
|
266
266
|
attrs.each { |a| write_attribute a, t }
|
@@ -268,7 +268,7 @@ module OceanDynamo
|
|
268
268
|
end
|
269
269
|
|
270
270
|
|
271
|
-
def _handle_locking(lock=lock_attribute)
|
271
|
+
def _handle_locking(lock=lock_attribute) # :nodoc:
|
272
272
|
_late_connect?
|
273
273
|
if lock
|
274
274
|
current_v = read_attribute(lock)
|
data/lib/ocean-dynamo/schema.rb
CHANGED
@@ -28,7 +28,7 @@ module OceanDynamo
|
|
28
28
|
self.table_name_suffix = table_name_suffix
|
29
29
|
self.table_read_capacity_units = read_capacity_units
|
30
30
|
self.table_write_capacity_units = write_capacity_units
|
31
|
-
self.lock_attribute = locking
|
31
|
+
self.lock_attribute = locking if locking
|
32
32
|
self.timestamp_attributes = timestamps
|
33
33
|
# Init
|
34
34
|
self.fields = HashWithIndifferentAccess.new
|
@@ -68,7 +68,7 @@ module OceanDynamo
|
|
68
68
|
|
69
69
|
protected
|
70
70
|
|
71
|
-
def self.dangerous_attributes
|
71
|
+
def self.dangerous_attributes # :nodoc:
|
72
72
|
self.public_methods(false).collect do |sym|
|
73
73
|
str = sym.to_s
|
74
74
|
if str.end_with?("?", "=")
|
data/lib/ocean-dynamo/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ocean-dynamo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Bengtson
|
@@ -112,21 +112,19 @@ description: "== OceanDynamo\n\nThis is the OceanDynamo ruby gem, implementing a
|
|
112
112
|
scalable Amazon DynamoDB near drop-in \nreplacement for ActiveRecord.\n\nAs one
|
113
113
|
important use case for OceanDynamo is to facilitate the conversion of SQL based\nActiveRecord
|
114
114
|
models to DynamoDB based models, it is important that the syntax and semantics\nof
|
115
|
-
OceanDynamo's operations are as close as possible to those of ActiveRecord
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
a Rails framework for creating highly scalable SOAs in the cloud, in which\nocean-dynamo
|
129
|
-
is used as a central component: http://wiki.oceanframework.net"
|
115
|
+
OceanDynamo's operations are as close as possible to those of ActiveRecord, including\ncallbacks,
|
116
|
+
exceptions and support methods. Ocean-dynamo follows this pattern closely and\nis
|
117
|
+
of course based on ActiveModel.\n\nThe attribute and persistence layer of OceanDynamo
|
118
|
+
is modeled on that of ActiveRecord:\nthere's +save+, +save!+, +create+, +update+,
|
119
|
+
+update!+, +update_attributes+ and all the other\nmethods you're used to. The design
|
120
|
+
goal is always to implement as much as possible of the\nActiveRecord interface,
|
121
|
+
without sacrificing scalability. This makes the task of switching from\nSQL to no-SQL
|
122
|
+
much easier.\n\nOceanDynamo will use secondary indices to retrieve related table
|
123
|
+
items, \nwhich means OceanDynamo tables will scale without limits.\n\nThanks to
|
124
|
+
its structural similarity to ActiveRecord, OceanDynamo works with FactoryGirl.\nTo
|
125
|
+
facilitate testing, future versions will keep track of and delete instances after
|
126
|
+
tests.\n\nSee also Ocean, a Rails framework for creating highly scalable SOAs in
|
127
|
+
the cloud, in which\nocean-dynamo is used as a central component: http://wiki.oceanframework.net"
|
130
128
|
email:
|
131
129
|
- peter@peterbengtson.com
|
132
130
|
executables: []
|