waylon-core 0.1.9 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +31 -26
- data/lib/waylon/cache.rb +43 -0
- data/lib/waylon/core.rb +1 -0
- data/lib/waylon/rspec/test_server.rb +1 -2
- data/lib/waylon/rspec.rb +2 -2
- data/lib/waylon/skills/diagnostics.rb +19 -9
- data/lib/waylon/storage.rb +17 -10
- data/lib/waylon/version.rb +2 -2
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1aebd152f6a966ba3af1d42c2538ee64aa63f23b369defa8cb14b5b76028156b
|
4
|
+
data.tar.gz: ed1ca477399d53439683414a943e99ba727dd07ebb7f4a7229db7bd106e74b5c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e211f819f4d54ad740f422902c98ea9086c1b02e738aa4907a7fcd79841a42ad3478f37c72d6399208be06bac0567c61c08652a50b492e9bcfc774600f056a88
|
7
|
+
data.tar.gz: 286a48bb42872720a371e48fc5f872456af7c1a0d655bfe677554a3eef459cbe8309bc974e0ef4f38fd8b434026f078828b99a5efb86e9b197dd9d7b68d42bad
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
waylon-core (0.
|
4
|
+
waylon-core (0.2.2)
|
5
5
|
addressable (~> 2.8)
|
6
6
|
faraday (~> 1.8)
|
7
7
|
i18n (~> 1.8)
|
@@ -14,13 +14,14 @@ PATH
|
|
14
14
|
GEM
|
15
15
|
remote: https://rubygems.org/
|
16
16
|
specs:
|
17
|
-
addressable (2.8.
|
18
|
-
public_suffix (>= 2.0.2, <
|
17
|
+
addressable (2.8.1)
|
18
|
+
public_suffix (>= 2.0.2, < 6.0)
|
19
19
|
ast (2.4.2)
|
20
20
|
concurrent-ruby (1.1.10)
|
21
|
+
connection_pool (2.2.5)
|
21
22
|
diff-lcs (1.5.0)
|
22
23
|
docile (1.4.0)
|
23
|
-
faraday (1.10.
|
24
|
+
faraday (1.10.2)
|
24
25
|
faraday-em_http (~> 1.0)
|
25
26
|
faraday-em_synchrony (~> 1.0)
|
26
27
|
faraday-excon (~> 1.1)
|
@@ -44,34 +45,37 @@ GEM
|
|
44
45
|
faraday-rack (1.0.0)
|
45
46
|
faraday-retry (1.0.3)
|
46
47
|
ffi (1.15.5)
|
47
|
-
i18n (1.
|
48
|
+
i18n (1.12.0)
|
48
49
|
concurrent-ruby (~> 1.0)
|
49
50
|
json (2.6.2)
|
50
51
|
moneta (1.5.1)
|
51
52
|
mono_logger (1.1.1)
|
52
53
|
multi_json (1.15.0)
|
53
54
|
multipart-post (2.2.3)
|
54
|
-
mustermann (
|
55
|
+
mustermann (2.0.2)
|
55
56
|
ruby2_keywords (~> 0.0.1)
|
56
57
|
nio4r (2.5.8)
|
57
58
|
parallel (1.22.1)
|
58
|
-
parser (3.1.2.
|
59
|
+
parser (3.1.2.1)
|
59
60
|
ast (~> 2.4.1)
|
60
|
-
public_suffix (
|
61
|
-
puma (5.6.
|
61
|
+
public_suffix (5.0.0)
|
62
|
+
puma (5.6.5)
|
62
63
|
nio4r (~> 2.0)
|
63
|
-
rack (2.2.
|
64
|
-
rack-protection (2.2.
|
64
|
+
rack (2.2.4)
|
65
|
+
rack-protection (2.2.2)
|
65
66
|
rack
|
66
67
|
rainbow (3.1.1)
|
67
68
|
rake (13.0.6)
|
68
69
|
rbnacl (7.1.1)
|
69
70
|
ffi
|
70
|
-
redis (
|
71
|
-
|
72
|
-
|
71
|
+
redis (5.0.1)
|
72
|
+
redis-client (~> 0.7)
|
73
|
+
redis-client (0.7.1)
|
74
|
+
connection_pool
|
75
|
+
redis-namespace (1.9.0)
|
76
|
+
redis (>= 4)
|
73
77
|
regexp_parser (2.5.0)
|
74
|
-
resque (2.
|
78
|
+
resque (2.3.0)
|
75
79
|
mono_logger (~> 1.0)
|
76
80
|
multi_json (~> 1.0)
|
77
81
|
redis-namespace (~> 1.6)
|
@@ -90,21 +94,22 @@ GEM
|
|
90
94
|
diff-lcs (>= 1.2.0, < 2.0)
|
91
95
|
rspec-support (~> 3.11.0)
|
92
96
|
rspec-support (3.11.0)
|
93
|
-
rubocop (1.
|
97
|
+
rubocop (1.35.1)
|
98
|
+
json (~> 2.3)
|
94
99
|
parallel (~> 1.10)
|
95
|
-
parser (>= 3.1.
|
100
|
+
parser (>= 3.1.2.1)
|
96
101
|
rainbow (>= 2.2.2, < 4.0)
|
97
102
|
regexp_parser (>= 1.8, < 3.0)
|
98
103
|
rexml (>= 3.2.5, < 4.0)
|
99
|
-
rubocop-ast (>= 1.
|
104
|
+
rubocop-ast (>= 1.20.1, < 2.0)
|
100
105
|
ruby-progressbar (~> 1.7)
|
101
106
|
unicode-display_width (>= 1.4.0, < 3.0)
|
102
|
-
rubocop-ast (1.
|
107
|
+
rubocop-ast (1.21.0)
|
103
108
|
parser (>= 3.1.1.0)
|
104
109
|
rubocop-rake (0.6.0)
|
105
110
|
rubocop (~> 1.0)
|
106
|
-
rubocop-rspec (2.
|
107
|
-
rubocop (~> 1.
|
111
|
+
rubocop-rspec (2.12.1)
|
112
|
+
rubocop (~> 1.31)
|
108
113
|
ruby-progressbar (1.11.0)
|
109
114
|
ruby2_keywords (0.0.5)
|
110
115
|
simplecov (0.21.2)
|
@@ -113,13 +118,13 @@ GEM
|
|
113
118
|
simplecov_json_formatter (~> 0.1)
|
114
119
|
simplecov-html (0.12.3)
|
115
120
|
simplecov_json_formatter (0.1.4)
|
116
|
-
sinatra (2.2.
|
117
|
-
mustermann (~>
|
121
|
+
sinatra (2.2.2)
|
122
|
+
mustermann (~> 2.0)
|
118
123
|
rack (~> 2.2)
|
119
|
-
rack-protection (= 2.2.
|
124
|
+
rack-protection (= 2.2.2)
|
120
125
|
tilt (~> 2.0)
|
121
|
-
tilt (2.0.
|
122
|
-
unicode-display_width (2.
|
126
|
+
tilt (2.0.11)
|
127
|
+
unicode-display_width (2.2.0)
|
123
128
|
webrick (1.7.0)
|
124
129
|
yard (0.9.28)
|
125
130
|
webrick (~> 1.7.0)
|
data/lib/waylon/cache.rb
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Waylon
|
4
|
+
# Used for working with the Moneta store for caching
|
5
|
+
module Cache
|
6
|
+
DefaultStorage = Moneta.new(
|
7
|
+
:Redis,
|
8
|
+
url: "redis://#{ENV.fetch("REDIS", "localhost:6379")}/1"
|
9
|
+
)
|
10
|
+
|
11
|
+
def self.clear
|
12
|
+
storage.clear
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.delete(key)
|
16
|
+
storage.delete(key)
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.key?(name)
|
20
|
+
storage.key?(name)
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.load(key, expires: nil)
|
24
|
+
expires ? storage.load(key, expires: expires) : storage.load(key)
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.store(key, value, expires: nil)
|
28
|
+
if expires
|
29
|
+
storage.store(key, value, expires: expires)
|
30
|
+
else
|
31
|
+
storage.store(key, value)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.storage
|
36
|
+
@storage ||= DefaultStorage
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.storage=(storage)
|
40
|
+
@storage = storage
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
data/lib/waylon/core.rb
CHANGED
@@ -19,8 +19,7 @@ require "waylon/rspec/test_worker"
|
|
19
19
|
config = Waylon::Config.instance
|
20
20
|
config.load_env
|
21
21
|
|
22
|
-
Waylon::Cache = Moneta.new(:Cookie)
|
23
|
-
p Waylon::Storage
|
22
|
+
Waylon::Cache.storage = Moneta.new(:Cookie)
|
24
23
|
Waylon::Logger.log("Found Global Admins: #{config.admins}")
|
25
24
|
|
26
25
|
Waylon::RSpec::TestUser.find_or_create(
|
data/lib/waylon/rspec.rb
CHANGED
@@ -23,10 +23,10 @@ module Waylon
|
|
23
23
|
response << "*Skill plugins:*"
|
24
24
|
loaded_routes.each { |d| response << " - #{d}" }
|
25
25
|
response << "*Redis:*"
|
26
|
-
state, read_time, write_time = test_redis
|
26
|
+
state, raw_read_time, raw_write_time, read_time, write_time = test_redis
|
27
27
|
response << " - *Test Result:* #{state ? "Success" : "Error"}"
|
28
|
-
response << " - *Read time:* #{read_time}s"
|
29
|
-
response << " - *Write time:* #{write_time}s"
|
28
|
+
response << " - *Read time:* #{read_time}s (raw: #{raw_read_time}s)"
|
29
|
+
response << " - *Write time:* #{write_time}s (raw: #{raw_write_time}s)"
|
30
30
|
if Resque.redis.connected?
|
31
31
|
response << "*Queue Monitoring:*"
|
32
32
|
response << " - Failed jobs: #{Resque::Failure.count}"
|
@@ -43,17 +43,27 @@ module Waylon
|
|
43
43
|
SenseRegistry.instance.senses.map { |_s, c| c.name }.sort.uniq
|
44
44
|
end
|
45
45
|
|
46
|
-
def test_redis
|
47
|
-
|
46
|
+
def test_redis # rubocop:disable Metrics/AbcSize
|
47
|
+
test_key1 = ("a".."z").to_a.sample(10).join
|
48
|
+
test_key2 = ("a".."z").to_a.sample(10).join
|
48
49
|
test_value = (0..1000).to_a.sample(20).map(&:to_s).join
|
49
50
|
test_result = nil
|
50
51
|
|
51
|
-
|
52
|
-
|
52
|
+
raw_write_time = Benchmark.realtime { cache(test_key1) { test_value } }
|
53
|
+
raw_read_time = Benchmark.realtime { cache(test_key1) { test_value } }
|
54
|
+
enc_write_time = Benchmark.realtime { db.store(test_key2, test_value) }
|
55
|
+
enc_read_time = Benchmark.realtime { test_result = db.load(test_key2) }
|
53
56
|
|
54
|
-
db.delete(
|
57
|
+
db.delete(test_key1)
|
58
|
+
db.delete(test_key2)
|
55
59
|
|
56
|
-
[
|
60
|
+
[
|
61
|
+
(test_value == test_result),
|
62
|
+
raw_read_time.round(6),
|
63
|
+
raw_write_time.round(6),
|
64
|
+
enc_read_time.round(6),
|
65
|
+
enc_write_time.round(6)
|
66
|
+
]
|
57
67
|
end
|
58
68
|
end
|
59
69
|
end
|
data/lib/waylon/storage.rb
CHANGED
@@ -1,14 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
Waylon::Cache = Moneta.new(
|
4
|
-
:Redis,
|
5
|
-
url: "redis://#{ENV.fetch("REDIS", "localhost:6379")}/1"
|
6
|
-
)
|
7
|
-
|
8
3
|
module Waylon
|
9
4
|
# Used for working with the Moneta store
|
10
5
|
module Storage
|
11
|
-
|
6
|
+
DefaultStorage = Moneta.new(
|
12
7
|
:Redis,
|
13
8
|
url: "redis://#{ENV.fetch("REDIS", "localhost:6379")}/2"
|
14
9
|
)
|
@@ -19,16 +14,20 @@ module Waylon
|
|
19
14
|
end
|
20
15
|
|
21
16
|
def self.clear
|
22
|
-
|
17
|
+
storage.clear
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.delete(key)
|
21
|
+
storage.delete(key)
|
23
22
|
end
|
24
23
|
|
25
24
|
def self.key?(name)
|
26
|
-
|
25
|
+
storage.key?(name)
|
27
26
|
end
|
28
27
|
|
29
28
|
def self.load(key)
|
30
29
|
this_cipher = cipher
|
31
|
-
raw =
|
30
|
+
raw = storage.load(key)
|
32
31
|
return nil unless raw
|
33
32
|
|
34
33
|
decoded = Base64.decode64(raw)
|
@@ -36,11 +35,19 @@ module Waylon
|
|
36
35
|
JSON.parse(plain)
|
37
36
|
end
|
38
37
|
|
38
|
+
def self.storage
|
39
|
+
@storage ||= DefaultStorage
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.storage=(storage)
|
43
|
+
@storage = storage
|
44
|
+
end
|
45
|
+
|
39
46
|
def self.store(key, value)
|
40
47
|
this_cipher = cipher
|
41
48
|
encrypted = this_cipher.encrypt(value.to_json)
|
42
49
|
encoded = Base64.encode64(encrypted)
|
43
|
-
|
50
|
+
storage.store(key, encoded)
|
44
51
|
end
|
45
52
|
end
|
46
53
|
end
|
data/lib/waylon/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: waylon-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan Gnagy
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-08-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -261,6 +261,7 @@ files:
|
|
261
261
|
- bin/console
|
262
262
|
- bin/setup
|
263
263
|
- lib/waylon/base_component.rb
|
264
|
+
- lib/waylon/cache.rb
|
264
265
|
- lib/waylon/condition.rb
|
265
266
|
- lib/waylon/conditions/black_hole.rb
|
266
267
|
- lib/waylon/conditions/default.rb
|