alephant-lookup 0.4.2 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aff72c4a54e98f1083023e67503f88a7290f0bdb
|
4
|
+
data.tar.gz: 4570723dbdbd206854ed2d992c82405a8036aaa7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b912276212e95c51a3b7bddf8d99c1234b8f2df34555625dc7329905b1188c69bb52a120fa9ef851d9f1edc3ce8b366aaede38507c637139eacf05e3a341511e
|
7
|
+
data.tar.gz: 42ef112c847bb894400f06684b549b6490498e1be173550d20b745361f907a6ef3a4061a8e62fdc61dd816eee4eb14ae0511bd1998e8177cc05e0380120ca5ed
|
@@ -11,26 +11,44 @@ module Alephant
|
|
11
11
|
attr_reader :lookup_table
|
12
12
|
|
13
13
|
def initialize(lookup_table)
|
14
|
-
logger.info "LookupHelper#initialize(#{lookup_table.table_name})"
|
15
|
-
|
16
14
|
@lookup_table = lookup_table
|
15
|
+
|
16
|
+
logger.info(
|
17
|
+
"event" => "LookupHelperInitialized",
|
18
|
+
"tableName" => lookup_table.table_name,
|
19
|
+
"method" => "#{self.class}#initialize"
|
20
|
+
)
|
17
21
|
end
|
18
22
|
|
19
23
|
def read(id, opts, batch_version)
|
20
|
-
|
21
|
-
|
22
|
-
LookupQuery
|
24
|
+
LookupQuery.new(lookup_table.table_name, id, opts, batch_version).run!.tap do
|
25
|
+
logger.info(
|
26
|
+
"event" => "LookupQuery",
|
27
|
+
"tableName" => lookup_table.table_name,
|
28
|
+
"id" => id,
|
29
|
+
"opts" => opts,
|
30
|
+
"batchVersion" => batch_version,
|
31
|
+
"method" => "#{self.class}#read"
|
32
|
+
)
|
33
|
+
end
|
23
34
|
end
|
24
35
|
|
25
36
|
def write(id, opts, batch_version, location)
|
26
|
-
logger.info "LookupHelper#write(#{id}, #{opts}, #{batch_version}, #{location})"
|
27
|
-
|
28
37
|
LookupLocation.new(id, opts, batch_version, location).tap do |l|
|
29
38
|
lookup_table.write(
|
30
39
|
l.component_key,
|
31
40
|
l.batch_version,
|
32
41
|
l.location
|
33
|
-
)
|
42
|
+
).tap do
|
43
|
+
logger.info(
|
44
|
+
"event" => "LookupLocationUpdated",
|
45
|
+
"location" => location,
|
46
|
+
"id" => id,
|
47
|
+
"opts" => opts,
|
48
|
+
"batchVersion" => batch_version,
|
49
|
+
"method" => "#{self.class}#write"
|
50
|
+
)
|
51
|
+
end
|
34
52
|
end
|
35
53
|
end
|
36
54
|
|
@@ -9,17 +9,31 @@ module Alephant
|
|
9
9
|
attr_reader :table_name, :lookup_location
|
10
10
|
|
11
11
|
def initialize(table_name, component_id, opts, batch_version)
|
12
|
-
@client
|
13
|
-
@table_name
|
12
|
+
@client = AWS::DynamoDB::Client::V20120810.new
|
13
|
+
@table_name = table_name
|
14
14
|
@lookup_location = LookupLocation.new(component_id, opts, batch_version)
|
15
|
-
|
15
|
+
|
16
|
+
logger.info(
|
17
|
+
"event" => "LookupQueryInitialized",
|
18
|
+
"tableName" => table_name,
|
19
|
+
"componentId" => component_id,
|
20
|
+
"location" => lookup_location,
|
21
|
+
"batchVersion" => batch_version,
|
22
|
+
"method" => "#{self.class}#initialize"
|
23
|
+
)
|
16
24
|
end
|
17
25
|
|
18
26
|
def run!
|
19
27
|
lookup_location.tap do |l|
|
20
28
|
l.location = s3_location_from(
|
21
29
|
@client.query(to_q)
|
22
|
-
).tap
|
30
|
+
).tap do |loc|
|
31
|
+
logger.info(
|
32
|
+
"event" => "S3LocationRetrieved",
|
33
|
+
"location" => loc,
|
34
|
+
"method" => "#{self.class}#run!"
|
35
|
+
)
|
36
|
+
end
|
23
37
|
end
|
24
38
|
end
|
25
39
|
|
@@ -15,12 +15,14 @@ module Alephant
|
|
15
15
|
@mutex = Mutex.new
|
16
16
|
@client = AWS::DynamoDB::Client::V20120810.new
|
17
17
|
@table_name = table_name
|
18
|
-
logger.info
|
18
|
+
logger.info(
|
19
|
+
"event" => "LookupTableInitialized",
|
20
|
+
"tableName" => table_name,
|
21
|
+
"method" => "#{self.class}#initialize"
|
22
|
+
)
|
19
23
|
end
|
20
24
|
|
21
25
|
def write(component_key, version, location)
|
22
|
-
logger.info "LookupTable#write: component key '#{component_key}', version '#{version}', location '#{location}'"
|
23
|
-
|
24
26
|
client.put_item({
|
25
27
|
:table_name => table_name,
|
26
28
|
:item => {
|
@@ -34,7 +36,15 @@ module Alephant
|
|
34
36
|
'S' => location.to_s
|
35
37
|
}
|
36
38
|
}
|
37
|
-
})
|
39
|
+
}).tap do
|
40
|
+
logger.info(
|
41
|
+
"event" => "LookupLocationWritten",
|
42
|
+
"componentKey" => component_key,
|
43
|
+
"version" => version,
|
44
|
+
"location" => location,
|
45
|
+
"method" => "#{self.class}#write"
|
46
|
+
)
|
47
|
+
end
|
38
48
|
end
|
39
49
|
|
40
50
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: alephant-lookup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- BBC News
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-07-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|