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 +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +12 -8
- data/lib/pgdice/version.rb +1 -1
- data/lib/pgdice.rb +6 -0
- metadata +1 -1
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: fba36c27ddb14e741a76b835c50b0174e01aaaa5dda17eec6bb2932320c34908
         | 
| 4 | 
            +
              data.tar.gz: 02a619304426969341ede31c4882b4deac9b21380b362900fad4a03d9a368ed2
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 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 | 
| 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. | 
| 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. | 
| 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. | 
| 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. | 
| 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. | 
| 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. | 
| 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. | 
| 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.
         | 
    
        data/lib/pgdice/version.rb
    CHANGED
    
    
    
        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 |  |