Class: Waylon::Skills::Diagnostics
- Inherits:
-
Waylon::Skill
- Object
- Waylon::Skill
- Waylon::Skills::Diagnostics
- Defined in:
- lib/waylon/skills/diagnostics.rb
Overview
Built-in info routes
Instance Attribute Summary
Attributes inherited from Waylon::Skill
#request, #route, #sense, #tokens
Instance Method Summary collapse
- #loaded_routes ⇒ Object
- #loaded_senses ⇒ Object
-
#status ⇒ Object
Provides info about Waylon’s status.
-
#test_redis ⇒ Object
rubocop:disable Metrics/AbcSize.
Methods inherited from Waylon::Skill
#acknowledgement, #codify, config_namespace, #details, #initialize, #mention, #message, #named_tokens, perform, queue, #react, #reply, #reply_with_blocks, route, #threaded_reply
Methods included from BaseComponent
Constructor Details
This class inherits a constructor from Waylon::Skill
Instance Method Details
#loaded_routes ⇒ Object
38 39 40 |
# File 'lib/waylon/skills/diagnostics.rb', line 38 def loaded_routes SkillRegistry.instance.routes.map { |r| r.destination.name }.sort.uniq end |
#loaded_senses ⇒ Object
42 43 44 |
# File 'lib/waylon/skills/diagnostics.rb', line 42 def loaded_senses SenseRegistry.instance.senses.map { |_s, c| c.name }.sort.uniq end |
#status ⇒ Object
Provides info about Waylon’s status
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/waylon/skills/diagnostics.rb', line 18 def status # rubocop:disable Metrics/AbcSize response = [] response << "*Framework Version:* Waylon v#{Waylon::Core::VERSION}" response << "*Sense plugins:*" loaded_senses.each { |c| response << " - #{c}" } response << "*Skill plugins:*" loaded_routes.each { |d| response << " - #{d}" } response << "*Redis:*" state, raw_read_time, raw_write_time, read_time, write_time = test_redis response << " - *Test Result:* #{state ? "Success" : "Error"}" response << " - *Read time:* #{read_time}s (raw: #{raw_read_time}s)" response << " - *Write time:* #{write_time}s (raw: #{raw_write_time}s)" if Resque.redis.connected? response << "*Queue Monitoring:*" response << " - Failed jobs: #{Resque::Failure.count}" end reply response.join("\n") end |
#test_redis ⇒ Object
rubocop:disable Metrics/AbcSize
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/waylon/skills/diagnostics.rb', line 46 def test_redis # rubocop:disable Metrics/AbcSize test_key1 = ("a".."z").to_a.sample(10).join test_key2 = ("a".."z").to_a.sample(10).join test_value = (0..1000).to_a.sample(20).map(&:to_s).join test_result = nil raw_write_time = Benchmark.realtime { cache(test_key1) { test_value } } raw_read_time = Benchmark.realtime { cache(test_key1) { test_value } } enc_write_time = Benchmark.realtime { db.store(test_key2, test_value) } enc_read_time = Benchmark.realtime { test_result = db.load(test_key2) } db.delete(test_key1) db.delete(test_key2) [ (test_value == test_result), raw_read_time.round(6), raw_write_time.round(6), enc_read_time.round(6), enc_write_time.round(6) ] end |