purview 1.1.0 → 1.1.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4075095b0198b4d1a9f104e39cef70a86f678038
4
- data.tar.gz: 8d87f15b33df6603d107edee2a5206f4579bca30
3
+ metadata.gz: 1369176b107aba11f52e4a8604fdfd440969f3e1
4
+ data.tar.gz: 989bbb48900af7fb712c9745b505727bd4963d53
5
5
  SHA512:
6
- metadata.gz: fe1283a266267325800140f453efe51da2be244c150a094d5d22c40d8b2e129b9a0192fdd004e44799377ec97625aa7c5621cdf24f0f6e4f46cef58ca216361d
7
- data.tar.gz: 5f5bd8092e10d1f3f34b39aceb15ab4b4ccf307b0e94dead6a801b1c964818069e7775d5af24251be61670307f27555ae0993fa54c3411142048326ad9fd0d1c
6
+ metadata.gz: 96aed3e255fe0a70bbaec213852a50da2ae7ddcf81ba9633a50d45ee6979cfdcfc1ffc614a5412c9b27964934d4b62bda405bb314f829acaa009133a4228964a
7
+ data.tar.gz: 2a8645de4002ef60ba092c796d0099ab0ed2851bc54261cf9e494cc41999f434002fe4a04ec904d3e34a1c4b6b718f305aa9e4a7aa51971272ed5e4d5cbf47f4
data/CHANGELOG CHANGED
@@ -1,3 +1,8 @@
1
+ Release 1.1.1
2
+ -------------
3
+
4
+ * Add `baseline_table` helper to `Database` class
5
+
1
6
  Release 1.1.0
2
7
  -------------
3
8
 
data/README.md CHANGED
@@ -128,6 +128,14 @@ as the high-water mark for records pulled from its source
128
128
  database.initialize_table(table, timestamp)
129
129
  ```
130
130
 
131
+ Baseline the `Table`. This process will quickly get the state of the `Table` as
132
+ close to the current state as possible. This is generally useful when adding a
133
+ new `Table` to an existing schema (ideally this should be done while the `Table`
134
+ is disabled)
135
+ ```ruby
136
+ database.baseline_table(table)
137
+ ```
138
+
131
139
  Enable the `Table` (in the DB). This process sets the `enabled_at` value in the
132
140
  `table_metadata` table and is used by the candidate `Table` selection algorithm
133
141
  to determine the pool of `Table(s)` available for synchronization (to remove a
@@ -8,6 +8,31 @@ module Purview
8
8
  @opts = opts
9
9
  end
10
10
 
11
+ def baseline_table(table)
12
+ with_context_logging('`baseline_table`') do
13
+ raise Purview::Exceptions::WrongDatabase.new(table) \
14
+ unless tables.include?(table)
15
+ starting_timestamp = Time.now.utc
16
+ with_table_locked(table, starting_timestamp) do
17
+ last_window = nil
18
+ begin
19
+ with_new_connection do |connection|
20
+ with_transaction(connection) do |transaction_timestamp|
21
+ with_next_window(
22
+ connection,
23
+ table,
24
+ transaction_timestamp
25
+ ) do |window|
26
+ table.sync(connection, window)
27
+ last_window = window
28
+ end
29
+ end
30
+ end
31
+ end while last_window.max < starting_timestamp
32
+ end
33
+ end
34
+ end
35
+
11
36
  def create_table(table, opts={})
12
37
  ensure_table_metadata_exists_for_table(table)
13
38
  table_opts = extract_table_options(opts)
@@ -134,14 +159,14 @@ module Purview
134
159
  def sync
135
160
  with_context_logging('`sync`') do
136
161
  with_new_connection do |connection|
137
- with_transaction(connection) do |timestamp|
138
- with_next_table(connection, timestamp) do |table|
162
+ with_transaction(connection) do |transaction_timestamp|
163
+ with_next_table(connection, transaction_timestamp) do |table|
139
164
  with_next_window(
140
165
  connection,
141
166
  table,
142
- timestamp
167
+ transaction_timestamp
143
168
  ) do |window|
144
- with_table_locked(table, timestamp) do
169
+ with_table_locked(table, transaction_timestamp) do
145
170
  table.sync(connection, window)
146
171
  end
147
172
  end
@@ -0,0 +1,9 @@
1
+ module Purview
2
+ module Exceptions
3
+ class WrongDatabase < BaseTable
4
+ def message
5
+ "Wrong database for table: #{table.name}"
6
+ end
7
+ end
8
+ end
9
+ end
@@ -11,3 +11,4 @@ require 'purview/exceptions/database_already_assigned'
11
11
  require 'purview/exceptions/no_table'
12
12
  require 'purview/exceptions/no_window'
13
13
  require 'purview/exceptions/rows_outside_window'
14
+ require 'purview/exceptions/wrong_database'
@@ -1,3 +1,3 @@
1
1
  module Purview
2
- VERSION = '1.1.0'
2
+ VERSION = '1.1.1'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: purview
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan W. Zaleski
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-01 00:00:00.000000000 Z
11
+ date: 2015-06-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -121,6 +121,7 @@ files:
121
121
  - lib/purview/exceptions/no_table.rb
122
122
  - lib/purview/exceptions/no_window.rb
123
123
  - lib/purview/exceptions/rows_outside_window.rb
124
+ - lib/purview/exceptions/wrong_database.rb
124
125
  - lib/purview/loaders.rb
125
126
  - lib/purview/loaders/base.rb
126
127
  - lib/purview/loaders/mysql.rb