status-page 0.1.3 → 0.1.4

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
  SHA1:
3
- metadata.gz: df1cc0468be3285f9d5ba755790a0ee26c2b84b0
4
- data.tar.gz: 398e134839b34f670b68ef7c2927e96e82f79bf6
3
+ metadata.gz: 52c384a41db820198ceabb23d287329bd7104c4c
4
+ data.tar.gz: 32ced89c5f80c3783fbb625c4bf5671c5be4b8b1
5
5
  SHA512:
6
- metadata.gz: ff7725d2662601b18b167d0cfd94df569a326bd55102dd274070fc6ab9d3833aa2556640fe74161d676387c229ded482cc1b6a724cef634307c85099a75e0c21
7
- data.tar.gz: 9bb450cedc1b560bd55695bd7340d7c3c5eb8e248217757c9de20c04cba838297426c08173a55189e2be1ff25604d2634acea8e7b35eff4d95982e531293b678
6
+ metadata.gz: 3ea6aa76924f33883ad37c37acd3c6228871f430f739dd7b2efad68c987965c1cec2d07989582cc3dcea6e6d1fb04700dacb7ae4a8e9f2114fc21c23decbc7ea
7
+ data.tar.gz: 0143b82d88d195c3aed4c61ebfc6a56e0549391290795e18f59374271a39009ccb4d8fa7aff9232b7875a350bc41c719906edecc539fdcef62c22d2c85b675e6
data/README.md CHANGED
@@ -52,6 +52,8 @@ StatusPage.configure do
52
52
  self.use :database
53
53
  self.use :cache
54
54
  self.use :redis
55
+ # Custom redis url
56
+ self.use :redis, url: 'redis://you-redis-host:3306/1'
55
57
  self.use :sidekiq
56
58
  end
57
59
  ```
@@ -8,9 +8,15 @@ module StatusPage
8
8
  @interval = 10
9
9
  end
10
10
 
11
- def use(service_name)
11
+ def use(service_name, opts = {})
12
12
  require "status-page/services/#{service_name}"
13
- add_service("StatusPage::Services::#{service_name.capitalize}".constantize)
13
+ klass = "StatusPage::Services::#{service_name.capitalize}".constantize
14
+ if klass.respond_to?(:configurable?) && klass.configurable?
15
+ opts.each_key do |key|
16
+ klass.config.send("#{key}=", opts[key])
17
+ end
18
+ end
19
+ add_service(klass)
14
20
  end
15
21
 
16
22
  def add_custom_service(custom_service_class)
@@ -2,24 +2,13 @@ module StatusPage
2
2
  module Services
3
3
  class Base
4
4
  attr_reader :request
5
- cattr_accessor :config
6
-
7
- def self.service_name
8
- @name ||= name.demodulize
9
- end
10
-
11
- def self.configure
12
- return unless configurable?
13
-
14
- self.config ||= config_class.new
15
-
16
- yield self.config if block_given?
17
- end
18
5
 
19
6
  def initialize(request: nil)
20
7
  @request = request
8
+ end
21
9
 
22
- self.class.configure
10
+ def self.service_name
11
+ @name ||= name.demodulize
23
12
  end
24
13
 
25
14
  # @abstract
@@ -27,6 +16,15 @@ module StatusPage
27
16
  raise NotImplementedError
28
17
  end
29
18
 
19
+ def self.config
20
+ return nil if !self.configurable?
21
+ @config ||= config_class.new
22
+ end
23
+
24
+ def config
25
+ self.class.config
26
+ end
27
+
30
28
  def self.configurable?
31
29
  config_class
32
30
  end
@@ -5,10 +5,24 @@ module StatusPage
5
5
  class RedisException < StandardError; end
6
6
 
7
7
  class Redis < Base
8
+ class Configuration
9
+ attr_accessor :url
10
+
11
+ def initialize
12
+ @url = "redis://127.0.0.1:3306/1"
13
+ end
14
+ end
15
+
16
+ class << self
17
+ def config_class
18
+ Redis::Configuration
19
+ end
20
+ end
21
+
8
22
  def check!
9
23
  time = Time.now.to_s(:db)
10
24
 
11
- redis = ::Redis.current
25
+ redis = ::Redis.new(url: config.url)
12
26
  redis.set(key, time)
13
27
  fetched = redis.get(key)
14
28
 
@@ -29,7 +29,7 @@ module StatusPage
29
29
  private
30
30
 
31
31
  def config_class
32
- Configuration
32
+ Sidekiq::Configuration
33
33
  end
34
34
  end
35
35
 
@@ -44,7 +44,6 @@ module StatusPage
44
44
  latency = ::Sidekiq::Queue.new.latency
45
45
 
46
46
  return unless latency > config.latency
47
-
48
47
  raise "latency #{latency} is greater than #{config.latency}"
49
48
  end
50
49
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module StatusPage
4
- VERSION = '0.1.3'
4
+ VERSION = '0.1.4'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: status-page
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Leonid Beder
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-04-08 00:00:00.000000000 Z
12
+ date: 2016-11-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -70,7 +70,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
70
70
  version: '0'
71
71
  requirements: []
72
72
  rubyforge_project:
73
- rubygems_version: 2.6.2
73
+ rubygems_version: 2.5.2
74
74
  signing_key:
75
75
  specification_version: 4
76
76
  summary: Health monitoring Rails plug-in, which checks various services (db, cache,