janus-ar 0.15.2 → 0.15.3

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
  SHA256:
3
- metadata.gz: 8bb9ff5d84b8ba3951b9a1666e64d267cfec1954cdebd7e9cc72cea970f0d3db
4
- data.tar.gz: 308144511c0a90d895e09acf51313a5c2eb3413e7d3b4016ac94b379d6c63489
3
+ metadata.gz: ba9bd0a8c688fa7d38fb9af101c5f47d3aeab3894499c55759c40190c8e56b6d
4
+ data.tar.gz: fe843929d1d953d249a5e36cda2779b0b9c72f2ad89da0eb0877f7db38f1c74e
5
5
  SHA512:
6
- metadata.gz: dd4855979a81e739025ecca496f38ff5be6a1b7979f5fdd713329b985a8ca07663f9fa0c0b3bba89d0793ada21f73e66ac12635a664e42146b5bce1d926d4649
7
- data.tar.gz: 113eed8973e6a7b60e2c05960bbe979c908b84efbfe58b3843afdeaaa3ca8808c04465811ab07eaf0244e5fa51ecce40f777098f25118ec89271b9fcaa5cb07c
6
+ metadata.gz: 6f0de25c9fded2476a892bdb48d5aa40a522fc523374b4de651eebc188263b60d11175ceb66f0f49178c9815b34a03e99fcd7953a3618c9fb8ec38037a127a7a
7
+ data.tar.gz: 3c883d4c3b81a36696f844e45c583e7d575dc02c8bc3b1b1df30c916cd0420d8e8880f4089d09316f241bdb0c859cf472eb38a7e68e6de45fdebf12fd916ce6e
@@ -1,60 +1,60 @@
1
- name: CI
2
-
3
- on:
4
- push:
5
- branches:
6
- - main
7
- pull_request:
8
-
9
- jobs:
10
- build:
11
- runs-on: ubuntu-latest
12
- strategy:
13
- fail-fast: false
14
- matrix:
15
- ruby:
16
- - '3.2'
17
- name: Ruby ${{ matrix.ruby }}
18
- services:
19
- mysql:
20
- image: mysql:8
21
- env:
22
- MYSQL_DATABASE: test
23
- MYSQL_ROOT_PASSWORD: password
24
- MYSQL_USER: test
25
- MYSQL_PASSWORD: test_password
26
- ports:
27
- - 3306:3306
28
- options: >-
29
- --health-cmd "mysqladmin ping"
30
- --health-interval 10s
31
- --health-timeout 5s
32
- --health-retries 5
33
- steps:
34
- - uses: actions/checkout@v2
35
- - uses: ruby/setup-ruby@v1
36
- with:
37
- ruby-version: ${{ matrix.ruby }}
38
- bundler-cache: true
39
- - run: |
40
- mysql -e "CREATE USER 'replica'@'%' IDENTIFIED WITH mysql_native_password BY 'replica_password';" -u root -p${{ env.MYSQL_PASSWORD || 'password' }} -h 127.0.0.1
41
- mysql -e "GRANT SELECT ON test.* TO 'replica'@'%'" -u root -p${{ env.MYSQL_PASSWORD || 'password' }} -h 127.0.0.1
42
-
43
- mysql -e "CREATE USER 'primary'@'%' IDENTIFIED WITH mysql_native_password BY 'primary_password';" -u root -p${{ env.MYSQL_PASSWORD || 'password' }} -h 127.0.0.1
44
- mysql -e "GRANT ALL PRIVILEGES ON *.* TO 'primary'@'%';" -u root -p${{ env.MYSQL_PASSWORD || 'password' }} -h 127.0.0.1
45
- mysql -e "FLUSH PRIVILEGES;" -u root -p${{ env.MYSQL_PASSWORD || 'password' }} -h 127.0.0.1
46
- - run: |
47
- bundle exec rspec
48
- env:
49
- MYSQL_HOST: 127.0.0.1
50
- RAILS_ENV: test
51
- RuboCop:
52
- runs-on: ubuntu-latest
53
- steps:
54
- - uses: actions/checkout@v2
55
- - uses: ruby/setup-ruby@v1
56
- with:
57
- ruby-version: '3.2'
58
- bundler-cache: true
59
- - run: |
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ pull_request:
8
+
9
+ jobs:
10
+ build:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ fail-fast: false
14
+ matrix:
15
+ ruby:
16
+ - '3.2'
17
+ name: Ruby ${{ matrix.ruby }}
18
+ services:
19
+ mysql:
20
+ image: mysql:8
21
+ env:
22
+ MYSQL_DATABASE: test
23
+ MYSQL_ROOT_PASSWORD: password
24
+ MYSQL_USER: test
25
+ MYSQL_PASSWORD: test_password
26
+ ports:
27
+ - 3306:3306
28
+ options: >-
29
+ --health-cmd "mysqladmin ping"
30
+ --health-interval 10s
31
+ --health-timeout 5s
32
+ --health-retries 5
33
+ steps:
34
+ - uses: actions/checkout@v2
35
+ - uses: ruby/setup-ruby@v1
36
+ with:
37
+ ruby-version: ${{ matrix.ruby }}
38
+ bundler-cache: true
39
+ - run: |
40
+ mysql -e "CREATE USER 'replica'@'%' IDENTIFIED BY 'replica_password';" -u root -p${{ env.MYSQL_PASSWORD || 'password' }} -h 127.0.0.1
41
+ mysql -e "GRANT SELECT ON test.* TO 'replica'@'%'" -u root -p${{ env.MYSQL_PASSWORD || 'password' }} -h 127.0.0.1
42
+
43
+ mysql -e "CREATE USER 'primary'@'%' IDENTIFIED BY 'primary_password';" -u root -p${{ env.MYSQL_PASSWORD || 'password' }} -h 127.0.0.1
44
+ mysql -e "GRANT ALL PRIVILEGES ON *.* TO 'primary'@'%';" -u root -p${{ env.MYSQL_PASSWORD || 'password' }} -h 127.0.0.1
45
+ mysql -e "FLUSH PRIVILEGES;" -u root -p${{ env.MYSQL_PASSWORD || 'password' }} -h 127.0.0.1
46
+ - run: |
47
+ bundle exec rspec
48
+ env:
49
+ MYSQL_HOST: 127.0.0.1
50
+ RAILS_ENV: test
51
+ RuboCop:
52
+ runs-on: ubuntu-latest
53
+ steps:
54
+ - uses: actions/checkout@v2
55
+ - uses: ruby/setup-ruby@v1
56
+ with:
57
+ ruby-version: '3.2'
58
+ bundler-cache: true
59
+ - run: |
60
60
  bundle exec rubocop --parallel --color
data/Gemfile.lock CHANGED
@@ -1,128 +1,122 @@
1
- PATH
2
- remote: .
3
- specs:
4
- janus-ar (0.15.1)
5
-
6
- GEM
7
- remote: http://rubygems.org/
8
- specs:
9
- activemodel (7.1.3.2)
10
- activesupport (= 7.1.3.2)
11
- activerecord (7.1.3.2)
12
- activemodel (= 7.1.3.2)
13
- activesupport (= 7.1.3.2)
14
- timeout (>= 0.4.0)
15
- activesupport (7.1.3.2)
16
- base64
17
- bigdecimal
18
- concurrent-ruby (~> 1.0, >= 1.0.2)
19
- connection_pool (>= 2.2.5)
20
- drb
21
- i18n (>= 1.6, < 2)
22
- minitest (>= 5.1)
23
- mutex_m
24
- tzinfo (~> 2.0)
25
- ast (2.4.2)
26
- base64 (0.2.0)
27
- bigdecimal (3.1.7)
28
- coderay (1.1.3)
29
- concurrent-ruby (1.2.3)
30
- connection_pool (2.4.1)
31
- diff-lcs (1.5.1)
32
- drb (2.2.1)
33
- i18n (1.14.4)
34
- concurrent-ruby (~> 1.0)
35
- json (2.7.2)
36
- language_server-protocol (3.17.0.3)
37
- method_source (1.0.0)
38
- minitest (5.22.3)
39
- mutex_m (0.2.0)
40
- mysql2 (0.5.6)
41
- parallel (1.24.0)
42
- parser (3.3.1.0)
43
- ast (~> 2.4.1)
44
- racc
45
- pry (0.14.2)
46
- coderay (~> 1.1)
47
- method_source (~> 1.0)
48
- racc (1.7.3)
49
- rack (3.0.10)
50
- rainbow (3.1.1)
51
- rake (13.2.1)
52
- regexp_parser (2.9.0)
53
- rexml (3.2.6)
54
- rspec (3.13.0)
55
- rspec-core (~> 3.13.0)
56
- rspec-expectations (~> 3.13.0)
57
- rspec-mocks (~> 3.13.0)
58
- rspec-core (3.13.0)
59
- rspec-support (~> 3.13.0)
60
- rspec-expectations (3.13.0)
61
- diff-lcs (>= 1.2.0, < 2.0)
62
- rspec-support (~> 3.13.0)
63
- rspec-mocks (3.13.0)
64
- diff-lcs (>= 1.2.0, < 2.0)
65
- rspec-support (~> 3.13.0)
66
- rspec-support (3.13.1)
67
- rubocop (1.63.4)
68
- json (~> 2.3)
69
- language_server-protocol (>= 3.17.0)
70
- parallel (~> 1.10)
71
- parser (>= 3.3.0.2)
72
- rainbow (>= 2.2.2, < 4.0)
73
- regexp_parser (>= 1.8, < 3.0)
74
- rexml (>= 3.2.5, < 4.0)
75
- rubocop-ast (>= 1.31.1, < 2.0)
76
- ruby-progressbar (~> 1.7)
77
- unicode-display_width (>= 2.4.0, < 3.0)
78
- rubocop-ast (1.31.2)
79
- parser (>= 3.3.0.4)
80
- rubocop-capybara (2.20.0)
81
- rubocop (~> 1.41)
82
- rubocop-factory_bot (2.25.1)
83
- rubocop (~> 1.41)
84
- rubocop-performance (1.21.0)
85
- rubocop (>= 1.48.1, < 2.0)
86
- rubocop-ast (>= 1.31.1, < 2.0)
87
- rubocop-rails (2.24.1)
88
- activesupport (>= 4.2.0)
89
- rack (>= 1.1)
90
- rubocop (>= 1.33.0, < 2.0)
91
- rubocop-ast (>= 1.31.1, < 2.0)
92
- rubocop-rspec (2.29.1)
93
- rubocop (~> 1.40)
94
- rubocop-capybara (~> 2.17)
95
- rubocop-factory_bot (~> 2.22)
96
- rubocop-rspec_rails (~> 2.28)
97
- rubocop-rspec_rails (2.28.3)
98
- rubocop (~> 1.40)
99
- rubocop-thread_safety (0.5.1)
100
- rubocop (>= 0.90.0)
101
- ruby-progressbar (1.13.0)
102
- timeout (0.4.1)
103
- trilogy (2.8.0)
104
- tzinfo (2.0.6)
105
- concurrent-ruby (~> 1.0)
106
- unicode-display_width (2.5.0)
107
-
108
- PLATFORMS
109
- arm64-darwin-23
110
- x86_64-linux
111
-
112
- DEPENDENCIES
113
- activerecord (>= 7.1.0)
114
- activesupport (>= 7.1.0)
115
- janus-ar!
116
- mysql2
117
- pry
118
- rake
119
- rspec (~> 3)
120
- rubocop (~> 1.63.0)
121
- rubocop-performance
122
- rubocop-rails (~> 2.24.0)
123
- rubocop-rspec
124
- rubocop-thread_safety
125
- trilogy
126
-
127
- BUNDLED WITH
128
- 2.4.22
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ janus-ar (0.15.2)
5
+ activerecord (>= 7.1.0, < 7.2)
6
+
7
+ GEM
8
+ remote: http://rubygems.org/
9
+ specs:
10
+ activemodel (7.1.3.4)
11
+ activesupport (= 7.1.3.4)
12
+ activerecord (7.1.3.4)
13
+ activemodel (= 7.1.3.4)
14
+ activesupport (= 7.1.3.4)
15
+ timeout (>= 0.4.0)
16
+ activesupport (7.1.3.4)
17
+ base64
18
+ bigdecimal
19
+ concurrent-ruby (~> 1.0, >= 1.0.2)
20
+ connection_pool (>= 2.2.5)
21
+ drb
22
+ i18n (>= 1.6, < 2)
23
+ minitest (>= 5.1)
24
+ mutex_m
25
+ tzinfo (~> 2.0)
26
+ ast (2.4.2)
27
+ base64 (0.2.0)
28
+ bigdecimal (3.1.8)
29
+ coderay (1.1.3)
30
+ concurrent-ruby (1.3.3)
31
+ connection_pool (2.4.1)
32
+ diff-lcs (1.5.1)
33
+ drb (2.2.1)
34
+ i18n (1.14.5)
35
+ concurrent-ruby (~> 1.0)
36
+ json (2.7.2)
37
+ language_server-protocol (3.17.0.3)
38
+ method_source (1.0.0)
39
+ minitest (5.24.1)
40
+ mutex_m (0.2.0)
41
+ mysql2 (0.5.6)
42
+ parallel (1.26.3)
43
+ parser (3.3.4.2)
44
+ ast (~> 2.4.1)
45
+ racc
46
+ pry (0.14.2)
47
+ coderay (~> 1.1)
48
+ method_source (~> 1.0)
49
+ racc (1.8.1)
50
+ rack (3.1.5)
51
+ strscan
52
+ rainbow (3.1.1)
53
+ rake (13.2.1)
54
+ regexp_parser (2.9.2)
55
+ rexml (3.3.5)
56
+ strscan
57
+ rspec (3.13.0)
58
+ rspec-core (~> 3.13.0)
59
+ rspec-expectations (~> 3.13.0)
60
+ rspec-mocks (~> 3.13.0)
61
+ rspec-core (3.13.0)
62
+ rspec-support (~> 3.13.0)
63
+ rspec-expectations (3.13.0)
64
+ diff-lcs (>= 1.2.0, < 2.0)
65
+ rspec-support (~> 3.13.0)
66
+ rspec-mocks (3.13.0)
67
+ diff-lcs (>= 1.2.0, < 2.0)
68
+ rspec-support (~> 3.13.0)
69
+ rspec-support (3.13.1)
70
+ rubocop (1.65.1)
71
+ json (~> 2.3)
72
+ language_server-protocol (>= 3.17.0)
73
+ parallel (~> 1.10)
74
+ parser (>= 3.3.0.2)
75
+ rainbow (>= 2.2.2, < 4.0)
76
+ regexp_parser (>= 2.4, < 3.0)
77
+ rexml (>= 3.2.5, < 4.0)
78
+ rubocop-ast (>= 1.31.1, < 2.0)
79
+ ruby-progressbar (~> 1.7)
80
+ unicode-display_width (>= 2.4.0, < 3.0)
81
+ rubocop-ast (1.32.1)
82
+ parser (>= 3.3.1.0)
83
+ rubocop-performance (1.21.1)
84
+ rubocop (>= 1.48.1, < 2.0)
85
+ rubocop-ast (>= 1.31.1, < 2.0)
86
+ rubocop-rails (2.25.1)
87
+ activesupport (>= 4.2.0)
88
+ rack (>= 1.1)
89
+ rubocop (>= 1.33.0, < 2.0)
90
+ rubocop-ast (>= 1.31.1, < 2.0)
91
+ rubocop-rspec (3.0.4)
92
+ rubocop (~> 1.61)
93
+ rubocop-thread_safety (0.5.1)
94
+ rubocop (>= 0.90.0)
95
+ ruby-progressbar (1.13.0)
96
+ strscan (3.1.0)
97
+ timeout (0.4.1)
98
+ trilogy (2.8.1)
99
+ tzinfo (2.0.6)
100
+ concurrent-ruby (~> 1.0)
101
+ unicode-display_width (2.5.0)
102
+
103
+ PLATFORMS
104
+ arm64-darwin-23
105
+ x86_64-linux
106
+
107
+ DEPENDENCIES
108
+ activesupport (>= 7.1.0, < 7.2)
109
+ janus-ar!
110
+ mysql2
111
+ pry
112
+ rake
113
+ rspec (~> 3)
114
+ rubocop (~> 1.65.0)
115
+ rubocop-performance
116
+ rubocop-rails (~> 2.25.0)
117
+ rubocop-rspec
118
+ rubocop-thread_safety
119
+ trilogy
120
+
121
+ BUNDLED WITH
122
+ 2.4.22
data/README.md CHANGED
@@ -1,110 +1,110 @@
1
- # Janus ActiveRecord
2
-
3
- <p align="center">
4
- <img src="assets/janus-logo.png"
5
- alt="Janus Logo"
6
- style="float: left; margin: 0 auto; height: 500px;" />
7
- </p>
8
-
9
- > In ancient Roman religion and myth, Janus (/ˈdʒeɪnəs/ JAY-nəs; Latin: Ianvs [ˈi̯aːnʊs]) is the god of beginnings, gates, transitions, time, duality, doorways,[2] passages, frames, and endings. [(wikipedia)](https://en.wikipedia.org/wiki/Janus)
10
-
11
- [![CI](https://github.com/OLIOEX/janus-ar/actions/workflows/ci.yml/badge.svg)](https://github.com/OLIOEX/janus-ar/actions/workflows/ci.yml)
12
- [![Gem Version](https://badge.fury.io/rb/janus-ar.svg)](https://badge.fury.io/rb/janus-ar)
13
-
14
- Janus ActiveRecord is generic primary/replica proxy for ActiveRecord 7.1+ and MySQL (via `mysql2` and `trilogy`). It handles the switching of connections between primary and replica database servers. It comes with an ActiveRecord database adapter implementation.
15
-
16
- Note: Trilogy support is experimental at this stage.
17
-
18
- Janus is heavily inspired by [Makara](https://github.com/instacart/makara) from TaskRabbit and then Instacart. Unfortunately this project is unmaintained and broke for us with Rails 7.1. This is an attempt to start afresh on the project. It is definitely not as fully featured as Makara at this stage.
19
-
20
- Learn more about its origins: [https://tech.olioex.com/ruby/2024/04/16/introducing-janus.html](https://tech.olioex.com/ruby/2024/04/16/introducing-janus.html).
21
-
22
- Notes: GEM is currently tested with MySQL 8, Ruby 3.2, ActiveRecord 7.1+
23
-
24
- ## Installation
25
-
26
- Use the current version of the gem from [rubygems](https://rubygems.org/gems/janus-ar) in your `Gemfile`.
27
-
28
- ```ruby
29
- gem 'janus-ar'
30
- ```
31
-
32
- This project assumes that your read/write endpoints are handled by a separate system (e.g. DNS).
33
-
34
- ## Usage
35
-
36
- After a write request during a thread the adapter will continue using the `primary` server, unless the context is specifically released.
37
-
38
- ### Configuration
39
-
40
- Update your **database.yml** as follows:
41
-
42
- ```yml
43
- development:
44
- adapter: janus_mysql2
45
- database: database_name
46
- janus:
47
- primary:
48
- <<: *default
49
- host: primary-host.local
50
- replica:
51
- <<: *default
52
- password: ithappenstobedifferent
53
- host: replica-host.local
54
- ```
55
- Note: For `trilogy` please use adapter "janus_trilogy". You'll probably need to add the following to your configuration to have it connect:
56
-
57
- ```yml
58
- ssl: true
59
- ssl_mode: 'REQUIRED'
60
- tls_min_version: 3
61
- ```
62
-
63
- `tls_min_version` here refers to TLS1.2.
64
-
65
- Otherwise you will get an error like the following (see https://github.com/trilogy-libraries/trilogy/issues/26):
66
- > trilogy_auth_recv: caching_sha2_password requires either TCP with TLS or a unix socket: TRILOGY_UNSUPPORTED"
67
-
68
- ### Forcing connections
69
-
70
- A context is local to the curent thread of execution. This will allow you to stick to the primary safely in a single thread
71
- in systems such as sidekiq, for instance.
72
-
73
- #### Releasing stuck connections (clearing context)
74
-
75
- If you need to clear the current context, releasing any stuck connections, all you have to do is:
76
-
77
- ```ruby
78
- Janus::Context.release_all
79
- ```
80
-
81
- #### Forcing connection to primary server
82
-
83
- ```ruby
84
- Janus::Context.stick_to_primary
85
- ```
86
-
87
- ### Logging
88
-
89
- You can set a logger instance to `::Janus::Logging::Logger.logger`:
90
-
91
- ```ruby
92
- Janus::Logging::Logger.logger = ::Logger.new(STDOUT)
93
- ```
94
-
95
- If using `ActiveRecord` logging, Janus will append the name of the connection used to any logs e.g. `[primary]` or `[replica]`.
96
-
97
- ### What queries goes where?
98
-
99
- In general: Any `SELECT` statements will execute against your replica(s), anything else will go to the primary.
100
-
101
- There are some edge cases:
102
- * `SET` operations will be sent to all connections
103
- * Execution of specific methods such as `connect!`, `disconnect!`, `reconnect!`, and `clear_cache!` are invoked on all underlying connections
104
- * Calls inside a transaction will always be sent to the primary (otherwise changes from within the transaction could not be read back on most transaction isolation levels)
105
- * Locking reads (e.g. `SELECT ... FOR UPDATE`) will always be sent to the primary
106
-
107
-
108
- # Acknowlegements
109
-
110
- Amazing project logo by @undevelopedbruce.
1
+ # Janus ActiveRecord
2
+
3
+ <p align="center">
4
+ <img src="assets/janus-logo.png"
5
+ alt="Janus Logo"
6
+ style="float: left; margin: 0 auto; height: 500px;" />
7
+ </p>
8
+
9
+ > In ancient Roman religion and myth, Janus (/ˈdʒeɪnəs/ JAY-nəs; Latin: Ianvs [ˈi̯aːnʊs]) is the god of beginnings, gates, transitions, time, duality, doorways,[2] passages, frames, and endings. [(wikipedia)](https://en.wikipedia.org/wiki/Janus)
10
+
11
+ [![CI](https://github.com/OLIOEX/janus-ar/actions/workflows/ci.yml/badge.svg)](https://github.com/OLIOEX/janus-ar/actions/workflows/ci.yml)
12
+ [![Gem Version](https://badge.fury.io/rb/janus-ar.svg)](https://badge.fury.io/rb/janus-ar)
13
+
14
+ Janus ActiveRecord is generic primary/replica proxy for ActiveRecord 7.1+ and MySQL (via `mysql2` and `trilogy`). It handles the switching of connections between primary and replica database servers. It comes with an ActiveRecord database adapter implementation.
15
+
16
+ Note: Trilogy support is experimental at this stage.
17
+
18
+ Janus is heavily inspired by [Makara](https://github.com/instacart/makara) from TaskRabbit and then Instacart. Unfortunately this project is unmaintained and broke for us with Rails 7.1. This is an attempt to start afresh on the project. It is definitely not as fully featured as Makara at this stage.
19
+
20
+ Learn more about its origins: [https://tech.olioex.com/ruby/2024/04/16/introducing-janus.html](https://tech.olioex.com/ruby/2024/04/16/introducing-janus.html).
21
+
22
+ Notes: GEM is currently tested with MySQL 8, Ruby 3.2, ActiveRecord 7.1+
23
+
24
+ ## Installation
25
+
26
+ Use the current version of the gem from [rubygems](https://rubygems.org/gems/janus-ar) in your `Gemfile`.
27
+
28
+ ```ruby
29
+ gem 'janus-ar'
30
+ ```
31
+
32
+ This project assumes that your read/write endpoints are handled by a separate system (e.g. DNS).
33
+
34
+ ## Usage
35
+
36
+ After a write request during a thread the adapter will continue using the `primary` server, unless the context is specifically released.
37
+
38
+ ### Configuration
39
+
40
+ Update your **database.yml** as follows:
41
+
42
+ ```yml
43
+ development:
44
+ adapter: janus_mysql2
45
+ database: database_name
46
+ janus:
47
+ primary:
48
+ <<: *default
49
+ host: primary-host.local
50
+ replica:
51
+ <<: *default
52
+ password: ithappenstobedifferent
53
+ host: replica-host.local
54
+ ```
55
+ Note: For `trilogy` please use adapter "janus_trilogy". You'll probably need to add the following to your configuration to have it connect:
56
+
57
+ ```yml
58
+ ssl: true
59
+ ssl_mode: 'REQUIRED'
60
+ tls_min_version: 3
61
+ ```
62
+
63
+ `tls_min_version` here refers to TLS1.2.
64
+
65
+ Otherwise you will get an error like the following (see https://github.com/trilogy-libraries/trilogy/issues/26):
66
+ > trilogy_auth_recv: caching_sha2_password requires either TCP with TLS or a unix socket: TRILOGY_UNSUPPORTED"
67
+
68
+ ### Forcing connections
69
+
70
+ A context is local to the curent thread of execution. This will allow you to stick to the primary safely in a single thread
71
+ in systems such as sidekiq, for instance.
72
+
73
+ #### Releasing stuck connections (clearing context)
74
+
75
+ If you need to clear the current context, releasing any stuck connections, all you have to do is:
76
+
77
+ ```ruby
78
+ Janus::Context.release_all
79
+ ```
80
+
81
+ #### Forcing connection to primary server
82
+
83
+ ```ruby
84
+ Janus::Context.stick_to_primary
85
+ ```
86
+
87
+ ### Logging
88
+
89
+ You can set a logger instance to `::Janus::Logging::Logger.logger`:
90
+
91
+ ```ruby
92
+ Janus::Logging::Logger.logger = ::Logger.new(STDOUT)
93
+ ```
94
+
95
+ If using `ActiveRecord` logging, Janus will append the name of the connection used to any logs e.g. `[primary]` or `[replica]`.
96
+
97
+ ### What queries goes where?
98
+
99
+ In general: Any `SELECT` statements will execute against your replica(s), anything else will go to the primary.
100
+
101
+ There are some edge cases:
102
+ * `SET` operations will be sent to all connections
103
+ * Execution of specific methods such as `connect!`, `disconnect!`, `reconnect!`, and `clear_cache!` are invoked on all underlying connections
104
+ * Calls inside a transaction will always be sent to the primary (otherwise changes from within the transaction could not be read back on most transaction isolation levels)
105
+ * Locking reads (e.g. `SELECT ... FOR UPDATE`) will always be sent to the primary
106
+
107
+
108
+ # Acknowlegements
109
+
110
+ Amazing project logo by @undevelopedbruce.
data/Rakefile CHANGED
@@ -1 +1,3 @@
1
- require 'bundler/gem_tasks'
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'