phobos_db_checkpoint 3.1.0 → 3.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +2 -2
- data/lib/phobos_db_checkpoint.rb +25 -5
- data/lib/phobos_db_checkpoint/cli.rb +1 -1
- data/lib/phobos_db_checkpoint/middleware/database.rb +2 -3
- data/lib/phobos_db_checkpoint/tasks.rb +1 -1
- data/lib/phobos_db_checkpoint/version.rb +1 -1
- data/templates/config.ru +1 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fb0abf033362b2d16951eea469a851873acbc863
|
4
|
+
data.tar.gz: 6f92192149a9ee9cbf82895c6f13329b4a87b032
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 54b57b7d287df8fa95916abde5284658c2831588db59863166e8b54061067bde199e6338c251387f72434c1535924038db0a14739523904c3d2878112dc7069d
|
7
|
+
data.tar.gz: 4ec9fda62d8e9e2d74f7ef4db0b94c7e7d983797484d1cafd30911384bae9b1a9c9baa41de76cbe04e2704b1da1c38d201caca61e567e47684d6e765ce959f2f
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
|
|
4
4
|
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
5
5
|
and this project adheres to [Semantic Versioning](http://semver.org/).
|
6
6
|
|
7
|
+
## 3.2.0 (2017-10-23)
|
8
|
+
|
9
|
+
- [enhancement] Make pool_size only configurable through configuration files
|
10
|
+
|
7
11
|
## 3.1.0 (2017-06-19)
|
8
12
|
|
9
13
|
- [enhancement] Add support for erb syntax in database config file
|
data/README.md
CHANGED
@@ -63,8 +63,8 @@ After this, your app should have access to all db tasks.
|
|
63
63
|
|
64
64
|
```sh
|
65
65
|
$ rake -T
|
66
|
-
rake db:create # Creates the database from DATABASE_URL or config/database.yml for the current
|
67
|
-
rake db:drop # Drops the database from DATABASE_URL or config/database.yml for the current
|
66
|
+
rake db:create # Creates the database from DATABASE_URL or config/database.yml for the current RACK_ENV (use db:create:all to create all ...
|
67
|
+
rake db:drop # Drops the database from DATABASE_URL or config/database.yml for the current RACK_ENV (use db:drop:all to drop all databa...
|
68
68
|
rake db:environment:set # Set the environment value for the database
|
69
69
|
rake db:fixtures:load # Loads fixtures into the current environment's database
|
70
70
|
rake db:migrate # Migrate the database (options: VERSION=x, VERBOSE=false, SCOPE=blog)
|
data/lib/phobos_db_checkpoint.rb
CHANGED
@@ -28,28 +28,39 @@ module PhobosDBCheckpoint
|
|
28
28
|
:phobos_db_checkpoint_
|
29
29
|
end
|
30
30
|
|
31
|
-
def configure(
|
32
|
-
|
31
|
+
def configure(options = {})
|
32
|
+
deprecate('options are deprecated, use configuration files instead') if options.keys.any?
|
33
|
+
|
34
|
+
load_db_config
|
33
35
|
at_exit { PhobosDBCheckpoint.close_db_connection }
|
34
|
-
|
36
|
+
PhobosDBCheckpoint.establish_db_connection
|
35
37
|
end
|
36
38
|
|
37
39
|
def env
|
38
40
|
ENV['RAILS_ENV'] ||= ENV['RACK_ENV'] ||= 'development'
|
39
41
|
end
|
40
42
|
|
41
|
-
def load_db_config(
|
43
|
+
def load_db_config(options = {})
|
44
|
+
deprecate('options are deprecated, use configuration files instead') if options.keys.any?
|
45
|
+
|
42
46
|
@db_config_path ||= ENV['DB_CONFIG'] || DEFAULT_DB_CONFIG_PATH
|
47
|
+
|
43
48
|
configs = YAML.load(ERB.new(File.read(File.expand_path(@db_config_path))).result)
|
44
49
|
@db_config = configs[env]
|
45
50
|
|
51
|
+
pool_size = @db_config['pool']
|
52
|
+
|
46
53
|
if pool_size.nil? && Phobos.config
|
47
|
-
pool_size =
|
54
|
+
pool_size = number_of_concurrent_listeners + DEFAULT_POOL_SIZE
|
48
55
|
end
|
49
56
|
|
50
57
|
@db_config.merge!('pool' => pool_size || DEFAULT_POOL_SIZE)
|
51
58
|
end
|
52
59
|
|
60
|
+
def establish_db_connection
|
61
|
+
ActiveRecord::Base.establish_connection(db_config)
|
62
|
+
end
|
63
|
+
|
53
64
|
def close_db_connection
|
54
65
|
ActiveRecord::Base.connection_pool.disconnect!
|
55
66
|
rescue ActiveRecord::ConnectionNotEstablished
|
@@ -58,10 +69,19 @@ module PhobosDBCheckpoint
|
|
58
69
|
def load_tasks
|
59
70
|
@db_dir ||= DEFAULT_DB_DIR
|
60
71
|
@migration_path ||= DEFAULT_MIGRATION_PATH
|
72
|
+
|
61
73
|
ActiveRecord::Tasks::DatabaseTasks.send(:define_method, :db_dir) { PhobosDBCheckpoint.db_dir }
|
62
74
|
ActiveRecord::Tasks::DatabaseTasks.send(:define_method, :migrations_paths) { [PhobosDBCheckpoint.migration_path] }
|
63
75
|
ActiveRecord::Tasks::DatabaseTasks.send(:define_method, :env) { PhobosDBCheckpoint.env }
|
64
76
|
require 'phobos_db_checkpoint/tasks'
|
65
77
|
end
|
78
|
+
|
79
|
+
def number_of_concurrent_listeners
|
80
|
+
Phobos.config.listeners.map { |listener| listener.max_concurrency || 1 }.inject(&:+) || 0
|
81
|
+
end
|
82
|
+
|
83
|
+
def deprecate(message)
|
84
|
+
warn "DEPRECATION WARNING: #{message} #{Kernel.caller.first}"
|
85
|
+
end
|
66
86
|
end
|
67
87
|
end
|
@@ -1,11 +1,10 @@
|
|
1
1
|
module PhobosDBCheckpoint
|
2
2
|
module Middleware
|
3
3
|
class Database
|
4
|
-
|
5
4
|
def initialize(app, options = {})
|
6
5
|
@app = app
|
7
|
-
|
8
|
-
PhobosDBCheckpoint.configure
|
6
|
+
PhobosDBCheckpoint.deprecate('options are deprecated, use configuration files instead') if options.keys.any?
|
7
|
+
PhobosDBCheckpoint.configure
|
9
8
|
end
|
10
9
|
|
11
10
|
def call(request_env)
|
@@ -11,7 +11,7 @@ module PhobosDBCheckpoint
|
|
11
11
|
|
12
12
|
task :load_config do
|
13
13
|
PhobosDBCheckpoint.load_db_config
|
14
|
-
task_db_config = Hash[PhobosDBCheckpoint.env, PhobosDBCheckpoint.db_config
|
14
|
+
task_db_config = Hash[PhobosDBCheckpoint.env, PhobosDBCheckpoint.db_config]
|
15
15
|
ActiveRecord::Tasks::DatabaseTasks.database_configuration = task_db_config
|
16
16
|
end
|
17
17
|
end
|
data/templates/config.ru
CHANGED
@@ -8,10 +8,6 @@ logger_config = {
|
|
8
8
|
# log_file: 'log/api.log'
|
9
9
|
}
|
10
10
|
|
11
|
-
database_config = {
|
12
|
-
# pool_size: PhobosDBCheckpoint::DEFAULT_POOL_SIZE # 5
|
13
|
-
}
|
14
|
-
|
15
11
|
use PhobosDBCheckpoint::Middleware::Logger, logger_config
|
16
|
-
use PhobosDBCheckpoint::Middleware::Database
|
12
|
+
use PhobosDBCheckpoint::Middleware::Database
|
17
13
|
run PhobosDBCheckpoint::EventsAPI
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: phobos_db_checkpoint
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Túlio Ornelas
|
@@ -13,7 +13,7 @@ authors:
|
|
13
13
|
autorequire:
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
|
-
date: 2017-
|
16
|
+
date: 2017-10-24 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: bundler
|