db_blaster 0.1.3 → 0.1.4
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/app/jobs/db_blaster/publish_all_job.rb +1 -1
- data/lib/db_blaster/configuration.rb +9 -2
- data/lib/db_blaster/s3_key_builder.rb +4 -1
- data/lib/db_blaster/s3_publisher.rb +11 -1
- data/lib/db_blaster/version.rb +1 -1
- data/lib/generators/db_blaster/install/templates/db_blaster_config.rb +4 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9313d3abe0bd4dcaa756dab6b07b1d65eb6438b435c914d18f9d38964f08a29d
|
4
|
+
data.tar.gz: c694940facb41fb3656d011baba720ffb5f66cf124472f945d7de45661ba90b5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c045adce6f5a4fb70be59194f6f4630879761011be805dbed09c9be225a415a807ffe60a2b33ccf5361e49ce595b87250f8b0e67f370c29d867254928a36e41f
|
7
|
+
data.tar.gz: 4b509898ced3205b588248700a75a375ddc6c614611298f0af347ef1a45b35f4c3d1adc9ae0a70d357c56050f47a7225d454564c22a350a21cec45da0effe322
|
@@ -6,7 +6,8 @@ module DbBlaster
|
|
6
6
|
class Configuration
|
7
7
|
DEFAULT_BATCH_SIZE = 100
|
8
8
|
DEFAULT_MAX_MESSAGE_SIZE_IN_KILOBYTES = 256 # max size allowed by AWS SNS
|
9
|
-
DEFAULT_S3_KEY = '<
|
9
|
+
DEFAULT_S3_KEY = '<batch_date>/<batch_time>/db_blaster/<table_name>/<uuid>.json'
|
10
|
+
DEFAULT_DATETIME_FORMAT = '%Y-%m-%dT%H:%M:%S.%LZ'
|
10
11
|
|
11
12
|
# The required configuration fields
|
12
13
|
REQUIRED_FIELDS = %i[aws_access_key aws_access_secret aws_region].freeze
|
@@ -30,7 +31,7 @@ module DbBlaster
|
|
30
31
|
# Optional
|
31
32
|
# Applicable only when `s3_bucket' is set
|
32
33
|
# The value set here will be included in every payload pushed to S3
|
33
|
-
# example: config.s3_meta = {'infra_id' => '061', '
|
34
|
+
# example: config.s3_meta = {'infra_id' => '061', 'source_app' => 'kcp-api'}}
|
34
35
|
# The resulting JSON:
|
35
36
|
# {"meta" : {"infra_id" : "061", "src_app" : "kcp-api", "src_table" : "the-table"}, "records" : [] }
|
36
37
|
attr_accessor :s3_meta
|
@@ -45,6 +46,12 @@ module DbBlaster
|
|
45
46
|
# '<batch_timestamp>/kcp-api/001/<table_name>/<uuid>.json'
|
46
47
|
attr_accessor :s3_key
|
47
48
|
|
49
|
+
# Optional
|
50
|
+
# Applicable only when `s3_bucket` is set
|
51
|
+
# S3 Tags
|
52
|
+
# example: config.s3_tags = { infra_id: '001', source_app: 'kcp-api', source_table: 'meetings' }
|
53
|
+
attr_accessor :s3_tags
|
54
|
+
|
48
55
|
# Global list of column names not to include in published SNS messages
|
49
56
|
# example: config.ignored_column_names = ['email', 'phone_number']
|
50
57
|
attr_accessor :ignored_column_names
|
@@ -23,7 +23,10 @@ module DbBlaster
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def substitutions
|
26
|
-
|
26
|
+
date, time = batch_start_time.split('T')
|
27
|
+
{ '<batch_date_time>' => batch_start_time,
|
28
|
+
'<batch_date>' => date,
|
29
|
+
'<batch_time>' => time,
|
27
30
|
'<uuid>' => SecureRandom.uuid,
|
28
31
|
'<table_name>' => source_table_name }
|
29
32
|
end
|
@@ -9,6 +9,7 @@ module DbBlaster
|
|
9
9
|
client.put_object(bucket: DbBlaster.configuration.s3_bucket,
|
10
10
|
key: S3KeyBuilder.build(source_table_name: source_table.name,
|
11
11
|
batch_start_time: batch_start_time),
|
12
|
+
tagging: tagging,
|
12
13
|
body: content.to_json)
|
13
14
|
end
|
14
15
|
|
@@ -17,8 +18,17 @@ module DbBlaster
|
|
17
18
|
records: records }
|
18
19
|
end
|
19
20
|
|
21
|
+
def tagging
|
22
|
+
URI.encode_www_form(tags_hash)
|
23
|
+
end
|
24
|
+
|
25
|
+
def tags_hash
|
26
|
+
@tags_hash ||= { source_table: source_table.name }
|
27
|
+
.merge(DbBlaster.configuration.s3_tags.presence || {})
|
28
|
+
end
|
29
|
+
|
20
30
|
def meta
|
21
|
-
(DbBlaster.configuration.s3_meta || {}).merge(source_table: source_table.name)
|
31
|
+
(DbBlaster.configuration.s3_meta.presence || {}).merge(source_table: source_table.name)
|
22
32
|
end
|
23
33
|
|
24
34
|
def client
|
data/lib/db_blaster/version.rb
CHANGED
@@ -20,7 +20,9 @@ DbBlaster.configure do |config|
|
|
20
20
|
# Optional
|
21
21
|
# Applicable only when `s3_bucket` is set
|
22
22
|
# The S3 key path. The following values will get substituted:
|
23
|
-
# <
|
23
|
+
# <batch_date_time> - a timestamp signifying the beginning of the batch processing
|
24
|
+
# <batch_date> - a date signifying the beginning of the batch processing
|
25
|
+
# <batch_time> - a time signifying the beginning of the batch processing
|
24
26
|
# <timestamp> - the current time
|
25
27
|
# <table_name> - the name of the table associated with the S3 body
|
26
28
|
# <uuid> - a universal identifier
|
@@ -31,7 +33,7 @@ DbBlaster.configure do |config|
|
|
31
33
|
# Extra meta values sent along with each payload
|
32
34
|
# example: config.s3_meta = {'infra_id' => '061'}
|
33
35
|
# The resulting JSON:
|
34
|
-
# {"meta" : {"infra_id" : "061", "
|
36
|
+
# {"meta" : {"infra_id" : "061", "source_app" : "kcp-api", "src_table" : "the-table"}, "records" : [] }
|
35
37
|
# config.s3_meta = {'infra_id' => '061'}
|
36
38
|
|
37
39
|
# Optional
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: db_blaster
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Perry Hertler
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-09-
|
11
|
+
date: 2021-09-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk-s3
|