fly-ruby 0.1.0 → 0.1.1
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 +4 -4
- data/.github/workflows/test.yml +0 -3
- data/Rakefile +5 -0
- data/lib/fly-ruby/regional_database.rb +13 -0
- data/lib/fly-ruby/version.rb +3 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 82d6cde56b619737984124f61e7fc526129eebb493e1954f9b9b171202d8eed0
|
4
|
+
data.tar.gz: 2a14fee50d07739be04a19476128671878fb448fbe1cf23654df254beba4507a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 87c976601cddc300a435f503983f5de87e54c7965b07fd36232526c8e3da26e4ac2f40b729e6f701924d9371872adeaafd780937eb9a750af95c8f6cb59b9012
|
7
|
+
data.tar.gz: 0c528dbb8a6d4035a754f8b580562c21194a37e999c64f82831aa2c70e0cb53b3687d9e94bbcaf67fe7ca1526f96232b87bb77a4dac1d017b30dcca080c9315d
|
data/.github/workflows/test.yml
CHANGED
data/Rakefile
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'rake'
|
2
|
+
|
1
3
|
module Fly
|
2
4
|
# Note that using instance variables in Rack middleware is considered a poor practice in
|
3
5
|
# multithreaded environments. Instead of using dirty tricks like using Object#dup,
|
@@ -9,8 +11,19 @@ module Fly
|
|
9
11
|
prefer_regional_database! unless in_primary_region?
|
10
12
|
end
|
11
13
|
|
14
|
+
def console?
|
15
|
+
defined?(::Rails::Console) && $stdout.isatty && $stdin.isatty
|
16
|
+
end
|
17
|
+
|
18
|
+
def rake_task?
|
19
|
+
defined?(::Rake) && !Rake.application.top_level_tasks.empty?
|
20
|
+
end
|
21
|
+
|
12
22
|
# Overwrite the primary database URL with that of the regional replica
|
13
23
|
def prefer_regional_database!
|
24
|
+
# Don't override the database if migrations are running
|
25
|
+
return if console? || rake_task?
|
26
|
+
|
14
27
|
uri = URI.parse(Fly.configuration.database_url)
|
15
28
|
hostname = "#{Fly.configuration.current_region}.#{uri.hostname}"
|
16
29
|
port = 5433
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fly-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joshua Sierles
|
@@ -42,6 +42,7 @@ files:
|
|
42
42
|
- lib/fly-ruby/configuration.rb
|
43
43
|
- lib/fly-ruby/railtie.rb
|
44
44
|
- lib/fly-ruby/regional_database.rb
|
45
|
+
- lib/fly-ruby/version.rb
|
45
46
|
homepage: https://github.com/superfly/fly-ruby
|
46
47
|
licenses:
|
47
48
|
- BSD-3-Clause
|