eventosaurus 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +11 -14
- data/lib/eventosaurus.rb +1 -0
- data/lib/eventosaurus/configuration.rb +4 -6
- data/lib/eventosaurus/lib/test_mode.rb +11 -0
- data/lib/eventosaurus/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 599ff59a55cf9f34dc2c1fce3b3ef8e605bc2aee
|
4
|
+
data.tar.gz: 832ae4467408a064116a2335ba9e41fefc923c30
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 393946457e9f53cc08e65c1b9e42284840280039aac1c0777298bec8210b07047761d25c56cd986b11cd682151277632771023c30c387eb296839877fb74d7cf
|
7
|
+
data.tar.gz: 2f6234c2b220187f760d3d03d5cc5ab0f26299b3927d6846980e4a1038b22353889368f34787c5535b7297d4bd6d1b49aacfb54688b43c437ab6be85b332c5e7
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -127,7 +127,7 @@ There are some built-in attributes for your events:
|
|
127
127
|
|
128
128
|
## Building the Tables
|
129
129
|
|
130
|
-
DynamoDB must have the tables needed to run your events. Once you've written your event classes you must run a rake task to create the tables. The tables are namespaced by your environment, as defined in the environment_prefix variable mentioned above. So if you build locally, the table name might be `
|
130
|
+
DynamoDB must have the tables needed to run your events. Once you've written your event classes you must run a rake task to create the tables. The tables are namespaced by your environment, as defined in the environment_prefix variable mentioned above. So if you build locally, the table name might be `localhost_phone_call`. This will allow us to quickly get up and running on new environments. For the time being, the rake task expects your event definitions to be in `app/models/events`. **Be sure to put them there!**. Rake tasks are scoped to only work with tables that begin with your environment_prefix. This means even if staging and production point to the same dynamodb account, the `drop_tables` task will only drop tables from the environment specified.
|
131
131
|
|
132
132
|
```
|
133
133
|
rake eventosaurus:create_tables
|
@@ -159,15 +159,12 @@ To store data use the `.store` class method on your event class. Use the same si
|
|
159
159
|
|
160
160
|
```ruby
|
161
161
|
# Somewhere in your app:
|
162
|
-
def
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
updated_by_user_id: 35,
|
168
|
-
audit_occurred_at: UTC.now
|
162
|
+
def check_for_phonecall(row)
|
163
|
+
Events::PhoneCall.store(
|
164
|
+
person_id: row[:person_id],
|
165
|
+
phone_number: row[:phone_number],
|
166
|
+
last_called: row[:last_called]
|
169
167
|
)
|
170
|
-
end
|
171
168
|
end
|
172
169
|
```
|
173
170
|
|
@@ -176,17 +173,17 @@ To store data use the `.store` class method on your event class. Use the same si
|
|
176
173
|
The gem gives you some dynamic methods to query your data based on your table definition. It's important to keep in mind that you are working with DynamoDB. It is not meant to be a data store that is accessed generically. It expects you to know the queries you want to run upfront. Good for us, we are storing each event type in its own table, so we can make good guesses about this. To this end, eventosaurus creates getters for the attributes you listed in your table definition:
|
177
174
|
|
178
175
|
```ruby
|
179
|
-
Events::
|
180
|
-
Events::
|
176
|
+
Events::PhoneCall.by_person_id(5)
|
177
|
+
Events::PhoneCall.by_person_id(5).by_table_name('users').count
|
181
178
|
|
182
179
|
# event_uuid & created_at included for free :)
|
183
|
-
Events::
|
180
|
+
Events::PhoneCall.by_created_at('2015-01-04', 'GT')
|
184
181
|
```
|
185
182
|
|
186
183
|
The queries above return eventosaurus Query objects. To actually execute the query, use the `run` method:
|
187
184
|
|
188
185
|
```ruby
|
189
|
-
Events::
|
186
|
+
Events::PhoneCall.by_person_id(5).count.run
|
190
187
|
```
|
191
188
|
|
192
189
|
Note:
|
@@ -197,7 +194,7 @@ Note:
|
|
197
194
|
|
198
195
|
```
|
199
196
|
# too many secondary predicates. after one secondary index is used, the rest will be full scans on whatever comes back after the first local index.
|
200
|
-
Events::
|
197
|
+
Events::PhoneCall.by_created_at('2015-01-04', 'GT').by_table_name('users')
|
201
198
|
```
|
202
199
|
|
203
200
|
**To sum it up: for speed, you are allowed 0||1 partition key condition and 0||1 secondary condition. No more than that.**
|
data/lib/eventosaurus.rb
CHANGED
@@ -6,5 +6,6 @@ require 'eventosaurus/configuration'
|
|
6
6
|
require 'eventosaurus/storable'
|
7
7
|
require 'eventosaurus/query_builder'
|
8
8
|
require 'eventosaurus/services/table_manager_service'
|
9
|
+
require 'eventosaurus/lib/test_mode'
|
9
10
|
require 'eventosaurus/models/table.rb'
|
10
11
|
require 'eventosaurus/models/query.rb'
|
@@ -16,13 +16,11 @@ module Eventosaurus
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def enable_test_mode
|
19
|
-
|
20
|
-
|
21
|
-
end
|
19
|
+
store = TestMode.instance_method(:store)
|
20
|
+
run = TestMode.instance_method(:run)
|
22
21
|
|
23
|
-
|
24
|
-
|
25
|
-
end
|
22
|
+
Storable::ClassMethods.send(:define_method, :store, store)
|
23
|
+
Models::Query.send(:define_method, :run, run)
|
26
24
|
end
|
27
25
|
end
|
28
26
|
|
data/lib/eventosaurus/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eventosaurus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Blue Apron Engineering
|
@@ -175,6 +175,7 @@ files:
|
|
175
175
|
- eventosaurus.gemspec
|
176
176
|
- lib/eventosaurus.rb
|
177
177
|
- lib/eventosaurus/configuration.rb
|
178
|
+
- lib/eventosaurus/lib/test_mode.rb
|
178
179
|
- lib/eventosaurus/models/query.rb
|
179
180
|
- lib/eventosaurus/models/table.rb
|
180
181
|
- lib/eventosaurus/persistors/sidekiq.rb
|
@@ -211,4 +212,3 @@ signing_key:
|
|
211
212
|
specification_version: 4
|
212
213
|
summary: Enables easy reporting of events to an event store.
|
213
214
|
test_files: []
|
214
|
-
has_rdoc:
|