waylon-core 0.1.6 → 0.2.0

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: 57bed2ca4c2e97caf912ff316be213e191605c61d2934a1a2cd590013a28cfa2
4
- data.tar.gz: 6e32bf09330d75603b7340f18a58bc9a16d373097d91c2a082ff5fea8a4cb5b8
3
+ metadata.gz: 404fb7180c3c7b52c2bb3637fd3fb86d28cd5b4b1f1791e8b2fe0f94d7788ea9
4
+ data.tar.gz: 6b1da741b15a5092cddf65e81623a348454289ecb496eef1dfee081e79bb5f0e
5
5
  SHA512:
6
- metadata.gz: 05bc6522ee2cda61c80dbabeb52a624d3301e6be562ebc575f4508e7537cfa212ba8f8b0f0d14ce4607852dd30162c93d5494325eac4bffe1c0e6f923492c31f
7
- data.tar.gz: 8537c32ded411934c548b4aa47ca8a03dcf3ed502a927357f25932166f555d0224948776d1226865bea5b01d94deb300081ede84075a64a073eb535175059817
6
+ metadata.gz: f4852c99d93a726be2e21ec1a1cdf9fdf758508b09fed717ea1642b2f92c9c9adfe84e8fb922107f751859d2e3a331521d32f492911ffb6f5d82935a0ceef032
7
+ data.tar.gz: 03747526f39170835b3ab67ffc294a3e3c914968001b40e24eb5ddcd74fb2746c28ca7bb95288ab67523cf25018fe9709aa16956a54ab507839b1fe05a252771
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- waylon-core (0.1.6)
4
+ waylon-core (0.2.0)
5
5
  addressable (~> 2.8)
6
6
  faraday (~> 1.8)
7
7
  i18n (~> 1.8)
@@ -50,7 +50,7 @@ GEM
50
50
  moneta (1.5.1)
51
51
  mono_logger (1.1.1)
52
52
  multi_json (1.15.0)
53
- multipart-post (2.2.0)
53
+ multipart-post (2.2.3)
54
54
  mustermann (1.1.1)
55
55
  ruby2_keywords (~> 0.0.1)
56
56
  nio4r (2.5.8)
data/lib/waylon/config.rb CHANGED
@@ -32,11 +32,10 @@ module Waylon
32
32
 
33
33
  # Load in the config from env variables
34
34
  # @return [Boolean] Was the configuration loaded?
35
- def load_env # rubocop:disable Metrics/AbcSize
35
+ def load_env
36
36
  @schema ||= {}
37
37
  self["global.log.level"] = ENV.fetch("LOG_LEVEL", "info")
38
- self["global.redis.host"] = ENV.fetch("REDIS_HOST", "redis")
39
- self["global.redis.port"] = ENV.fetch("REDIS_PORT", "6379")
38
+ self["global.redis"] = ENV.fetch("REDIS", "localhost:6379")
40
39
  self["global.admins"] = ENV.fetch("GLOBAL_ADMINS", "")
41
40
  ENV.keys.grep(/CONF_/).each do |env_key|
42
41
  conf_key = env_key.downcase.split("_")[1..].join(".")
@@ -49,13 +48,13 @@ module Waylon
49
48
  # Provides the redis host used for most of Waylon's brain
50
49
  # @return [String] The redis host
51
50
  def redis_host
52
- self["global.redis.host"]
51
+ self["global.redis"].split(":").first
53
52
  end
54
53
 
55
54
  # Provides the redis port used for most of Waylon's brain
56
55
  # @return [String] The redis host
57
56
  def redis_port
58
- self["global.redis.port"]
57
+ self["global.redis"].split(":").last
59
58
  end
60
59
 
61
60
  # Clear the configuration
@@ -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
- test_key = ("a".."z").to_a.sample(10).join
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
- write_time = Benchmark.realtime { db.store(test_key, test_value) }
52
- read_time = Benchmark.realtime { test_result = db.load(test_key) }
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(test_key)
57
+ db.delete(test_key1)
58
+ db.delete(test_key2)
55
59
 
56
- [(test_value == test_result), read_time.round(6), write_time.round(6)]
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
@@ -1,11 +1,16 @@
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
+
3
8
  module Waylon
4
9
  # Used for working with the Moneta store
5
10
  module Storage
6
11
  Store = Moneta.new(
7
12
  :Redis,
8
- url: "redis://#{ENV.fetch("REDIS", "localhost:6379")}/1"
13
+ url: "redis://#{ENV.fetch("REDIS", "localhost:6379")}/2"
9
14
  )
10
15
 
11
16
  def self.cipher
@@ -17,6 +22,10 @@ module Waylon
17
22
  Store.clear
18
23
  end
19
24
 
25
+ def self.delete(key)
26
+ Store.delete(key)
27
+ end
28
+
20
29
  def self.key?(name)
21
30
  Store.key?(name)
22
31
  end
@@ -5,8 +5,8 @@ module Waylon
5
5
  # The Waylon::Core version
6
6
  VERSION = [
7
7
  0, # Major
8
- 1, # Minor
9
- 6 # Patch
8
+ 2, # Minor
9
+ 0 # Patch
10
10
  ].join(".")
11
11
  end
12
12
  end
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.1.6
4
+ version: 0.2.0
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-06-17 00:00:00.000000000 Z
11
+ date: 2022-06-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable