arkaan 1.5.2 → 1.6.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cf94af22c1c55882c5232b5aa8db7aeae048ccfc91849318b04a3f19553f9f5f
|
4
|
+
data.tar.gz: adeb1a47fb02a84701f041a488b14205a1c9cf4975134d52fb13f49e242ebf77
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6494b1baaa4d884de245074401f5a15a03f8be88affdcda791cdf10b3692da9428d44ca3bab0cb4f80796e3cabd758e5307a6ae8e7654e8c0fdbba5525515f6a
|
7
|
+
data.tar.gz: edb13f0173ff449b29f57d4ff3965de7d9af90a6d1c5a85326203c50ffe9f741ad8ff18972a67ea2775c64114c9c2d8b987d40491afee7fb8f22468409e2adfd
|
data/lib/arkaan/monitoring.rb
CHANGED
@@ -7,6 +7,7 @@ module Arkaan
|
|
7
7
|
autoload :Instance , 'arkaan/monitoring/instance'
|
8
8
|
autoload :Route , 'arkaan/monitoring/route'
|
9
9
|
autoload :Service , 'arkaan/monitoring/service'
|
10
|
+
autoload :Vigilante, 'arkaan/monitoring/vigilante'
|
10
11
|
autoload :Websocket, 'arkaan/monitoring/websocket'
|
11
12
|
end
|
12
13
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Arkaan
|
2
|
+
module Monitoring
|
3
|
+
# A vigilante is a specific type of service that watches over the
|
4
|
+
# infrastructure and give a clear look at its global state.
|
5
|
+
# @author Vincent Courtois <courtois.vincent@outlook.com>
|
6
|
+
class Vigilante < Arkaan::Monitoring::Service
|
7
|
+
|
8
|
+
# @!attribute [rw] token
|
9
|
+
# @return [String] the token the vigilante uses to identify himself in the services
|
10
|
+
field :token, type: String
|
11
|
+
|
12
|
+
validates :token, presence: {message: 'required'}
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -26,6 +26,26 @@ module Arkaan
|
|
26
26
|
self.declare_route_with(verb, path, true, options, &block)
|
27
27
|
end
|
28
28
|
|
29
|
+
# Declares the status route of the service, used by the Vigilante to check its status
|
30
|
+
# @param path [String] the path used to map the route on.
|
31
|
+
def self.declare_status_route(path = '/status')
|
32
|
+
self.declare_route_with('get', path, false, { authanticated: false }) do
|
33
|
+
if params['token'].nil?
|
34
|
+
custom_error 400, 'vigilante.token.required'
|
35
|
+
elsif Arkaan::Monitoring::Vigilante.where(token: params[:token]).first.nil?
|
36
|
+
custom_error 404, 'vigilante.token.unknown'
|
37
|
+
end
|
38
|
+
service = Arkaan::Utils::MicroService.instance.service
|
39
|
+
informations = {
|
40
|
+
key: service.key,
|
41
|
+
path: service.path,
|
42
|
+
health: 'ok'
|
43
|
+
}
|
44
|
+
halt 200, informations.to_json
|
45
|
+
end
|
46
|
+
Arkaan::Utils::MicroService.instance.service.update_attribute(:diagnostic, path)
|
47
|
+
end
|
48
|
+
|
29
49
|
# Creates a route whithin the Sinatra application, and registers it in the database if it does not already exists.
|
30
50
|
# @param verb [String] the HTTP method used to create this route.
|
31
51
|
# @param path [String] the path, beginning with a /, of the route to create.
|
@@ -55,6 +75,7 @@ module Arkaan
|
|
55
75
|
else
|
56
76
|
self.public_send(verb, complete_path, &block)
|
57
77
|
end
|
78
|
+
complete_path
|
58
79
|
end
|
59
80
|
|
60
81
|
# Loads the errors configuration file from the config folder.
|
@@ -6,8 +6,15 @@ module Arkaan
|
|
6
6
|
class Checked < Arkaan::Utils::Controllers::Base
|
7
7
|
|
8
8
|
before do
|
9
|
+
pass if route_is_diagnostic?
|
9
10
|
before_checks
|
10
11
|
end
|
12
|
+
|
13
|
+
def route_is_diagnostic?
|
14
|
+
service = Arkaan::Utils::MicroService.instance.service
|
15
|
+
diagnostic = "#{service.path}#{service.diagnostic}"
|
16
|
+
request.path_info == diagnostic
|
17
|
+
end
|
11
18
|
end
|
12
19
|
end
|
13
20
|
end
|
@@ -146,7 +146,7 @@ module Arkaan
|
|
146
146
|
|
147
147
|
def load_mongoid_configuration(test_mode: false)
|
148
148
|
environment = test_mode ? 'test' : (ENV['RACK_ENV'] || 'development')
|
149
|
-
Mongoid.load!('config
|
149
|
+
Mongoid.load!(File.join(@location, 'config', 'mongoid.yml'), environment)
|
150
150
|
end
|
151
151
|
|
152
152
|
def load_standard_files
|
data/lib/arkaan/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: arkaan
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vincent Courtois
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-08-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -332,6 +332,7 @@ files:
|
|
332
332
|
- lib/arkaan/monitoring/instance.rb
|
333
333
|
- lib/arkaan/monitoring/route.rb
|
334
334
|
- lib/arkaan/monitoring/service.rb
|
335
|
+
- lib/arkaan/monitoring/vigilante.rb
|
335
336
|
- lib/arkaan/monitoring/websocket.rb
|
336
337
|
- lib/arkaan/notification.rb
|
337
338
|
- lib/arkaan/oauth.rb
|