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: 0e039bc7b87c996ca5b223e578161c649cd68ce9230580a580ac2162c6dbd302
4
- data.tar.gz: 04c8e8dc6c30467dd05a5523da86f6294956414eba9b8d0e10ab3dddebb8230a
3
+ metadata.gz: cf94af22c1c55882c5232b5aa8db7aeae048ccfc91849318b04a3f19553f9f5f
4
+ data.tar.gz: adeb1a47fb02a84701f041a488b14205a1c9cf4975134d52fb13f49e242ebf77
5
5
  SHA512:
6
- metadata.gz: 4a038e2756faf5fed3f24b72b8b9bcc6be1d9dc774ba6dcdc99ab3b6da64b3db3c7143415920173d0d05f937357949f01f3655cc668251888e3fa510dd299152
7
- data.tar.gz: 73a86435ff14dbc93a268bfa3300417f1351c40532f7ff3f0bc65b5c4cb00e228211271dcf2b40a4ec1d82fc7c62431b020552416d34a2d2a7ed0a79a048b12d
6
+ metadata.gz: 6494b1baaa4d884de245074401f5a15a03f8be88affdcda791cdf10b3692da9428d44ca3bab0cb4f80796e3cabd758e5307a6ae8e7654e8c0fdbba5525515f6a
7
+ data.tar.gz: edb13f0173ff449b29f57d4ff3965de7d9af90a6d1c5a85326203c50ffe9f741ad8ff18972a67ea2775c64114c9c2d8b987d40491afee7fb8f22468409e2adfd
@@ -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/mongoid.yml', environment)
149
+ Mongoid.load!(File.join(@location, 'config', 'mongoid.yml'), environment)
150
150
  end
151
151
 
152
152
  def load_standard_files
@@ -1,3 +1,3 @@
1
1
  module Arkaan
2
- VERSION = '1.5.2'
2
+ VERSION = '1.6.0'
3
3
  end
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.5.2
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-07-24 00:00:00.000000000 Z
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