ebisu_connection 0.3.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 329f392b0c96e684f68b181ee65c8f17941e0537
4
- data.tar.gz: d0f4b510081d702887b1253d6b240783e176b4b3
3
+ metadata.gz: 6ca70a47990e4d8b4785fd2d744777cce70ca488
4
+ data.tar.gz: deb891cf866a57e0fa9945215737bbe73774469e
5
5
  SHA512:
6
- metadata.gz: a026f2a2e172f868d1cdc7a4be0269ae87cdfa204daef131f5e3d7755c39409b12b2485cdefdf33eb0a190799252fa0bae56f39eebcecd833dbc020e797d5d18
7
- data.tar.gz: cd289b7235f65d828fd22e9867f916cb2aaa4a346d13694da9d0ff22ad17b2309ec4adf8890bdfa64f038ae50d66974e7308542de0c98dfd11eab8db9691e37a
6
+ metadata.gz: 073399cd8859740d5a14c69b4932f4615438841012adae7f4bd95f909c7f62754dca313e9ccd958d3863c6932b16cf5142adfb7a75a0d95ebfb27aeddd0fe425
7
+ data.tar.gz: 8656575ecfac9e40ef0b9b56a5ae34f836e174467c84524ae5e617b48fab1cf200308a72bb8de5573f6a76a2a45920852ec401904daf10b163467250afca86b7
data/.travis.yml CHANGED
@@ -1,13 +1,17 @@
1
1
  language: ruby
2
+ before_install:
3
+ - gem install bundler
2
4
  before_script:
3
5
  - mysql -e 'create database ebisu_connection_test;'
4
6
  - mysql -e 'create database ebisu_connection_test_master;'
5
7
  - mysql -e 'create database ebisu_connection_test_slave;'
6
- - "bundle exec ruby spec/prepare.rb"
8
+ - bundle update
9
+ cache: bundler
7
10
  rvm:
8
11
  - 2.0.0
9
- - 2.1
10
- - 2.2
12
+ - 2.1.8
13
+ - 2.2.4
14
+ - 2.3.0
11
15
  - ruby-head
12
16
  gemfile:
13
17
  - gemfiles/rails3.gemfile
@@ -0,0 +1,49 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, and in the interest of
4
+ fostering an open and welcoming community, we pledge to respect all people who
5
+ contribute through reporting issues, posting feature requests, updating
6
+ documentation, submitting pull requests or patches, and other activities.
7
+
8
+ We are committed to making participation in this project a harassment-free
9
+ experience for everyone, regardless of level of experience, gender, gender
10
+ identity and expression, sexual orientation, disability, personal appearance,
11
+ body size, race, ethnicity, age, religion, or nationality.
12
+
13
+ Examples of unacceptable behavior by participants include:
14
+
15
+ * The use of sexualized language or imagery
16
+ * Personal attacks
17
+ * Trolling or insulting/derogatory comments
18
+ * Public or private harassment
19
+ * Publishing other's private information, such as physical or electronic
20
+ addresses, without explicit permission
21
+ * Other unethical or unprofessional conduct
22
+
23
+ Project maintainers have the right and responsibility to remove, edit, or
24
+ reject comments, commits, code, wiki edits, issues, and other contributions
25
+ that are not aligned to this Code of Conduct, or to ban temporarily or
26
+ permanently any contributor for other behaviors that they deem inappropriate,
27
+ threatening, offensive, or harmful.
28
+
29
+ By adopting this Code of Conduct, project maintainers commit themselves to
30
+ fairly and consistently applying these principles to every aspect of managing
31
+ this project. Project maintainers who do not follow or enforce the Code of
32
+ Conduct may be permanently removed from the project team.
33
+
34
+ This code of conduct applies both within project spaces and in public spaces
35
+ when an individual is representing the project or its community.
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
38
+ reported by contacting a project maintainer at tsukasa.oishi@gmail.com. All
39
+ complaints will be reviewed and investigated and will result in a response that
40
+ is deemed necessary and appropriate to the circumstances. Maintainers are
41
+ obligated to maintain confidentiality with regard to the reporter of an
42
+ incident.
43
+
44
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
45
+ version 1.3.0, available at
46
+ [http://contributor-covenant.org/version/1/3/0/][version]
47
+
48
+ [homepage]: http://contributor-covenant.org
49
+ [version]: http://contributor-covenant.org/version/1/3/0/
data/LICENSE.txt CHANGED
@@ -1,22 +1,21 @@
1
- Copyright (c) 2013 tsukasaoishi
1
+ The MIT License (MIT)
2
2
 
3
- MIT License
3
+ Copyright (c) 2016 Tsukasa OISHI
4
4
 
5
- Permission is hereby granted, free of charge, to any person obtaining
6
- a copy of this software and associated documentation files (the
7
- "Software"), to deal in the Software without restriction, including
8
- without limitation the rights to use, copy, modify, merge, publish,
9
- distribute, sublicense, and/or sell copies of the Software, and to
10
- permit persons to whom the Software is furnished to do so, subject to
11
- the following conditions:
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
12
11
 
13
- The above copyright notice and this permission notice shall be
14
- included in all copies or substantial portions of the Software.
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
15
14
 
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md CHANGED
@@ -10,118 +10,140 @@ EbisuConnection uses FreshConnection (https://github.com/tsukasaoishi/fresh_conn
10
10
 
11
11
  Add this line to your application's Gemfile:
12
12
 
13
- gem 'ebisu_connection'
13
+ ```ruby
14
+ gem 'ebisu_connection'
15
+ ```
14
16
 
15
17
  And then execute:
16
18
 
17
- $ bundle
19
+ ```
20
+ $ bundle
21
+ ```
18
22
 
19
23
  Or install it yourself as:
20
24
 
21
- $ gem install ebisu_connection
25
+ ```
26
+ $ gem install ebisu_connection
27
+ ```
22
28
 
23
29
  ## Config
24
30
 
25
31
  config/database.yml
26
32
 
27
- production:
28
- adapter: mysql2
29
- encoding: utf8
30
- reconnect: true
31
- database: kaeru
32
- pool: 5
33
- username: master
34
- password: master
35
- host: localhost
36
- socket: /var/run/mysqld/mysqld.sock
37
-
38
- slave:
39
- username: slave
40
- password: slave
41
- host: slave
33
+ ```yaml
34
+ production:
35
+ adapter: mysql2
36
+ encoding: utf8
37
+ reconnect: true
38
+ database: kaeru
39
+ pool: 5
40
+ username: master
41
+ password: master
42
+ host: localhost
43
+ socket: /var/run/mysqld/mysqld.sock
44
+
45
+ slave:
46
+ username: slave
47
+ password: slave
48
+ host: slave
49
+ ```
42
50
 
43
51
  ```slave``` is base config to connect to slave servers.
44
52
  Others will use the master setting. If you want to change, write in the slave.
45
53
 
46
54
  Config of each slave server fill out config/slave.yaml
47
55
 
48
- production:
49
- - "slave1, 10"
50
- - "slave2, 20"
51
- -
52
- host: "slave3"
53
- weight: 30
56
+ ```yaml
57
+ production:
58
+ - "slave1, 10"
59
+ - "slave2, 20"
60
+ -
61
+ host: "slave3"
62
+ weight: 30
63
+ ```
54
64
 
55
65
  config/slave.yaml is checked by end of action. If config changed, it's reflected dynamic. Application doesn't need restart.
56
66
 
57
- "hostname, weight"
67
+ ```yaml
68
+ "hostname, weight"
69
+ ```
58
70
 
59
71
  String format is it. You can write config with hash.
60
72
 
61
73
  ### use multiple slave servers group
62
74
  If you may want to user multiple slave group, write multiple slave group to config/database.yml.
63
75
 
64
- production:
65
- adapter: mysql2
66
- encoding: utf8
67
- reconnect: true
68
- database: kaeru
69
- pool: 5
70
- username: master
71
- password: master
72
- host: localhost
73
- socket: /var/run/mysqld/mysqld.sock
74
-
75
- slave:
76
- username: slave
77
- password: slave
78
- host: slave
79
-
80
- admin_slave:
81
- username: slave
82
- password: slave
83
- host: admin_slaves
76
+ ```yaml
77
+ production:
78
+ adapter: mysql2
79
+ encoding: utf8
80
+ reconnect: true
81
+ database: kaeru
82
+ pool: 5
83
+ username: master
84
+ password: master
85
+ host: localhost
86
+ socket: /var/run/mysqld/mysqld.sock
87
+
88
+ slave:
89
+ username: slave
90
+ password: slave
91
+ host: slave
92
+
93
+ admin_slave:
94
+ username: slave
95
+ password: slave
96
+ host: admin_slaves
97
+ ```
84
98
 
85
99
  Config of each slave server fill out config/slave.yaml
86
100
 
87
- production:
88
- slave:
89
- - "slave1, 10"
90
- - "slave2, 20"
91
- -
92
- host: "slave3"
93
- weight: 30
94
- admin_slave:
95
- - "slave3, 10"
96
- - "slave4, 20"
101
+ ```yaml
102
+ production:
103
+ slave:
104
+ - "slave1, 10"
105
+ - "slave2, 20"
106
+ -
107
+ host: "slave3"
108
+ weight: 30
109
+ admin_slave:
110
+ - "slave3, 10"
111
+ - "slave4, 20"
112
+ ```
97
113
 
98
114
 
99
115
  And call establish_fresh_connection method in model that access to ```admin_slave``` slave group.
100
116
 
101
- class AdminUser < ActiveRecord::Base
102
- establish_fresh_connection :admin_slave
103
- end
117
+ ```ruby
118
+ class AdminUser < ActiveRecord::Base
119
+ establish_fresh_connection :admin_slave
120
+ end
121
+ ```
104
122
 
105
123
  The children is access to same slave group of parent.
106
124
 
107
- class Parent < ActiveRecord::Base
108
- establish_fresh_connection :admin_slave
109
- end
125
+ ```ruby
126
+ class Parent < ActiveRecord::Base
127
+ establish_fresh_connection :admin_slave
128
+ end
110
129
 
111
- class AdminUser < Parent
112
- end
130
+ class AdminUser < Parent
131
+ end
113
132
 
114
- class Benefit < Parent
115
- end
133
+ class Benefit < Parent
134
+ end
135
+ ```
116
136
 
117
137
  AdminUser and Benefit access to ```admin_slave``` slave group.
118
138
 
119
139
 
120
140
  ### Declare model that doesn't use slave db
121
141
 
122
- class SomethingModel < ActiveRecord::Base
123
- master_db_only!
124
- end
142
+ ```ruby
143
+ class SomethingModel < ActiveRecord::Base
144
+ master_db_only!
145
+ end
146
+ ```
125
147
 
126
148
  If model that always access to master servers is exist, You may want to write ```master_db_only!``` in model.
127
149
  The model that master_db_only model's child is always access to master db.
@@ -130,8 +152,10 @@ The model that master_db_only model's child is always access to master db.
130
152
 
131
153
  Read query will be access to slave server.
132
154
 
133
- Article.where(:id => 1)
134
- Article.count
155
+ ```ruby
156
+ Article.where(:id => 1)
157
+ Article.count
158
+ ```
135
159
 
136
160
  If you want to access to the master server, use read_master.
137
161
 
@@ -143,9 +167,11 @@ It is possible to use readonly(false) instead of read_master, but it will be dep
143
167
 
144
168
  In transaction, Always will be access to master server.
145
169
 
146
- Article.transaction do
147
- Article.where(:id => 1)
148
- end
170
+ ```ruby
171
+ Article.transaction do
172
+ Article.where(:id => 1)
173
+ end
174
+ ```
149
175
 
150
176
 
151
177
  ### for Unicorn
@@ -180,13 +206,12 @@ How to setup your test environment.
180
206
 
181
207
  ```bash
182
208
  bundle install --path .bundle
183
- GEM_HOME=.bundle/ruby/(your ruby version) gem install bundler --pre
184
209
  bundle exec appraisal install
185
210
  ```
186
211
 
187
212
  This command run the spec suite for all rails versions supported.
188
213
 
189
214
  ```base
190
- bundle exec appraisal rake spec
215
+ bundle exec appraisal rake test
191
216
  ```
192
217
 
data/Rakefile CHANGED
@@ -1,6 +1,10 @@
1
1
  require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
2
+ require 'rake/testtask'
3
3
 
4
- RSpec::Core::RakeTask.new(:spec)
4
+ Rake::TestTask.new do |t|
5
+ t.libs.push "test"
6
+ t.test_files = FileList['test/**/*_test.rb']
7
+ t.verbose = true
8
+ end
5
9
 
6
- task :default => :spec
10
+ task :default => :test
@@ -20,10 +20,12 @@ Gem::Specification.new do |spec|
20
20
  spec.require_paths = ["lib"]
21
21
 
22
22
  spec.required_ruby_version = '>= 2.0'
23
- spec.add_dependency 'fresh_connection', '~> 0.4.0'
24
23
 
25
- spec.add_development_dependency "bundler", "~> 1.7"
26
- spec.add_development_dependency "rake", '~> 10.0'
27
- spec.add_development_dependency "rspec", '~> 3.0'
28
- spec.add_development_dependency 'appraisal', '~> 2.0'
24
+ spec.add_dependency 'fresh_connection', '~> 1.0.0'
25
+
26
+ spec.add_development_dependency "bundler", ">= 1.3.0", "< 2.0"
27
+ spec.add_development_dependency "rake", ">= 0.8.7"
28
+ spec.add_development_dependency 'appraisal'
29
+ spec.add_development_dependency "minitest"
30
+ spec.add_development_dependency "minitest-reporters"
29
31
  end
@@ -1,3 +1,3 @@
1
1
  module EbisuConnection
2
- VERSION = "0.3.1"
2
+ VERSION = "1.0.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ebisu_connection
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - tsukasaoishi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-05-21 00:00:00.000000000 Z
11
+ date: 2016-01-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fresh_connection
@@ -16,70 +16,90 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.4.0
19
+ version: 1.0.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.4.0
26
+ version: 1.0.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 1.3.0
34
+ - - "<"
32
35
  - !ruby/object:Gem::Version
33
- version: '1.7'
36
+ version: '2.0'
34
37
  type: :development
35
38
  prerelease: false
36
39
  version_requirements: !ruby/object:Gem::Requirement
37
40
  requirements:
38
- - - "~>"
41
+ - - ">="
39
42
  - !ruby/object:Gem::Version
40
- version: '1.7'
43
+ version: 1.3.0
44
+ - - "<"
45
+ - !ruby/object:Gem::Version
46
+ version: '2.0'
41
47
  - !ruby/object:Gem::Dependency
42
48
  name: rake
43
49
  requirement: !ruby/object:Gem::Requirement
44
50
  requirements:
45
- - - "~>"
51
+ - - ">="
46
52
  - !ruby/object:Gem::Version
47
- version: '10.0'
53
+ version: 0.8.7
48
54
  type: :development
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
51
57
  requirements:
52
- - - "~>"
58
+ - - ">="
53
59
  - !ruby/object:Gem::Version
54
- version: '10.0'
60
+ version: 0.8.7
55
61
  - !ruby/object:Gem::Dependency
56
- name: rspec
62
+ name: appraisal
57
63
  requirement: !ruby/object:Gem::Requirement
58
64
  requirements:
59
- - - "~>"
65
+ - - ">="
60
66
  - !ruby/object:Gem::Version
61
- version: '3.0'
67
+ version: '0'
62
68
  type: :development
63
69
  prerelease: false
64
70
  version_requirements: !ruby/object:Gem::Requirement
65
71
  requirements:
66
- - - "~>"
72
+ - - ">="
67
73
  - !ruby/object:Gem::Version
68
- version: '3.0'
74
+ version: '0'
69
75
  - !ruby/object:Gem::Dependency
70
- name: appraisal
76
+ name: minitest
71
77
  requirement: !ruby/object:Gem::Requirement
72
78
  requirements:
73
- - - "~>"
79
+ - - ">="
74
80
  - !ruby/object:Gem::Version
75
- version: '2.0'
81
+ version: '0'
76
82
  type: :development
77
83
  prerelease: false
78
84
  version_requirements: !ruby/object:Gem::Requirement
79
85
  requirements:
80
- - - "~>"
86
+ - - ">="
81
87
  - !ruby/object:Gem::Version
82
- version: '2.0'
88
+ version: '0'
89
+ - !ruby/object:Gem::Dependency
90
+ name: minitest-reporters
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ type: :development
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
83
103
  description: EbisuConnection supports to connect with Mysql slave servers. It doesn't
84
104
  need Load Balancer.
85
105
  email:
@@ -91,6 +111,7 @@ files:
91
111
  - ".gitignore"
92
112
  - ".travis.yml"
93
113
  - Appraisals
114
+ - CODE_OF_CONDUCT.md
94
115
  - Gemfile
95
116
  - LICENSE.txt
96
117
  - README.md
@@ -127,7 +148,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
127
148
  version: '0'
128
149
  requirements: []
129
150
  rubyforge_project:
130
- rubygems_version: 2.4.5
151
+ rubygems_version: 2.5.1
131
152
  signing_key:
132
153
  specification_version: 4
133
154
  summary: EbisuConnection supports to connect with Mysql slave servers.