pgdice 0.2.1 → 0.3.0

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
  SHA256:
3
- metadata.gz: f3fb2d5818d5b0042ad5509989c68728bc4cf308a6776d2e4e86f098e54f0eca
4
- data.tar.gz: 878e00f3882170077962bbd486164f529ffe03cfb3a90a3c82fbb93ad4f91062
3
+ metadata.gz: fba36c27ddb14e741a76b835c50b0174e01aaaa5dda17eec6bb2932320c34908
4
+ data.tar.gz: 02a619304426969341ede31c4882b4deac9b21380b362900fad4a03d9a368ed2
5
5
  SHA512:
6
- metadata.gz: 391d851ca34559bae050ce7a3e4ea5d980fa85c215438252c08842af2d409535170e14951538d665168851260cf182a2705901682b5adad9b9b30928d054e49d
7
- data.tar.gz: bab98688c55400ff18ea5f94a0fc29ad94752c13fa5fcf410a058c71c4c82bcb588df0ccf97f1bc1447e9e59f4d9877ffff00ef2aea67c016a66a2fa8995979a
6
+ metadata.gz: 9667cfbb816a7bb7b5f962b646fdab43fdd6fbcc2c5e8017e8523ce160819bfd4b88b45a444a8654bf627eb282c5d139e515dddfd64efa926204ac103bc80c57
7
+ data.tar.gz: 2965757a70d340024a67971ec6a9dd5ca0218454d6dab363876a1ef7ea9493cf5681f478bd95ae8b294349cb75b40c1e43266ce714b731813b74b2ad146e5471
data/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
  All notable changes to this project will be documented in this file.
3
3
  This project adheres to [Semantic Versioning](http://semver.org/).
4
4
 
5
+ ## [v0.3.0] : 2018-10-21
6
+ ### Changes
7
+ - Delegate methods from the management classes onto the `PgDice` module itself.
8
+ - This means the api for this project is significantly more simple to use.
5
9
 
6
10
  ## [v0.2.1] : 2018-10-21
7
11
  ### Changes
data/README.md CHANGED
@@ -54,6 +54,9 @@ require 'pgdice'
54
54
  PgDice.configure do |config|
55
55
  # This defaults to STDOUT if you don't specify a logger
56
56
  config.logger_factory = proc { Sidekiq.logger }
57
+
58
+ # database_url *must be set*
59
+ # Rails users: see FAQ for method on how to generate this from your Rails config.
57
60
  config.database_url = ENV['PGDICE_DATABASE_URL'] # postgresql://[user[:password]@][host][:port][/dbname][?param1=value1&...]
58
61
 
59
62
  # Set a config file or build the tables manually
@@ -69,8 +72,9 @@ end
69
72
 
70
73
  ### Configuration Parameters
71
74
 
72
- - `database_url` - Required: The postgres database url to connect to.
75
+ - `database_url` - **Required**: The postgres database url to connect to.
73
76
  - This is required since `pgslice` requires a postgres `url`.
77
+ - `PgDice` will throw an error if this value is not a valid postgres url.
74
78
 
75
79
  - `logger_factory` - Optional: A factory that will return a logger to use.
76
80
  - Defaults to `proc { Logger.new(STDOUT) }`
@@ -146,7 +150,7 @@ For more information on what's going on in the background see
146
150
 
147
151
 
148
152
  ```ruby
149
- PgDice.partition_helper.partition_table('comments')
153
+ PgDice.partition_table('comments')
150
154
  ```
151
155
 
152
156
 
@@ -160,7 +164,7 @@ PgDice.partition_helper.partition_table('comments')
160
164
  If you mess up, again you shouldn't use this in production, you can call:
161
165
 
162
166
  ```ruby
163
- PgDice.partition_helper.undo_partitioning!('comments')
167
+ PgDice.undo_partitioning!('comments')
164
168
  ```
165
169
 
166
170
  This method will revert the changes made by partitioning a table. Don't rely on this
@@ -174,7 +178,7 @@ in production if you mess up; you need to test everything thoroughly.
174
178
  If you have existing tables that need to periodically have more tables added you can run:
175
179
 
176
180
  ```ruby
177
- PgDice.partition_manager.add_new_partitions('comments')
181
+ PgDice.add_new_partitions('comments')
178
182
  ```
179
183
 
180
184
  #### Notes on `add_new_partitions`
@@ -190,12 +194,12 @@ Sometimes you just want to know what's out there and if there are tables ready t
190
194
 
191
195
  To list all eligible tables for dropping you can run:
192
196
  ```ruby
193
- PgDice.partition_manager.list_droppable_partitions('comments')
197
+ PgDice.list_droppable_partitions('comments')
194
198
  ```
195
199
 
196
200
  If you want to know _exactly_ which partitions will be dropped you can call:
197
201
  ```ruby
198
- PgDice.partition_manager.list_droppable_partitions_by_batch_size('comments')
202
+ PgDice.list_droppable_partitions_by_batch_size('comments')
199
203
  ```
200
204
 
201
205
  This method will show partitions that are within the configured `batch_size`.
@@ -213,7 +217,7 @@ _Dropping tables is irreversible! Do this at your own risk!!_
213
217
  If you want to drop old tables (after backing them up of course) you can run:
214
218
 
215
219
  ```ruby
216
- PgDice.partition_manager.drop_old_partitions(table_name: 'comments')
220
+ PgDice.drop_old_partitions(table_name: 'comments')
217
221
  ```
218
222
 
219
223
  #### Notes on `drop_old_partitions`
@@ -231,7 +235,7 @@ ensure they are actually working correctly.
231
235
 
232
236
  To validate that your expected number of tables exist, you can run:
233
237
  ```ruby
234
- PgDice.validation.assert_tables('comments')
238
+ PgDice.assert_tables('comments')
235
239
  ```
236
240
 
237
241
  An [InsufficientTablesError](lib/pgdice.rb) will be raised if any conditions are not met.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PgDice
4
- VERSION = '0.2.1'
4
+ VERSION = '0.3.0'
5
5
  end
data/lib/pgdice.rb CHANGED
@@ -50,6 +50,12 @@ module PgDice
50
50
  SUPPORTED_PERIODS = { 'day' => 'YYYYMMDD', 'month' => 'YYYYMM', 'year' => 'YYYY' }.freeze
51
51
 
52
52
  class << self
53
+ extend Forwardable
54
+ def_delegators :partition_manager, :add_new_partitions, :drop_old_partitions, :list_partitions,
55
+ :list_droppable_partitions, :list_droppable_partitions_by_batch_size
56
+ def_delegators :partition_helper, :partition_table, :undo_partitioning, :undo_partitioning!
57
+ def_delegators :validation, :assert_tables
58
+
53
59
  def partition_manager
54
60
  raise PgDice::NotConfiguredError, 'partition_manager' unless configuration
55
61
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pgdice
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Newell