ready-for-migration 0.1.1 → 0.1.2
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.
Potentially problematic release.
This version of ready-for-migration might be problematic. Click here for more details.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a0e753e4def466810e67b02c098ca3f4a4ac7e9fc4ef83daed81848086513dc7
|
4
|
+
data.tar.gz: 65d5db0fd19fb6f5e9edee9e690b1def89afbbe6a1ef3d03ac46e2832ee3d11a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 807d107595256c81270caa89b215705b174120d3c6692c2e01dbaeb568fd9fab0e8d7d04e6c145be3414bc3342e9b0358e3430b2df4e5c722db261d7b6c0b6f1
|
7
|
+
data.tar.gz: 93bbe8c21236760096827b77da10ded3e3ee93959821be52f350faa953ab956ffab8b402204136dd100f340e9d07383fc881c222f5edb5a87a10887fc83c12cd
|
@@ -0,0 +1,98 @@
|
|
1
|
+
require 'active_support/cache/file_store'
|
2
|
+
|
3
|
+
module Ready
|
4
|
+
module For
|
5
|
+
module Migration
|
6
|
+
module HealthActionInspectable
|
7
|
+
|
8
|
+
def self.cache
|
9
|
+
@cache ||= ActiveSupport::Cache::MemoryStore.new
|
10
|
+
end
|
11
|
+
|
12
|
+
def readiness
|
13
|
+
if params.has_key?(:status)
|
14
|
+
case
|
15
|
+
when params.has_key?(:after)
|
16
|
+
perform_inspection_with_status_and_after
|
17
|
+
when params.has_key?(:sleep)
|
18
|
+
perform_inspection_with_status_and_sleep
|
19
|
+
when params.has_key?(:random)
|
20
|
+
perform_inspection_with_status_and_random
|
21
|
+
else
|
22
|
+
perform_inspection_with_status
|
23
|
+
end
|
24
|
+
elsif params.has_key?(:sleep)
|
25
|
+
perform_inspection_with_sleep
|
26
|
+
end
|
27
|
+
|
28
|
+
super unless performed?
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def get_status_value
|
34
|
+
raw = params.dig(:status)
|
35
|
+
status = raw.to_i if raw && /^\d{3}$/.match?(raw)
|
36
|
+
status
|
37
|
+
end
|
38
|
+
|
39
|
+
def get_after_value
|
40
|
+
raw = params.dig(:after)
|
41
|
+
value = raw.to_i if raw && /^\d+$/.match?(raw)
|
42
|
+
value
|
43
|
+
end
|
44
|
+
|
45
|
+
def get_random_value
|
46
|
+
raw = params.dig(:random)
|
47
|
+
value = raw.to_i if raw && /^\d+$/.match?(raw)
|
48
|
+
value
|
49
|
+
end
|
50
|
+
|
51
|
+
def get_sleep_value
|
52
|
+
raw = params.dig(:sleep)
|
53
|
+
value = raw.to_i if raw && /^\d+$/.match?(raw)
|
54
|
+
value
|
55
|
+
end
|
56
|
+
|
57
|
+
def perform_inspection_with_status_and_after
|
58
|
+
return unless status = get_status_value
|
59
|
+
return unless value = get_after_value
|
60
|
+
|
61
|
+
first_access_time = Ready::For::Migration::HealthActionInspectable.cache.fetch(:first_access_time) { Time.now }
|
62
|
+
if first_access_time + value < Time.now
|
63
|
+
head status
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def perform_inspection_with_status_and_sleep
|
68
|
+
return unless status = get_status_value
|
69
|
+
return unless value = get_sleep_value
|
70
|
+
|
71
|
+
sleep value
|
72
|
+
head status
|
73
|
+
end
|
74
|
+
|
75
|
+
def perform_inspection_with_status_and_random
|
76
|
+
return unless status = get_status_value
|
77
|
+
return unless value = get_random_value
|
78
|
+
|
79
|
+
if value == 1 || rand(value - 1) == 0
|
80
|
+
head status
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def perform_inspection_with_status
|
85
|
+
return unless status = get_status_value
|
86
|
+
head status
|
87
|
+
end
|
88
|
+
|
89
|
+
def perform_inspection_with_sleep
|
90
|
+
return unless value = get_sleep_value
|
91
|
+
|
92
|
+
sleep value
|
93
|
+
end
|
94
|
+
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ready-for-migration
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- bizside-developers
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-01-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -60,6 +60,7 @@ files:
|
|
60
60
|
- MIT-LICENSE
|
61
61
|
- README.md
|
62
62
|
- Rakefile
|
63
|
+
- app/controllers/concerns/ready/for/migration/health_action_inspectable.rb
|
63
64
|
- app/controllers/ready/for/migration/health_controller.rb
|
64
65
|
- config/routes.rb
|
65
66
|
- lib/ready/for/migration.rb
|
@@ -84,8 +85,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
84
85
|
- !ruby/object:Gem::Version
|
85
86
|
version: '0'
|
86
87
|
requirements: []
|
87
|
-
|
88
|
-
rubygems_version: 2.7.6.2
|
88
|
+
rubygems_version: 3.1.6
|
89
89
|
signing_key:
|
90
90
|
specification_version: 4
|
91
91
|
summary: ready for migration
|