ocean-dynamo 0.3.9 → 0.3.10
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/README.rdoc +51 -41
- data/lib/ocean-dynamo/persistence.rb +16 -0
- data/lib/ocean-dynamo/queries.rb +28 -0
- data/lib/ocean-dynamo/version.rb +1 -1
- metadata +10 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f6249788253589b08c22ba6f39f134b14ac986b5
|
4
|
+
data.tar.gz: 1d170f9c05448c3136fe7df37de6f6f43f56666f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 84d2847bba2ae68f2c29aa52844081bab0a0e61976b8b9b5fc25cb185f8eb039481418b501ce36db628a8912bfbc95fce488121abe766de45cca39525f5fc433
|
7
|
+
data.tar.gz: 238e095ec0105f540326430af4e0445c02cdf9ee557780e87c6e10284f53aa6e97aa43be57c29747e343b4051a51c1f3bdfef782abea06e60f8164a5a7a3511b
|
data/README.rdoc
CHANGED
@@ -8,34 +8,6 @@ OceanDynamo requires Ruby 2.0 and Ruby on Rails 4.0.0 or later.
|
|
8
8
|
{<img src="https://badge.fury.io/rb/ocean-dynamo.png" alt="Gem Version" />}[http://badge.fury.io/rb/ocean-dynamo]
|
9
9
|
|
10
10
|
|
11
|
-
==== Installation
|
12
|
-
|
13
|
-
gem install ocean-dynamo
|
14
|
-
|
15
|
-
Then, locate the gem's directory and copy
|
16
|
-
|
17
|
-
spec/dummy/config/initializers/aws.rb
|
18
|
-
|
19
|
-
to your project's
|
20
|
-
|
21
|
-
config/initializers/aws.rb
|
22
|
-
|
23
|
-
Also copy
|
24
|
-
|
25
|
-
spec/dummy/config/aws.yml.example
|
26
|
-
|
27
|
-
to both the following locations in your project:
|
28
|
-
|
29
|
-
config/aws.yml.example
|
30
|
-
config/aws.yml
|
31
|
-
|
32
|
-
Enter your AWS credentials in the latter file. Eventually, there
|
33
|
-
will be a generator to copy these files for you, but for now you need to do it manually.
|
34
|
-
|
35
|
-
You also need +fake_dynamo+ to run DynamoDB locally: see below for installation instructions.
|
36
|
-
NB: You do not need an Amazon AWS account to run OceanDynamo locally.
|
37
|
-
|
38
|
-
|
39
11
|
==== Features
|
40
12
|
|
41
13
|
As one important use case for OceanDynamo is to facilitate the conversion of SQL based
|
@@ -45,18 +17,17 @@ callbacks, exceptions and support methods. Ocean-dynamo follows this pattern clo
|
|
45
17
|
is of course based on ActiveModel.
|
46
18
|
|
47
19
|
The attribute and persistence layer of OceanDynamo is modeled on that of ActiveRecord:
|
48
|
-
there's +save+, +save!+, +create+, +update+, +update!+, +update_attributes+
|
49
|
-
methods you're used to. The design goal is always to implement as much
|
50
|
-
ActiveRecord interface, without sacrificing scalability. This makes the
|
51
|
-
from SQL to no-SQL much easier.
|
20
|
+
there's +save+, +save!+, +create+, +update+, +update!+, +update_attributes+, +find_each+,
|
21
|
+
and all the other methods you're used to. The design goal is always to implement as much
|
22
|
+
as possible of the ActiveRecord interface, without sacrificing scalability. This makes the
|
23
|
+
task of switching from SQL to no-SQL much easier.
|
52
24
|
|
53
25
|
Thanks to its structural similarity to ActiveRecord, OceanDynamo works with FactoryGirl.
|
54
26
|
To facilitate testing, future versions will keep track of and delete instances after tests.
|
55
27
|
|
56
|
-
OceanDynamo
|
28
|
+
OceanDynamo uses primary and secondary indices to retrieve related table items,
|
57
29
|
which means it will scale without limits.
|
58
30
|
|
59
|
-
|
60
31
|
==== Example
|
61
32
|
|
62
33
|
The following example shows the syntax.
|
@@ -115,22 +86,61 @@ Also, dynamo_schema takes args and many options. Here's the full syntax:
|
|
115
86
|
end
|
116
87
|
|
117
88
|
|
118
|
-
|
89
|
+
=== Current State
|
119
90
|
|
120
91
|
At the moment, OceanDynamo is fully usable as an ActiveModel and can be used by Rails
|
121
92
|
controllers. Furthermore, OceanDynamo implements much of the infrastructure of ActiveRecord;
|
122
93
|
for instance, +read_attribute+, +write_attribute+, and much of the control logic and
|
123
94
|
parameters.
|
124
95
|
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
Work has begun on the +has_many+ / +belongs_to+ association which requires only a primary
|
129
|
-
|
96
|
+
At the moment, Model.find only takes a single id. Model.all and Model.count work as
|
97
|
+
expected. Model.find_each and Model.find_in_batches are also available.
|
98
|
+
|
99
|
+
Work has begun on the +has_many+ / +belongs_to+ association which requires only a primary
|
100
|
+
index. This association is even more efficient than its ActiveRecord counterpart.
|
101
|
+
|
102
|
+
|
103
|
+
=== Future milestones
|
104
|
+
|
105
|
+
After the +has_many+ / +belongs_to+ association, the +has_and_belongs_to_many+ assocation
|
106
|
+
will be implemented. This will require secondary indices. This, and other associations will
|
107
|
+
use secondary indices. OceanDynamo will use association proxies to achieve the same kind of
|
108
|
+
interface as ActiveRecord, e.g.: <code>blog_entry.comments.build(body: "Cool!").save!</code>
|
109
|
+
|
110
|
+
|
111
|
+
=== Current use
|
130
112
|
|
131
113
|
OceanDynamo is currently used in the Ocean framework (http://wiki.oceanframework.net)
|
132
114
|
e.g. to implement critical job queues. It will be used increasingly as features are
|
133
|
-
added to OceanDynamo and will eventually replace all ActiveRecord tables.
|
115
|
+
added to OceanDynamo and will eventually replace all ActiveRecord tables in Ocean.
|
116
|
+
|
117
|
+
|
118
|
+
==== Installation
|
119
|
+
|
120
|
+
gem install ocean-dynamo
|
121
|
+
|
122
|
+
Then, locate the gem's directory and copy
|
123
|
+
|
124
|
+
spec/dummy/config/initializers/aws.rb
|
125
|
+
|
126
|
+
to your project's
|
127
|
+
|
128
|
+
config/initializers/aws.rb
|
129
|
+
|
130
|
+
Also copy
|
131
|
+
|
132
|
+
spec/dummy/config/aws.yml.example
|
133
|
+
|
134
|
+
to both the following locations in your project:
|
135
|
+
|
136
|
+
config/aws.yml.example
|
137
|
+
config/aws.yml
|
138
|
+
|
139
|
+
Enter your AWS credentials in the latter file. Eventually, there
|
140
|
+
will be a generator to copy these files for you, but for now you need to do it manually.
|
141
|
+
|
142
|
+
You also need +fake_dynamo+ to run DynamoDB locally: see below for installation instructions.
|
143
|
+
NB: You do not need an Amazon AWS account to run OceanDynamo locally.
|
134
144
|
|
135
145
|
|
136
146
|
== Documentation
|
@@ -32,6 +32,22 @@ module OceanDynamo
|
|
32
32
|
end
|
33
33
|
|
34
34
|
|
35
|
+
def self.delete_all
|
36
|
+
dynamo_items.each() do |item|
|
37
|
+
item.delete
|
38
|
+
end
|
39
|
+
nil
|
40
|
+
end
|
41
|
+
|
42
|
+
|
43
|
+
def self.destroy_all
|
44
|
+
dynamo_items.select() do |item_data|
|
45
|
+
new._setup_from_dynamo(item_data).destroy
|
46
|
+
end
|
47
|
+
nil
|
48
|
+
end
|
49
|
+
|
50
|
+
|
35
51
|
# ---------------------------------------------------------
|
36
52
|
#
|
37
53
|
# Instance variables and methods
|
data/lib/ocean-dynamo/queries.rb
CHANGED
@@ -42,5 +42,33 @@ module OceanDynamo
|
|
42
42
|
result
|
43
43
|
end
|
44
44
|
|
45
|
+
|
46
|
+
#
|
47
|
+
# Looping through a collection of records from the database (using the +all+ method,
|
48
|
+
# for example) is very inefficient since it will try to instantiate all the objects at once.
|
49
|
+
#
|
50
|
+
# In that case, batch processing methods allow you to work with the records in batches,
|
51
|
+
# thereby greatly reducing memory consumption.
|
52
|
+
#
|
53
|
+
def self.find_each(limit: nil, batch_size: 1000)
|
54
|
+
dynamo_items.select(limit: limit, batch_size: 1000) do |item_data|
|
55
|
+
yield new._setup_from_dynamo(item_data)
|
56
|
+
end
|
57
|
+
true
|
58
|
+
end
|
59
|
+
|
60
|
+
|
61
|
+
# #
|
62
|
+
# # Yields each batch of records that was found by the find options as an array. The size of
|
63
|
+
# # each batch is set by the :batch_size option; the default is 1000.
|
64
|
+
# #
|
65
|
+
# # You can control the starting point for the batch processing by supplying the :start option.
|
66
|
+
# # This is especially useful if you want multiple workers dealing with the same processing queue. You can make worker 1 handle all the records between id 0 and 10,000 and worker 2 handle from 10,000 and beyond (by setting the :start option on that worker).
|
67
|
+
# #
|
68
|
+
# # It’s not possible to set the order.
|
69
|
+
# #
|
70
|
+
# def self.find_in_batches(start: nil, batch_size: 1000)
|
71
|
+
# []
|
72
|
+
# end
|
45
73
|
end
|
46
74
|
end
|
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.3.
|
4
|
+
version: 0.3.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Bengtson
|
@@ -144,15 +144,15 @@ description: "== OceanDynamo\n\nOceanDynamo is a massively scalable Amazon Dynam
|
|
144
144
|
and support methods. Ocean-dynamo follows this pattern closely and\nis of course
|
145
145
|
based on ActiveModel.\n\nThe attribute and persistence layer of OceanDynamo is modeled
|
146
146
|
on that of ActiveRecord:\nthere's +save+, +save!+, +create+, +update+, +update!+,
|
147
|
-
+update_attributes+
|
148
|
-
always to implement as much
|
149
|
-
sacrificing scalability. This makes the
|
150
|
-
easier.\n\
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
Ocean, a Rails framework for creating highly scalable SOAs in the cloud, in
|
155
|
-
is used as a central component: http://wiki.oceanframework.net"
|
147
|
+
+update_attributes+, +find_each+,\nand all the other methods you're used to. The
|
148
|
+
design goal is always to implement as much \nas possible of the ActiveRecord interface,
|
149
|
+
without sacrificing scalability. This makes the \ntask of switching from SQL to
|
150
|
+
no-SQL much easier.\n\nThanks to its structural similarity to ActiveRecord, OceanDynamo
|
151
|
+
works with FactoryGirl.\nTo facilitate testing, future versions will keep track
|
152
|
+
of and delete instances after tests.\n\nOceanDynamo uses primary and secondary indices
|
153
|
+
to retrieve related table items, \nwhich means it will scale without limits.\n\nSee
|
154
|
+
also Ocean, a Rails framework for creating highly scalable SOAs in the cloud, in
|
155
|
+
which\nocean-dynamo is used as a central component: http://wiki.oceanframework.net"
|
156
156
|
email:
|
157
157
|
- peter@peterbengtson.com
|
158
158
|
executables: []
|