activerecord-aurora-serverless-adapter 1.0.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 +7 -0
- data/.github/workflows/ci.yaml +37 -0
- data/.gitignore +21 -0
- data/.ruby-version +1 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Dockerfile-cdk +3 -0
- data/Dockerfile-ci +2 -0
- data/Gemfile +30 -0
- data/Gemfile.lock +189 -0
- data/LICENSE.txt +21 -0
- data/README.md +110 -0
- data/Rakefile +27 -0
- data/activerecord-aurora-serverless-adapter.gemspec +30 -0
- data/bin/_setup +5 -0
- data/bin/_test +23 -0
- data/bin/bootstrap +8 -0
- data/bin/run +8 -0
- data/bin/setup +8 -0
- data/bin/test +8 -0
- data/bin/test-ci-setup +16 -0
- data/docker-compose.yml +36 -0
- data/lib/active_record/connection_adapters/aurora_serverless/abstract.rb +29 -0
- data/lib/active_record/connection_adapters/aurora_serverless/client.rb +152 -0
- data/lib/active_record/connection_adapters/aurora_serverless/gem_hack.rb +15 -0
- data/lib/active_record/connection_adapters/aurora_serverless/mysql2.rb +90 -0
- data/lib/active_record/connection_adapters/aurora_serverless/mysql2/client.rb +71 -0
- data/lib/active_record/connection_adapters/aurora_serverless/mysql2/connection_handling.rb +20 -0
- data/lib/active_record/connection_adapters/aurora_serverless/mysql2/result.rb +116 -0
- data/lib/active_record/connection_adapters/aurora_serverless/version.rb +7 -0
- data/lib/active_record/connection_adapters/aurora_serverless_adapter.rb +7 -0
- data/lib/activerecord-aurora-serverless-adapter.rb +1 -0
- data/lib/mysql2.rb +4 -0
- metadata +217 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: d55e3b914364d41374c560c6183e7def09de56c9d3e90a9cba15bac946c10353
|
4
|
+
data.tar.gz: 5266a9a3be80080fbdfe5b24a85611251ac2724994f3883066e6b2c045845168
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 347d5f9690887b426f7d290295c92ee402ed2a8d808097f2e796e46bcbf3bc201c133a531a1b7a20e8e3790fed4859d191fa1f1be6a25a7ca16a519ddb8dc34b
|
7
|
+
data.tar.gz: 30192a0925ad931dd541da411a9817ac5c58d86c2f9d7c5c2ef70cf9117f3cb9cca39664946c03eafb2ea2fe03324bc56abad3c9cfa6882bec2b6b30a306e1d0
|
@@ -0,0 +1,37 @@
|
|
1
|
+
name: CI
|
2
|
+
on: [push]
|
3
|
+
jobs:
|
4
|
+
test:
|
5
|
+
runs-on: ubuntu-latest
|
6
|
+
steps:
|
7
|
+
- name: Checkout
|
8
|
+
uses: actions/checkout@v1
|
9
|
+
- name: Environment
|
10
|
+
run: |
|
11
|
+
echo "::set-env name=AWS_DEFAULT_REGION::us-east-1"
|
12
|
+
echo "::set-env name=AWS_ACCESS_KEY_ID::${{ secrets.AWS_ACCESS_KEY_ID }}"
|
13
|
+
echo "::set-env name=AWS_SECRET_ACCESS_KEY::${{ secrets.AWS_SECRET_ACCESS_KEY }}"
|
14
|
+
echo "::set-env name=AASA_SECRET_ARN::${{ secrets.AASA_SECRET_ARN }}"
|
15
|
+
echo "::set-env name=AASA_RESOURCE_ARN::${{ secrets.AASA_RESOURCE_ARN }}"
|
16
|
+
echo "::set-env name=AASA_SECRET_ARN2::${{ secrets.AASA_SECRET_ARN2 }}"
|
17
|
+
echo "::set-env name=AASA_RESOURCE_ARN2::${{ secrets.AASA_RESOURCE_ARN2 }}"
|
18
|
+
mkdir -p vendor/bundle
|
19
|
+
- name: Bootstrap
|
20
|
+
run: |
|
21
|
+
./bin/bootstrap
|
22
|
+
- name: Wakeup
|
23
|
+
run: |
|
24
|
+
./bin/test-ci-setup
|
25
|
+
if ! ./test/bin/wakeup ; then sleep 90 ; fi
|
26
|
+
- name: Setup (cache)
|
27
|
+
id: cache-setup
|
28
|
+
uses: actions/cache@v1
|
29
|
+
with:
|
30
|
+
path: vendor/bundle
|
31
|
+
key: ${{ runner.os }}-gems-${{ hashFiles('Gemfile.lock') }}
|
32
|
+
- name: Setup
|
33
|
+
run: |
|
34
|
+
./bin/setup
|
35
|
+
- name: Test
|
36
|
+
run: |
|
37
|
+
./bin/test
|
data/.gitignore
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# Rails
|
2
|
+
/.bundle/
|
3
|
+
/.yardoc
|
4
|
+
/_yardoc/
|
5
|
+
/coverage/
|
6
|
+
/doc/
|
7
|
+
/pkg/
|
8
|
+
/spec/reports/
|
9
|
+
/tmp/
|
10
|
+
/vendor/bundle
|
11
|
+
# Personal Deploy Scripts
|
12
|
+
/test/bin/deploy-aurora-ci
|
13
|
+
# Typescript & CDK
|
14
|
+
*.js
|
15
|
+
!jest.config.js
|
16
|
+
*.d.ts
|
17
|
+
node_modules
|
18
|
+
.cdk.staging
|
19
|
+
cdk.out
|
20
|
+
.env
|
21
|
+
debug.log
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.5.5
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at kcollins@customink.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Dockerfile-cdk
ADDED
data/Dockerfile-ci
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
source "https://rubygems.org"
|
2
|
+
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
|
3
|
+
gemspec
|
4
|
+
|
5
|
+
ENV['RAILS_VERSION'] = '6.0.2.1'
|
6
|
+
|
7
|
+
# This allows us to bundle to Rails via Git to get the ActiveRecord test files
|
8
|
+
# which comes down to a git tag. We can also use the `RAILS_VERSION` env variable
|
9
|
+
# too as needed for a very specific/tiny version too.
|
10
|
+
#
|
11
|
+
version = ENV['RAILS_VERSION'] || begin
|
12
|
+
require 'net/http'
|
13
|
+
require 'yaml'
|
14
|
+
spec = eval(File.read('activerecord-aurora-serverless-adapter.gemspec'))
|
15
|
+
ver = spec.dependencies.detect{ |d|d.name == 'activerecord' }.requirement.requirements.first.last.version
|
16
|
+
major, minor, tiny, pre = ver.split('.')
|
17
|
+
if !pre
|
18
|
+
uri = URI.parse "https://rubygems.org/api/v1/versions/activerecord.yaml"
|
19
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
20
|
+
http.use_ssl = true
|
21
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
22
|
+
YAML.load(http.request(Net::HTTP::Get.new(uri.request_uri)).body).select do |data|
|
23
|
+
a, b, c = data['number'].split('.')
|
24
|
+
!data['prerelease'] && major == a && (minor.nil? || minor == b)
|
25
|
+
end.first['number']
|
26
|
+
else
|
27
|
+
ver
|
28
|
+
end
|
29
|
+
end
|
30
|
+
gem 'rails', github: "rails/rails", tag: "v#{version}"
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,189 @@
|
|
1
|
+
GIT
|
2
|
+
remote: https://github.com/rails/rails
|
3
|
+
revision: 3a6e8a3ff94f8690dcd68d5184600eabc9e05664
|
4
|
+
tag: v6.0.2.1
|
5
|
+
specs:
|
6
|
+
actioncable (6.0.2.1)
|
7
|
+
actionpack (= 6.0.2.1)
|
8
|
+
nio4r (~> 2.0)
|
9
|
+
websocket-driver (>= 0.6.1)
|
10
|
+
actionmailbox (6.0.2.1)
|
11
|
+
actionpack (= 6.0.2.1)
|
12
|
+
activejob (= 6.0.2.1)
|
13
|
+
activerecord (= 6.0.2.1)
|
14
|
+
activestorage (= 6.0.2.1)
|
15
|
+
activesupport (= 6.0.2.1)
|
16
|
+
mail (>= 2.7.1)
|
17
|
+
actionmailer (6.0.2.1)
|
18
|
+
actionpack (= 6.0.2.1)
|
19
|
+
actionview (= 6.0.2.1)
|
20
|
+
activejob (= 6.0.2.1)
|
21
|
+
mail (~> 2.5, >= 2.5.4)
|
22
|
+
rails-dom-testing (~> 2.0)
|
23
|
+
actionpack (6.0.2.1)
|
24
|
+
actionview (= 6.0.2.1)
|
25
|
+
activesupport (= 6.0.2.1)
|
26
|
+
rack (~> 2.0, >= 2.0.8)
|
27
|
+
rack-test (>= 0.6.3)
|
28
|
+
rails-dom-testing (~> 2.0)
|
29
|
+
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
30
|
+
actiontext (6.0.2.1)
|
31
|
+
actionpack (= 6.0.2.1)
|
32
|
+
activerecord (= 6.0.2.1)
|
33
|
+
activestorage (= 6.0.2.1)
|
34
|
+
activesupport (= 6.0.2.1)
|
35
|
+
nokogiri (>= 1.8.5)
|
36
|
+
actionview (6.0.2.1)
|
37
|
+
activesupport (= 6.0.2.1)
|
38
|
+
builder (~> 3.1)
|
39
|
+
erubi (~> 1.4)
|
40
|
+
rails-dom-testing (~> 2.0)
|
41
|
+
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
42
|
+
activejob (6.0.2.1)
|
43
|
+
activesupport (= 6.0.2.1)
|
44
|
+
globalid (>= 0.3.6)
|
45
|
+
activemodel (6.0.2.1)
|
46
|
+
activesupport (= 6.0.2.1)
|
47
|
+
activerecord (6.0.2.1)
|
48
|
+
activemodel (= 6.0.2.1)
|
49
|
+
activesupport (= 6.0.2.1)
|
50
|
+
activestorage (6.0.2.1)
|
51
|
+
actionpack (= 6.0.2.1)
|
52
|
+
activejob (= 6.0.2.1)
|
53
|
+
activerecord (= 6.0.2.1)
|
54
|
+
marcel (~> 0.3.1)
|
55
|
+
activesupport (6.0.2.1)
|
56
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
57
|
+
i18n (>= 0.7, < 2)
|
58
|
+
minitest (~> 5.1)
|
59
|
+
tzinfo (~> 1.1)
|
60
|
+
zeitwerk (~> 2.2)
|
61
|
+
rails (6.0.2.1)
|
62
|
+
actioncable (= 6.0.2.1)
|
63
|
+
actionmailbox (= 6.0.2.1)
|
64
|
+
actionmailer (= 6.0.2.1)
|
65
|
+
actionpack (= 6.0.2.1)
|
66
|
+
actiontext (= 6.0.2.1)
|
67
|
+
actionview (= 6.0.2.1)
|
68
|
+
activejob (= 6.0.2.1)
|
69
|
+
activemodel (= 6.0.2.1)
|
70
|
+
activerecord (= 6.0.2.1)
|
71
|
+
activestorage (= 6.0.2.1)
|
72
|
+
activesupport (= 6.0.2.1)
|
73
|
+
bundler (>= 1.3.0)
|
74
|
+
railties (= 6.0.2.1)
|
75
|
+
sprockets-rails (>= 2.0.0)
|
76
|
+
railties (6.0.2.1)
|
77
|
+
actionpack (= 6.0.2.1)
|
78
|
+
activesupport (= 6.0.2.1)
|
79
|
+
method_source
|
80
|
+
rake (>= 0.8.7)
|
81
|
+
thor (>= 0.20.3, < 2.0)
|
82
|
+
|
83
|
+
PATH
|
84
|
+
remote: .
|
85
|
+
specs:
|
86
|
+
activerecord-aurora-serverless-adapter (1.0.0)
|
87
|
+
activerecord (>= 6.0)
|
88
|
+
aws-sdk-rdsdataservice
|
89
|
+
|
90
|
+
GEM
|
91
|
+
remote: https://rubygems.org/
|
92
|
+
specs:
|
93
|
+
ansi (1.5.0)
|
94
|
+
appraisal (2.2.0)
|
95
|
+
bundler
|
96
|
+
rake
|
97
|
+
thor (>= 0.14.0)
|
98
|
+
aws-eventstream (1.0.3)
|
99
|
+
aws-partitions (1.260.0)
|
100
|
+
aws-sdk-core (3.86.0)
|
101
|
+
aws-eventstream (~> 1.0, >= 1.0.2)
|
102
|
+
aws-partitions (~> 1, >= 1.239.0)
|
103
|
+
aws-sigv4 (~> 1.1)
|
104
|
+
jmespath (~> 1.0)
|
105
|
+
aws-sdk-rdsdataservice (1.14.0)
|
106
|
+
aws-sdk-core (~> 3, >= 3.71.0)
|
107
|
+
aws-sigv4 (~> 1.1)
|
108
|
+
aws-sigv4 (1.1.0)
|
109
|
+
aws-eventstream (~> 1.0, >= 1.0.2)
|
110
|
+
builder (3.2.4)
|
111
|
+
coderay (1.1.2)
|
112
|
+
concurrent-ruby (1.1.5)
|
113
|
+
crass (1.0.5)
|
114
|
+
dotenv (2.7.5)
|
115
|
+
erubi (1.9.0)
|
116
|
+
globalid (0.4.2)
|
117
|
+
activesupport (>= 4.2.0)
|
118
|
+
i18n (1.7.0)
|
119
|
+
concurrent-ruby (~> 1.0)
|
120
|
+
jmespath (1.4.0)
|
121
|
+
loofah (2.4.0)
|
122
|
+
crass (~> 1.0.2)
|
123
|
+
nokogiri (>= 1.5.9)
|
124
|
+
mail (2.7.1)
|
125
|
+
mini_mime (>= 0.1.1)
|
126
|
+
marcel (0.3.3)
|
127
|
+
mimemagic (~> 0.3.2)
|
128
|
+
method_source (0.9.2)
|
129
|
+
mimemagic (0.3.3)
|
130
|
+
mini_mime (1.0.2)
|
131
|
+
mini_portile2 (2.4.0)
|
132
|
+
minitest (5.13.0)
|
133
|
+
minitest-reporters (1.4.2)
|
134
|
+
ansi
|
135
|
+
builder
|
136
|
+
minitest (>= 5.0)
|
137
|
+
ruby-progressbar
|
138
|
+
minitest-retry (0.1.9)
|
139
|
+
minitest (>= 5.0)
|
140
|
+
nio4r (2.5.2)
|
141
|
+
nokogiri (1.10.7)
|
142
|
+
mini_portile2 (~> 2.4.0)
|
143
|
+
pry (0.12.2)
|
144
|
+
coderay (~> 1.1.0)
|
145
|
+
method_source (~> 0.9.0)
|
146
|
+
rack (2.0.8)
|
147
|
+
rack-test (1.1.0)
|
148
|
+
rack (>= 1.0, < 3)
|
149
|
+
rails-dom-testing (2.0.3)
|
150
|
+
activesupport (>= 4.2.0)
|
151
|
+
nokogiri (>= 1.6)
|
152
|
+
rails-html-sanitizer (1.3.0)
|
153
|
+
loofah (~> 2.3)
|
154
|
+
rake (13.0.1)
|
155
|
+
ruby-progressbar (1.10.1)
|
156
|
+
sprockets (4.0.0)
|
157
|
+
concurrent-ruby (~> 1.0)
|
158
|
+
rack (> 1, < 3)
|
159
|
+
sprockets-rails (3.2.1)
|
160
|
+
actionpack (>= 4.0)
|
161
|
+
activesupport (>= 4.0)
|
162
|
+
sprockets (>= 3.0.0)
|
163
|
+
sqlite3 (1.4.2)
|
164
|
+
thor (1.0.1)
|
165
|
+
thread_safe (0.3.6)
|
166
|
+
tzinfo (1.2.6)
|
167
|
+
thread_safe (~> 0.1)
|
168
|
+
websocket-driver (0.7.1)
|
169
|
+
websocket-extensions (>= 0.1.0)
|
170
|
+
websocket-extensions (0.1.4)
|
171
|
+
zeitwerk (2.2.2)
|
172
|
+
|
173
|
+
PLATFORMS
|
174
|
+
ruby
|
175
|
+
|
176
|
+
DEPENDENCIES
|
177
|
+
activerecord-aurora-serverless-adapter!
|
178
|
+
appraisal
|
179
|
+
dotenv
|
180
|
+
minitest
|
181
|
+
minitest-reporters
|
182
|
+
minitest-retry
|
183
|
+
pry
|
184
|
+
rails!
|
185
|
+
rake
|
186
|
+
sqlite3
|
187
|
+
|
188
|
+
BUNDLED WITH
|
189
|
+
2.1.2
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019 Ken Collins
|
4
|
+
|
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:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
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
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
|
2
|
+
# Activerecord Aurora Serverless Adapter
|
3
|
+
|
4
|
+
<a href="https://www.youtube.com/watch?v=Q0cqKl6ktIg"><img alt="Aurora Serverless on Rails" src="https://user-images.githubusercontent.com/2381/71551059-c507f180-29ab-11ea-91dc-0e83a0ed317f.png"></a>
|
5
|
+
|
6
|
+
[](https://github.com/customink/activerecord-aurora-serverless-adapter/actions)
|
7
|
+
|
8
|
+
<a href="https://github.com/customink/lamby"><img src="https://user-images.githubusercontent.com/2381/59363668-89edeb80-8d03-11e9-9985-2ce14361b7e3.png" alt="Lamby: Simple Rails & AWS Lambda Integration using Rack." align="right" width="300" /></a>
|
9
|
+
|
10
|
+
Simple ActiveRecord Mysql2 adapter extensions to allow Rails to use [AWS Aurora Serverless](https://aws.amazon.com/rds/aurora/serverless/) via the [Aws::RDSDataService::Client](https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/RDSDataService/Client.html) internface. Perfect if you are using [Lamby](https://lamby.custominktech.com) to deploy your Rails applications to AWS Lambda.
|
11
|
+
|
12
|
+
**[Lamby: Simple Rails & AWS Lambda Integration using Rack.](https://lamby.custominktech.com)**
|
13
|
+
|
14
|
+
|
15
|
+
## Highlights
|
16
|
+
|
17
|
+
This gem allows Rails to seamless use
|
18
|
+
|
19
|
+
* No need for the `mysql2` gem at all!
|
20
|
+
* Developed and tested with Aurora Serverless MySQL v5.6.
|
21
|
+
* Emoji support via `utf8mb4`. Please configure your cluster's parameter group. See our [CDK Stack](/blob/master/test/aurora-serverless/lib/aurora-serverless-stack.ts) for examples.
|
22
|
+
|
23
|
+
Here are some misc features that work differently for the Mysql2 adapter under Aurora Serverless.
|
24
|
+
|
25
|
+
* Multiple schemas are not supported.
|
26
|
+
* Prepared statements are not supported.
|
27
|
+
* Batch statements are not supported.
|
28
|
+
* Advisory locks are not supported.
|
29
|
+
|
30
|
+
|
31
|
+
## Usage
|
32
|
+
|
33
|
+
Add the gem to your `Gemfile`. Remember, You **DO NOT** have to add the `mysql2` gem. This adapter will replace the MySQL connection with the `Aws::RDSDataService::Client` API calls.
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
gem 'activerecord-aurora-serverless-adapter'
|
37
|
+
```
|
38
|
+
|
39
|
+
Assuming you have [created your database](/test/aurora-serverless/lib/aurora-serverless-stack.ts) with the Data API enabled and [configured your secrets](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/data-api.html) then configure your `database.yml` file like so.
|
40
|
+
|
41
|
+
```yaml
|
42
|
+
database: 'mydatabase'
|
43
|
+
adapter: aurora_serverless
|
44
|
+
secret_arn: arn:aws:secretsmanager:us-east-1:123456789012:secret:Secret-kd2ASwipxeWw-Bdsiww
|
45
|
+
resource_arn: arn:aws:rds:us-east-1:123456789012:cluster:mydatabase
|
46
|
+
```
|
47
|
+
|
48
|
+
lease feel free to use any valid ActiveRecord configuration in your database.yml file. We also allow all [Aws::RDSDataService::Client](https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/RDSDataService/Client.html#initialize-instance_method) options here too! Any valid option will be passed to `Aws::RDSDataService::Client.new`.
|
49
|
+
|
50
|
+
## Contributing
|
51
|
+
|
52
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/customink/activerecord-aurora-serverless-adapter. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
53
|
+
|
54
|
+
### Testing
|
55
|
+
|
56
|
+
Cloning the repo and running the tests locally is super easy assuming you have:
|
57
|
+
|
58
|
+
1. Docker Installed
|
59
|
+
2. AWS Account Configured
|
60
|
+
|
61
|
+
These commands will use Docker to setup a node runtime leveraging [AWD CDK](https://github.com/aws/aws-cdk) to deploy a Aurora Serverless stack. Note, you may be to use/set `AWS_PROFILE` for the deploy command.
|
62
|
+
|
63
|
+
```s
|
64
|
+
$ ./bin/bootstrap
|
65
|
+
$ export AASA_MASTER_USER=admin
|
66
|
+
$ export AASA_MASTER_PASS=supersecret
|
67
|
+
$ ./test/bin/deploy-aurora
|
68
|
+
```
|
69
|
+
|
70
|
+
The outputs of this deployed stack will containt an `AASASecretArn` and a `AASAAuroraClusterArn` value. Please place these into the local `.env` file in the following format where `{{ Value }}` is replaced.
|
71
|
+
|
72
|
+
```
|
73
|
+
AASA_SECRET_ARN={{ AASASecretArn }}
|
74
|
+
AASA_RESOURCE_ARN2={{ AASAResourceArn }}
|
75
|
+
|
76
|
+
AASA_SECRET_ARN={{ AASASecretArn2 }}
|
77
|
+
AASA_RESOURCE_ARN_2={{ AASAResourceArn2 }}
|
78
|
+
```
|
79
|
+
|
80
|
+
Finally, assuming you have your default AWS account setup with full access to your account, now you can run the tests. The `AWS_PROFILE` can be used here and set in `.env` file as needed or you can use the `AASAUserAccessKeyId` and `AASAUserSecretAccessKey` outputs as `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` environments set in `.env` too.
|
81
|
+
|
82
|
+
```s
|
83
|
+
$ ./bin/test
|
84
|
+
```
|
85
|
+
|
86
|
+
#### Working With The CDK App/Stack
|
87
|
+
|
88
|
+
To work with the CDK project within the test directory, run the following commands.
|
89
|
+
|
90
|
+
```s
|
91
|
+
$ docker-compose \
|
92
|
+
--project-name aasa \
|
93
|
+
run \
|
94
|
+
cdk \
|
95
|
+
bash
|
96
|
+
|
97
|
+
$ cd ./test/aurora-serverless
|
98
|
+
```
|
99
|
+
|
100
|
+
From here you can run `npm`, `tsc`, `cdk` or whatever commands are needed.
|
101
|
+
|
102
|
+
|
103
|
+
## License
|
104
|
+
|
105
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
106
|
+
|
107
|
+
|
108
|
+
## Code of Conduct
|
109
|
+
|
110
|
+
Everyone interacting in the adapter project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/customink/activerecord-aurora-serverless-adapter/blob/master/CODE_OF_CONDUCT.md).
|