Skip to content

Commit

Permalink
Merge pull request #17 from IlluminusLimited/move_up_methods
Browse files Browse the repository at this point in the history
Move up methods
  • Loading branch information
scytherswings authored Nov 21, 2018
2 parents 7b581ca + 73c322e commit 1d159cc
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [v0.3.0] : 2018-10-21
### Changes
- Delegate methods from the management classes onto the `PgDice` module itself.
- This means the api for this project is significantly more simple to use.

## [v0.2.1] : 2018-10-21
### Changes
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ For more information on what's going on in the background see


```ruby
PgDice.partition_helper.partition_table('comments')
PgDice.partition_table('comments')
```


Expand All @@ -164,7 +164,7 @@ PgDice.partition_helper.partition_table('comments')
If you mess up, again you shouldn't use this in production, you can call:

```ruby
PgDice.partition_helper.undo_partitioning!('comments')
PgDice.undo_partitioning!('comments')
```

This method will revert the changes made by partitioning a table. Don't rely on this
Expand All @@ -178,7 +178,7 @@ in production if you mess up; you need to test everything thoroughly.
If you have existing tables that need to periodically have more tables added you can run:

```ruby
PgDice.partition_manager.add_new_partitions('comments')
PgDice.add_new_partitions('comments')
```

#### Notes on `add_new_partitions`
Expand All @@ -194,12 +194,12 @@ Sometimes you just want to know what's out there and if there are tables ready t

To list all eligible tables for dropping you can run:
```ruby
PgDice.partition_manager.list_droppable_partitions('comments')
PgDice.list_droppable_partitions('comments')
```

If you want to know _exactly_ which partitions will be dropped you can call:
```ruby
PgDice.partition_manager.list_droppable_partitions_by_batch_size('comments')
PgDice.list_droppable_partitions_by_batch_size('comments')
```

This method will show partitions that are within the configured `batch_size`.
Expand All @@ -217,7 +217,7 @@ _Dropping tables is irreversible! Do this at your own risk!!_
If you want to drop old tables (after backing them up of course) you can run:

```ruby
PgDice.partition_manager.drop_old_partitions(table_name: 'comments')
PgDice.drop_old_partitions(table_name: 'comments')
```

#### Notes on `drop_old_partitions`
Expand All @@ -235,7 +235,7 @@ ensure they are actually working correctly.

To validate that your expected number of tables exist, you can run:
```ruby
PgDice.validation.assert_tables('comments')
PgDice.assert_tables('comments')
```

An [InsufficientTablesError](lib/pgdice.rb) will be raised if any conditions are not met.
Expand Down
6 changes: 6 additions & 0 deletions lib/pgdice.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ module PgDice
SUPPORTED_PERIODS = { 'day' => 'YYYYMMDD', 'month' => 'YYYYMM', 'year' => 'YYYY' }.freeze

class << self
extend Forwardable
def_delegators :partition_manager, :add_new_partitions, :drop_old_partitions, :list_partitions,
:list_droppable_partitions, :list_droppable_partitions_by_batch_size
def_delegators :partition_helper, :partition_table, :undo_partitioning, :undo_partitioning!
def_delegators :validation, :assert_tables

def partition_manager
raise PgDice::NotConfiguredError, 'partition_manager' unless configuration

Expand Down
2 changes: 1 addition & 1 deletion lib/pgdice/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module PgDice
VERSION = '0.2.1'
VERSION = '0.3.0'
end

0 comments on commit 1d159cc

Please sign in to comment.