arkaan 2.5.0 → 2.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/arkaan.rb +1 -0
- data/lib/arkaan/account.rb +0 -3
- data/lib/arkaan/campaign.rb +9 -3
- data/lib/arkaan/campaigns/invitation.rb +13 -6
- data/lib/arkaan/campaigns/tag.rb +4 -4
- data/lib/arkaan/concerns.rb +1 -0
- data/lib/arkaan/concerns/enumerable.rb +5 -1
- data/lib/arkaan/concerns/historizable.rb +62 -0
- data/lib/arkaan/event.rb +29 -0
- data/lib/arkaan/monitoring.rb +2 -8
- data/lib/arkaan/monitoring/service.rb +2 -8
- data/lib/arkaan/oauth/access_token.rb +9 -2
- data/lib/arkaan/oauth/authorization.rb +4 -1
- data/lib/arkaan/version.rb +1 -1
- metadata +62 -53
- data/lib/arkaan/monitoring/action.rb +0 -25
- data/lib/arkaan/monitoring/instance.rb +0 -38
- data/lib/arkaan/monitoring/results.rb +0 -10
- data/lib/arkaan/monitoring/results/heartbeat.rb +0 -50
- data/lib/arkaan/monitoring/results/report.rb +0 -46
- data/lib/arkaan/monitoring/vigilante.rb +0 -48
- data/lib/arkaan/monitoring/websocket.rb +0 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 49b4f5f61273d5bb04c52296fbd6d98d2132e960872d2f3ef13c0abb9843f16c
|
4
|
+
data.tar.gz: 2f6a9767b394c101937eee1275116c034a5aec3152ecd55a81f27d771cf2619e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 988474c07ee9facdd07b1d5e29baaadfbe65c68b4b7dd9b6c85474f4bdf31363205d85a5dc91e3a298d10ef436317922953b5867699165b84986911caf4b8186
|
7
|
+
data.tar.gz: aaa639ed45955ca052dc7aea2fec0090b9e6fc9d8c69afb2ed1258f5b161e902a96593124848666fa4c340626b240455a09428bca1da4250a061c10e4e44a817
|
data/lib/arkaan.rb
CHANGED
@@ -13,6 +13,7 @@ module Arkaan
|
|
13
13
|
autoload :Chatroom , 'arkaan/chatroom'
|
14
14
|
autoload :Chatrooms , 'arkaan/chatrooms'
|
15
15
|
autoload :Concerns , 'arkaan/concerns'
|
16
|
+
autoload :Event , 'arkaan/event'
|
16
17
|
autoload :Factories , 'arkaan/factories'
|
17
18
|
autoload :Files , 'arkaan/files'
|
18
19
|
autoload :Monitoring , 'arkaan/monitoring'
|
data/lib/arkaan/account.rb
CHANGED
@@ -57,9 +57,6 @@ module Arkaan
|
|
57
57
|
# @!attribute [rw] invitations
|
58
58
|
# @return [Array<Arkaan::Campaigns::Invitation>] the invitations you've issued yourself to other players.
|
59
59
|
has_many :created_invitations, class_name: 'Arkaan::Campaigns::Invitation', inverse_of: :creator
|
60
|
-
# @!attribute [rw] websockets
|
61
|
-
# @return [Array<Arkaan::Monitoring::Websocket>] the websockets created by the owner of this account.
|
62
|
-
has_many :websockets, class_name: 'Arkaan::Monitoring::Websocket', inverse_of: :creator
|
63
60
|
# @!attribute [rw] permissions
|
64
61
|
# @return [Array<Arkaan::Files::Permission>] the file access permissions granted to this account.
|
65
62
|
has_many :permissions, class_name: 'Arkaan::Files::Permission', inverse_of: :account
|
data/lib/arkaan/campaign.rb
CHANGED
@@ -51,14 +51,18 @@ module Arkaan
|
|
51
51
|
# @param account [Arkaan::Account] the account of the creator for this campaign.
|
52
52
|
def creator=(account)
|
53
53
|
if !invitations.where(account: account).exists?
|
54
|
-
Arkaan::Campaigns::Invitation.create(
|
54
|
+
invitation = Arkaan::Campaigns::Invitation.create(
|
55
|
+
campaign: self,
|
56
|
+
account: account,
|
57
|
+
status: :creator
|
58
|
+
)
|
55
59
|
end
|
56
60
|
end
|
57
61
|
|
58
62
|
# Getter for the creator account of this campaign.
|
59
63
|
# @return [Arkaan::Account] the account of the player creating this campaign.
|
60
64
|
def creator
|
61
|
-
|
65
|
+
invitations.to_a.find(&:status_creator?).account
|
62
66
|
end
|
63
67
|
|
64
68
|
# Adds an error message if the account creating this campaign already has a campaign with the very same name.
|
@@ -83,7 +87,9 @@ module Arkaan
|
|
83
87
|
|
84
88
|
# @return [Array<Arkaan::Campaigns::Invitation>] the players in this campaign.
|
85
89
|
def players
|
86
|
-
invitations.
|
90
|
+
invitations.to_a.select do |invitation|
|
91
|
+
[:creator, :accepted].include? invitation.enum_status
|
92
|
+
end
|
87
93
|
end
|
88
94
|
|
89
95
|
# @return [Integer] the number of players in this campaign.
|
@@ -1,15 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Arkaan
|
2
4
|
module Campaigns
|
3
|
-
# An invitation is the linked between a player and a campaign
|
5
|
+
# An invitation is the linked between a player and a campaign.
|
6
|
+
# It keeps the history of the interaction between the player and the campaign.
|
7
|
+
#
|
4
8
|
# @author Vincent Courtois <courtois.vincent@outlook.com>
|
5
9
|
class Invitation
|
6
10
|
include Mongoid::Document
|
7
11
|
include Mongoid::Timestamps
|
8
12
|
include Arkaan::Concerns::Enumerable
|
9
|
-
|
10
|
-
# @!attribute [rw] status
|
11
|
-
# @return [Symbol] the current status of the invitation.
|
12
|
-
enum_field :status, [:accepted, :blocked, :expelled, :ignored, :left, :pending, :refused, :request, :creator], default: :pending
|
13
|
+
include Arkaan::Concerns::Historizable
|
13
14
|
|
14
15
|
# @!attribute [rw] account
|
15
16
|
# @return [Arkaan::Account] the account the invitation has been issued to.
|
@@ -17,6 +18,12 @@ module Arkaan
|
|
17
18
|
# @!attribute [rw] campaign
|
18
19
|
# @return [Arkaan::Campaign] the campaign the invitation has been made in.
|
19
20
|
belongs_to :campaign, class_name: 'Arkaan::Campaign', inverse_of: :invitations
|
21
|
+
|
22
|
+
# @!attribute [rw] status
|
23
|
+
# @return [Symbol] the current status of the invitation.
|
24
|
+
historize enum_field :status,
|
25
|
+
[:pending, :request, :accepted, :refused, :expelled, :left, :master, :creator],
|
26
|
+
default: :pending
|
20
27
|
end
|
21
28
|
end
|
22
|
-
end
|
29
|
+
end
|
data/lib/arkaan/campaigns/tag.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Arkaan
|
2
4
|
module Campaigns
|
3
5
|
# A campaign tag is a string describing a characteristic of the campaign it's in.
|
@@ -13,9 +15,7 @@ module Arkaan
|
|
13
15
|
# @return [Integer] the number of campaigns this tag is in, avoiding a join.
|
14
16
|
field :count, type: Integer, default: 1
|
15
17
|
|
16
|
-
validates :content,
|
17
|
-
presence: {message: 'required'},
|
18
|
-
uniqueness: {message: 'uniq'}
|
18
|
+
validates :content, presence: { message: 'required' }, uniqueness: { message: 'uniq' }
|
19
19
|
end
|
20
20
|
end
|
21
|
-
end
|
21
|
+
end
|
data/lib/arkaan/concerns.rb
CHANGED
@@ -5,6 +5,7 @@ module Arkaan
|
|
5
5
|
autoload :Activable , 'arkaan/concerns/activable'
|
6
6
|
autoload :Diagnosticable, 'arkaan/concerns/diagnosticable'
|
7
7
|
autoload :Enumerable , 'arkaan/concerns/enumerable'
|
8
|
+
autoload :Historizable , 'arkaan/concerns/historizable'
|
8
9
|
autoload :MimeTypable , 'arkaan/concerns/mime_typable'
|
9
10
|
autoload :Premiumable , 'arkaan/concerns/premiumable'
|
10
11
|
autoload :Sluggable , 'arkaan/concerns/sluggable'
|
@@ -14,7 +14,7 @@ module Arkaan
|
|
14
14
|
# @param values [Array<Symbol>] the possible values of the enumerated field.
|
15
15
|
# @param options [Hash<Symbol, Any>] the possible options for the field.
|
16
16
|
def enum_field(field_name, values, options = {})
|
17
|
-
field :"enum_#{field_name}", type: Symbol, default: options[:default]
|
17
|
+
returned = field :"enum_#{field_name}", type: Symbol, default: options[:default]
|
18
18
|
|
19
19
|
validates :"enum_#{field_name}", inclusion: {in: values.map(&:to_sym), message: 'inclusion'}
|
20
20
|
|
@@ -37,6 +37,10 @@ module Arkaan
|
|
37
37
|
self["enum_#{field_name}"] == value
|
38
38
|
end
|
39
39
|
end
|
40
|
+
|
41
|
+
# This is to make enumerations historizable by
|
42
|
+
# returning the field object created by Mongoid.
|
43
|
+
returned
|
40
44
|
end
|
41
45
|
end
|
42
46
|
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Arkaan
|
4
|
+
module Concerns
|
5
|
+
# This module is what I call "a beautiful piece of Ruby engineering"
|
6
|
+
# It takes any mongoid field that you may have declared, and historizes
|
7
|
+
# it in a dedicated relation if this relation does not already exists.
|
8
|
+
#
|
9
|
+
# What it does exactly :
|
10
|
+
# - Creates the :history relation if it does not already exists.
|
11
|
+
# - Creates a method to check for changes of a specific attribute.
|
12
|
+
# - Check for changes at initialization to insert the first value.
|
13
|
+
# - Check for changes at update/save to store the history.
|
14
|
+
#
|
15
|
+
# @author Vincent Courtois <courtois.vincent@outlook.com>
|
16
|
+
module Historizable
|
17
|
+
extend ActiveSupport::Concern
|
18
|
+
|
19
|
+
# Adds an entry in the history table for the given field.
|
20
|
+
# It checks several things to make the history entry valid :
|
21
|
+
# - the new value is different from the old value
|
22
|
+
# - the old value is identical to the last recorded new value.
|
23
|
+
#
|
24
|
+
# @param field [String] the name of the field to historize
|
25
|
+
# @param from [Any] the old value before update
|
26
|
+
# @param to [Any] the new value after update.
|
27
|
+
def add_history(field:, from:, to:)
|
28
|
+
return if from == to
|
29
|
+
return if !history.empty? && history.order_by(:created_at.desc).first.to != from
|
30
|
+
|
31
|
+
event = Arkaan::Event.create(field: field, from: from, to: to, document: self)
|
32
|
+
event.save
|
33
|
+
end
|
34
|
+
|
35
|
+
# Submodule holding all the static methods add to the current subclass.
|
36
|
+
# @author Vincent Courtois <courtois.vincent@outlook.com>
|
37
|
+
module ClassMethods
|
38
|
+
|
39
|
+
# Takes the Mongoid declared field and creates the callbacks
|
40
|
+
# to intercept any value change and add it to the history.
|
41
|
+
# @field field [Mongoid::Fields::Standard] the Mongoid field to historize.
|
42
|
+
def historize(field)
|
43
|
+
|
44
|
+
unless relations.key?('history')
|
45
|
+
embeds_many :history, class_name: 'Arkaan::Event'
|
46
|
+
end
|
47
|
+
|
48
|
+
after_initialize do |doc|
|
49
|
+
add_history(field: field.name, from: nil, to: doc[field.name])
|
50
|
+
end
|
51
|
+
|
52
|
+
after_save do |doc|
|
53
|
+
if doc.changed_attributes.key?(field.name)
|
54
|
+
from = doc.changed_attributes[field.name]
|
55
|
+
add_history(field: field.name, from: from, to: doc[field.name])
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
data/lib/arkaan/event.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Arkaan
|
4
|
+
# An event is symbolizing a timestamped change in a model.
|
5
|
+
# It is recommended NOT to use this class directly but to use
|
6
|
+
# the Arkaan::Concerns::Historizable concern in a model.
|
7
|
+
#
|
8
|
+
# @author Vincent Courtois <courtois.vincent@outlook.com>
|
9
|
+
class Event
|
10
|
+
include Mongoid::Document
|
11
|
+
include Mongoid::Timestamps
|
12
|
+
|
13
|
+
# @!attribute [rw] field
|
14
|
+
# @return [String] the name of the field being historized
|
15
|
+
field :field, type: String
|
16
|
+
# @!attribute [rw] from
|
17
|
+
# @return [Any] the value of the field before update
|
18
|
+
field :from
|
19
|
+
# @!attribute [rw] to
|
20
|
+
# @return [Any] the value of the field after update
|
21
|
+
field :to
|
22
|
+
|
23
|
+
# @!attribute [rw] document
|
24
|
+
# @return [Any] the model in which the history is embedded
|
25
|
+
embedded_in :document, polymorphic: true, inverse_of: :history
|
26
|
+
|
27
|
+
validates :field, presence: { message: 'required' }
|
28
|
+
end
|
29
|
+
end
|
data/lib/arkaan/monitoring.rb
CHANGED
@@ -2,13 +2,7 @@ module Arkaan
|
|
2
2
|
# The monitoring module holds all the logic about the services so they can be activated or deactivated.
|
3
3
|
# @author Vincent Courtois <courtois.vincent@outlook.com>
|
4
4
|
module Monitoring
|
5
|
-
autoload :
|
6
|
-
autoload :
|
7
|
-
autoload :Instance , 'arkaan/monitoring/instance'
|
8
|
-
autoload :Results , 'arkaan/monitoring/results'
|
9
|
-
autoload :Route , 'arkaan/monitoring/route'
|
10
|
-
autoload :Service , 'arkaan/monitoring/service'
|
11
|
-
autoload :Vigilante, 'arkaan/monitoring/vigilante'
|
12
|
-
autoload :Websocket, 'arkaan/monitoring/websocket'
|
5
|
+
autoload :Route , 'arkaan/monitoring/route'
|
6
|
+
autoload :Service, 'arkaan/monitoring/service'
|
13
7
|
end
|
14
8
|
end
|
@@ -10,21 +10,15 @@ module Arkaan
|
|
10
10
|
include Arkaan::Concerns::Premiumable
|
11
11
|
|
12
12
|
# @!attribute [rw] key
|
13
|
-
# @return [String] the name
|
13
|
+
# @return [String] the name of the service, used as a namespace on the Kubernetes side.
|
14
14
|
field :key, type: String
|
15
15
|
# @!attribute [rw] path
|
16
|
-
# @return [String] the path the service will be mapped on in the API.
|
16
|
+
# @return [String] the path the service will be mapped on in the API. This will be used in the Ingress.
|
17
17
|
field :path, type: String, default: '/'
|
18
|
-
# @!attribute [rw] test_mode
|
19
|
-
# @return [Boolean] TRUE if the service is currently in test mode and thus the gateway shall only qurty local instances.
|
20
|
-
field :test_mode, type: Boolean, default: false
|
21
18
|
|
22
19
|
# @!attribute [rw] creator
|
23
20
|
# @return [Arkaan::Account] the creator of this service.
|
24
21
|
belongs_to :creator, class_name: 'Arkaan::Account', optional: true, inverse_of: :services
|
25
|
-
# @!attribute [rw] instances
|
26
|
-
# @return [Array<Arkaan::Monitoring::Instance>] the instances of this service currently deployed.
|
27
|
-
embeds_many :instances, class_name: 'Arkaan::Monitoring::Instance', inverse_of: :service
|
28
22
|
# @!attribute [rw] routes
|
29
23
|
# @return [Array<Arkaan::Monitoring::Route>] the routes associated to this service, accessible from the gateway.
|
30
24
|
has_many :routes, class_name: 'Arkaan::Monitoring::Route', inverse_of: :service
|
@@ -1,6 +1,7 @@
|
|
1
1
|
module Arkaan
|
2
2
|
module OAuth
|
3
|
-
# An access token is the value assigned to the application
|
3
|
+
# An access token is the value assigned to the application
|
4
|
+
# to access the data the user is allowed to access.
|
4
5
|
# @author Vincent Courtois <courtois.vincent@outlook.com>
|
5
6
|
class AccessToken
|
6
7
|
include Mongoid::Document
|
@@ -15,11 +16,17 @@ module Arkaan
|
|
15
16
|
|
16
17
|
# @!attribute [rw] authorization
|
17
18
|
# @return [Arkaan::OAuth::Authorization] the authorization code that issued this token to the application for this user.
|
18
|
-
belongs_to :authorization, class_name: 'Arkaan::OAuth::Authorization', inverse_of: :
|
19
|
+
belongs_to :authorization, class_name: 'Arkaan::OAuth::Authorization', inverse_of: :tokens
|
19
20
|
|
20
21
|
validates :value,
|
21
22
|
presence: {message: 'required'},
|
22
23
|
uniqueness: {message: 'uniq'}
|
24
|
+
|
25
|
+
# Checks if the current date is inferior to the creation date + expiration period
|
26
|
+
# @return [Boolean] TRUE if the token is expired, FALSE otherwise.
|
27
|
+
def expired?
|
28
|
+
created_at.to_time.to_i + expiration < Time.now.to_i
|
29
|
+
end
|
23
30
|
end
|
24
31
|
end
|
25
32
|
end
|
@@ -1,6 +1,9 @@
|
|
1
1
|
module Arkaan
|
2
2
|
module OAuth
|
3
3
|
# An OAuth authorization is granted by a user to an application to access its personal data.
|
4
|
+
# The application then transforms it into an access token to be able to send it with
|
5
|
+
# further requests, so that we know the user has authorized the application to access its data.
|
6
|
+
#
|
4
7
|
# @author Vincent Courtois <courtois.vincent@outlook.com>
|
5
8
|
class Authorization
|
6
9
|
include Mongoid::Document
|
@@ -18,7 +21,7 @@ module Arkaan
|
|
18
21
|
belongs_to :application, class_name: 'Arkaan::OAuth::Application', inverse_of: :authorizations
|
19
22
|
# @!attribute [rw] token
|
20
23
|
# @return [Arkaan::OAuth::AccessToken] the access token used further in the application process to access private data of the account.
|
21
|
-
|
24
|
+
has_many :tokens, class_name: 'Arkaan::OAuth::AccessToken', inverse_of: :authorization
|
22
25
|
|
23
26
|
validates :code,
|
24
27
|
presence: {message: 'required'},
|
data/lib/arkaan/version.rb
CHANGED
metadata
CHANGED
@@ -1,239 +1,253 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: arkaan
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.7.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vincent Courtois
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-09-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: database_cleaner
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 1.6.1
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 1.6.1
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: factory_bot
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - '='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 6.1.0
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - '='
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 6.1.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: factory_girl
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - '='
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 4.8.1
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - '='
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 4.8.1
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: faker
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - '='
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 2.13.0
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - '='
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 2.13.0
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: pry
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - '='
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
75
|
+
version: 0.13.1
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - '='
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
82
|
+
version: 0.13.1
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
84
|
+
name: rack
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - '='
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
89
|
+
version: 2.2.3
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - '='
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
96
|
+
version: 2.2.3
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
98
|
+
name: rack-test
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - '='
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
103
|
+
version: 1.1.0
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - '='
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version:
|
110
|
+
version: 1.1.0
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
|
-
name:
|
112
|
+
name: rspec
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
115
|
- - '='
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version:
|
117
|
+
version: 3.9.0
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
122
|
- - '='
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version:
|
124
|
+
version: 3.9.0
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
|
-
name:
|
126
|
+
name: rspec-json_expectations
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
129
|
- - '='
|
130
130
|
- !ruby/object:Gem::Version
|
131
|
-
version:
|
131
|
+
version: 2.1.0
|
132
132
|
type: :development
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
136
|
- - '='
|
137
137
|
- !ruby/object:Gem::Version
|
138
|
-
version:
|
138
|
+
version: 2.1.0
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
|
-
name:
|
140
|
+
name: rubocop
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
142
142
|
requirements:
|
143
143
|
- - '='
|
144
144
|
- !ruby/object:Gem::Version
|
145
|
-
version:
|
145
|
+
version: 0.90.0
|
146
146
|
type: :development
|
147
147
|
prerelease: false
|
148
148
|
version_requirements: !ruby/object:Gem::Requirement
|
149
149
|
requirements:
|
150
150
|
- - '='
|
151
151
|
- !ruby/object:Gem::Version
|
152
|
-
version:
|
152
|
+
version: 0.90.0
|
153
153
|
- !ruby/object:Gem::Dependency
|
154
|
-
name:
|
154
|
+
name: simplecov
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - '='
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: 0.19.0
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - '='
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: 0.19.0
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: yard
|
155
169
|
requirement: !ruby/object:Gem::Requirement
|
156
170
|
requirements:
|
157
171
|
- - '='
|
158
172
|
- !ruby/object:Gem::Version
|
159
|
-
version:
|
173
|
+
version: 0.9.25
|
160
174
|
type: :development
|
161
175
|
prerelease: false
|
162
176
|
version_requirements: !ruby/object:Gem::Requirement
|
163
177
|
requirements:
|
164
178
|
- - '='
|
165
179
|
- !ruby/object:Gem::Version
|
166
|
-
version:
|
180
|
+
version: 0.9.25
|
167
181
|
- !ruby/object:Gem::Dependency
|
168
182
|
name: mongoid
|
169
183
|
requirement: !ruby/object:Gem::Requirement
|
170
184
|
requirements:
|
171
185
|
- - '='
|
172
186
|
- !ruby/object:Gem::Version
|
173
|
-
version: 7.0
|
187
|
+
version: 7.1.0
|
174
188
|
type: :runtime
|
175
189
|
prerelease: false
|
176
190
|
version_requirements: !ruby/object:Gem::Requirement
|
177
191
|
requirements:
|
178
192
|
- - '='
|
179
193
|
- !ruby/object:Gem::Version
|
180
|
-
version: 7.0
|
194
|
+
version: 7.1.0
|
181
195
|
- !ruby/object:Gem::Dependency
|
182
196
|
name: activemodel
|
183
197
|
requirement: !ruby/object:Gem::Requirement
|
184
198
|
requirements:
|
185
199
|
- - '='
|
186
200
|
- !ruby/object:Gem::Version
|
187
|
-
version:
|
201
|
+
version: 6.0.3.2
|
188
202
|
type: :runtime
|
189
203
|
prerelease: false
|
190
204
|
version_requirements: !ruby/object:Gem::Requirement
|
191
205
|
requirements:
|
192
206
|
- - '='
|
193
207
|
- !ruby/object:Gem::Version
|
194
|
-
version:
|
208
|
+
version: 6.0.3.2
|
195
209
|
- !ruby/object:Gem::Dependency
|
196
210
|
name: activesupport
|
197
211
|
requirement: !ruby/object:Gem::Requirement
|
198
212
|
requirements:
|
199
213
|
- - '='
|
200
214
|
- !ruby/object:Gem::Version
|
201
|
-
version:
|
215
|
+
version: 6.0.3.2
|
202
216
|
type: :runtime
|
203
217
|
prerelease: false
|
204
218
|
version_requirements: !ruby/object:Gem::Requirement
|
205
219
|
requirements:
|
206
220
|
- - '='
|
207
221
|
- !ruby/object:Gem::Version
|
208
|
-
version:
|
222
|
+
version: 6.0.3.2
|
209
223
|
- !ruby/object:Gem::Dependency
|
210
224
|
name: bcrypt
|
211
225
|
requirement: !ruby/object:Gem::Requirement
|
212
226
|
requirements:
|
213
227
|
- - '='
|
214
228
|
- !ruby/object:Gem::Version
|
215
|
-
version: 3.1.
|
229
|
+
version: 3.1.13
|
216
230
|
type: :runtime
|
217
231
|
prerelease: false
|
218
232
|
version_requirements: !ruby/object:Gem::Requirement
|
219
233
|
requirements:
|
220
234
|
- - '='
|
221
235
|
- !ruby/object:Gem::Version
|
222
|
-
version: 3.1.
|
236
|
+
version: 3.1.13
|
223
237
|
- !ruby/object:Gem::Dependency
|
224
238
|
name: dotenv
|
225
239
|
requirement: !ruby/object:Gem::Requirement
|
226
240
|
requirements:
|
227
241
|
- - '='
|
228
242
|
- !ruby/object:Gem::Version
|
229
|
-
version: 2.7.
|
243
|
+
version: 2.7.6
|
230
244
|
type: :runtime
|
231
245
|
prerelease: false
|
232
246
|
version_requirements: !ruby/object:Gem::Requirement
|
233
247
|
requirements:
|
234
248
|
- - '='
|
235
249
|
- !ruby/object:Gem::Version
|
236
|
-
version: 2.7.
|
250
|
+
version: 2.7.6
|
237
251
|
description: This gem holds the model layer for my table-top RPG games application.
|
238
252
|
email: courtois.vincent@outlook.com
|
239
253
|
executables: []
|
@@ -258,6 +272,7 @@ files:
|
|
258
272
|
- lib/arkaan/concerns/activable.rb
|
259
273
|
- lib/arkaan/concerns/diagnosticable.rb
|
260
274
|
- lib/arkaan/concerns/enumerable.rb
|
275
|
+
- lib/arkaan/concerns/historizable.rb
|
261
276
|
- lib/arkaan/concerns/mime_typable.rb
|
262
277
|
- lib/arkaan/concerns/premiumable.rb
|
263
278
|
- lib/arkaan/concerns/sluggable.rb
|
@@ -265,6 +280,7 @@ files:
|
|
265
280
|
- lib/arkaan/decorators/errors.rb
|
266
281
|
- lib/arkaan/decorators/errors/env_variable_missing.rb
|
267
282
|
- lib/arkaan/decorators/gateway.rb
|
283
|
+
- lib/arkaan/event.rb
|
268
284
|
- lib/arkaan/factories.rb
|
269
285
|
- lib/arkaan/factories/errors.rb
|
270
286
|
- lib/arkaan/factories/errors/gateway_not_found.rb
|
@@ -272,15 +288,8 @@ files:
|
|
272
288
|
- lib/arkaan/files/document.rb
|
273
289
|
- lib/arkaan/files/permission.rb
|
274
290
|
- lib/arkaan/monitoring.rb
|
275
|
-
- lib/arkaan/monitoring/action.rb
|
276
|
-
- lib/arkaan/monitoring/instance.rb
|
277
|
-
- lib/arkaan/monitoring/results.rb
|
278
|
-
- lib/arkaan/monitoring/results/heartbeat.rb
|
279
|
-
- lib/arkaan/monitoring/results/report.rb
|
280
291
|
- lib/arkaan/monitoring/route.rb
|
281
292
|
- lib/arkaan/monitoring/service.rb
|
282
|
-
- lib/arkaan/monitoring/vigilante.rb
|
283
|
-
- lib/arkaan/monitoring/websocket.rb
|
284
293
|
- lib/arkaan/notification.rb
|
285
294
|
- lib/arkaan/oauth.rb
|
286
295
|
- lib/arkaan/oauth/access_token.rb
|
@@ -312,7 +321,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
312
321
|
- !ruby/object:Gem::Version
|
313
322
|
version: '0'
|
314
323
|
requirements: []
|
315
|
-
rubygems_version: 3.
|
324
|
+
rubygems_version: 3.0.6
|
316
325
|
signing_key:
|
317
326
|
specification_version: 4
|
318
327
|
summary: The model layer for my table-RPG application
|
@@ -1,25 +0,0 @@
|
|
1
|
-
module Arkaan
|
2
|
-
module Monitoring
|
3
|
-
# An action is made by an authorized user on the instance of a server to perform a task.
|
4
|
-
# @author Vincent Courtois <courtois.vincent@outlook.com>
|
5
|
-
class Action
|
6
|
-
include Mongoid::Document
|
7
|
-
include Mongoid::Timestamps
|
8
|
-
include Arkaan::Concerns::Enumerable
|
9
|
-
|
10
|
-
# @!attribute [rw] type
|
11
|
-
# @return [Symbol] the type of action you're making on this instance
|
12
|
-
enum_field :type, [:restart]
|
13
|
-
# @!attribute [rw] success
|
14
|
-
# @return [Boolean] TRUE if the action succeeded (or at least was successfully launched), FALSE otherwise.
|
15
|
-
field :success, type: Boolean, default: false
|
16
|
-
|
17
|
-
# @!attribute [rw] user
|
18
|
-
# @return [Arkaan::Account] the user performing the action on the instance.
|
19
|
-
belongs_to :user, class_name: 'Arkaan::Account'
|
20
|
-
# @!attribute [rw] instance
|
21
|
-
# @return [Arkaan::Monitoring::Instance] the instance of a service on which the action is performed.
|
22
|
-
embedded_in :instance, class_name: 'Arkaan::Monitoring::Instance', inverse_of: :actions
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
@@ -1,38 +0,0 @@
|
|
1
|
-
module Arkaan
|
2
|
-
module Monitoring
|
3
|
-
# An instance is one of the services, deployed on one server. A service may have many instances to balance the load between them all.
|
4
|
-
# @author Vincent Courtois <courtois.vincent@outlook.com>
|
5
|
-
class Instance
|
6
|
-
include Mongoid::Document
|
7
|
-
include Mongoid::Timestamps
|
8
|
-
include Arkaan::Concerns::Activable
|
9
|
-
include Arkaan::Concerns::Typable
|
10
|
-
|
11
|
-
# @!attribute [rw] url
|
12
|
-
# @return [String] the URL of the instance, where the requests will be issued.
|
13
|
-
field :url, type: String
|
14
|
-
# @!attribute [rw] running
|
15
|
-
# @return [Boolean] the running status of the instance, indicating if it can be used or not.
|
16
|
-
field :running, type: Boolean, default: false
|
17
|
-
# @!attribute [rw] data
|
18
|
-
# @return [Hash] the additional datas for this instance (for example for an Heroku instance it's all the data provided by the API)
|
19
|
-
field :data, type: Hash, default: {}
|
20
|
-
|
21
|
-
scope :running , ->{ where(running: true) }
|
22
|
-
|
23
|
-
# @!attribute [r] service
|
24
|
-
# @return [Arkaan::Monitoring::Service] the service this instance is linked to.
|
25
|
-
embedded_in :service, class_name: 'Arkaan::Monitoring::Service', inverse_of: :instances
|
26
|
-
# @!attribute [rw] actions
|
27
|
-
# @return [Arkaan::Monitoring::Action] the actions that has been performed on the service.
|
28
|
-
embeds_many :actions, class_name: 'Arkaan::Monitoring::Action', inverse_of: :instance
|
29
|
-
|
30
|
-
has_many :heartbeats, class_name: 'Arkaan::Monitoring::Results::Heartbeat', inverse_of: :instance
|
31
|
-
|
32
|
-
validates :url,
|
33
|
-
presence: {message: 'required'},
|
34
|
-
format: {with: /\A(https?:\/\/)((([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*)|(localhost:[0-9]{2,4})\/?)\z/, message: 'pattern', if: :url?}
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
@@ -1,10 +0,0 @@
|
|
1
|
-
module Arkaan
|
2
|
-
module Monitoring
|
3
|
-
# The results module handle classes to make results for the vigilante runs.
|
4
|
-
# @author Vincent Courtois <courtois.vincent@outlook.com>
|
5
|
-
module Results
|
6
|
-
autoload :Report, 'arkaan/monitoring/results/report'
|
7
|
-
autoload :Heartbeat, 'arkaan/monitoring/results/heartbeat'
|
8
|
-
end
|
9
|
-
end
|
10
|
-
end
|
@@ -1,50 +0,0 @@
|
|
1
|
-
module Arkaan
|
2
|
-
module Monitoring
|
3
|
-
module Results
|
4
|
-
# A record is the result of the vigilante asking the health of one instance.
|
5
|
-
# @author Vincent Courtois <courtois.vincent@outlook.com>
|
6
|
-
class Heartbeat
|
7
|
-
include Mongoid::Document
|
8
|
-
|
9
|
-
# @!attribute [rw] status
|
10
|
-
# @return [Integer] the HTTP status of the request made for this record.
|
11
|
-
field :status, type: Integer, default: 500
|
12
|
-
# @!attribute [rw] body
|
13
|
-
# @return [Hash] the JSON parsed body from the heartbeat request.
|
14
|
-
field :body, type: Hash, default: {}
|
15
|
-
# @!attribute [rw] healthy
|
16
|
-
# @return [Boolean] TRUE if the instance is deemed healthy, FALSE otherwise.
|
17
|
-
field :healthy, type: Boolean, default: false
|
18
|
-
# @!attribute [rw] started_at
|
19
|
-
# @return [DateTime] the date at which the heartbeat request has started.
|
20
|
-
field :started_at, type: DateTime
|
21
|
-
# @!attribute [rw] ended_at
|
22
|
-
# @return [DateTime] the date at which the request was terminated.
|
23
|
-
field :ended_at, type: DateTime
|
24
|
-
|
25
|
-
# @!attribute [rw] instance
|
26
|
-
# @return [Arkaan::Monitoring::Instance] the instance on which the record has been done.
|
27
|
-
belongs_to :instance, class_name: 'Arkaan::Monitoring::Instance', inverse_of: :heartbeats
|
28
|
-
|
29
|
-
# @!attribute [rw] report
|
30
|
-
# @return [Arkaan::Monitoring::Results::Report] the report made by the vigilante including this record.
|
31
|
-
belongs_to :report, class_name: 'Arkaan::Monitoring::Results::Report', inverse_of: :heartbeats
|
32
|
-
|
33
|
-
attr_readonly :healthy
|
34
|
-
|
35
|
-
def status=(status)
|
36
|
-
self[:status] = status
|
37
|
-
self[:healthy] = status == 200
|
38
|
-
end
|
39
|
-
|
40
|
-
def start!
|
41
|
-
self.started_at = DateTime.now
|
42
|
-
end
|
43
|
-
|
44
|
-
def end!
|
45
|
-
self.ended_at = DateTime.now
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
@@ -1,46 +0,0 @@
|
|
1
|
-
module Arkaan
|
2
|
-
module Monitoring
|
3
|
-
module Results
|
4
|
-
# A report is the result of one call to the API on one instance status route.
|
5
|
-
# @author Vincent Courtois <courtoi.vincent@outlook.com>
|
6
|
-
class Report
|
7
|
-
include Mongoid::Document
|
8
|
-
include Mongoid::Timestamps
|
9
|
-
|
10
|
-
field :started_at, type: DateTime
|
11
|
-
# @!attribute [rw] ended_at
|
12
|
-
# @return [DateTime] the timestamp at which the report ends.
|
13
|
-
field :ended_at, type: DateTime
|
14
|
-
# @!attribute [rw] total
|
15
|
-
# @return [Integer] the total number of services monitored.
|
16
|
-
field :total, type: Integer, default: 0
|
17
|
-
# @!attribute [rw] healthy
|
18
|
-
# @return [Integer] the number of healthy services amongst all the monitored services.
|
19
|
-
field :healthy, type: Integer, default: 0
|
20
|
-
|
21
|
-
# @!attribute [rw] records
|
22
|
-
# @return [Array<Arkaan::Monitoring::Results::Record>] the records linked to this report.
|
23
|
-
has_many :heartbeats, class_name: 'Arkaan::Monitoring::Results::Heartbeat', inverse_of: :report
|
24
|
-
# @!attribute [rw] vigilante
|
25
|
-
# @return [Arkaan::Monitoring::Vigilante] the vigilante application that has created this report.
|
26
|
-
belongs_to :vigilante, class_name: 'Arkaan::Monitoring::Vigilante', inverse_of: :reports
|
27
|
-
|
28
|
-
def add_heartbeat(heartbeat)
|
29
|
-
self.heartbeats << heartbeat
|
30
|
-
self.total += 1
|
31
|
-
self.healthy += (heartbeat.healthy ? 1 : 0)
|
32
|
-
heartbeat.end!
|
33
|
-
end
|
34
|
-
|
35
|
-
def start!
|
36
|
-
self.started_at = DateTime.now
|
37
|
-
end
|
38
|
-
|
39
|
-
def end!
|
40
|
-
self.ended_at = DateTime.now
|
41
|
-
self.save!
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
@@ -1,48 +0,0 @@
|
|
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
|
7
|
-
include Mongoid::Document
|
8
|
-
include Mongoid::Timestamps
|
9
|
-
|
10
|
-
# @!attribute [rw] token
|
11
|
-
# @return [String] the token the vigilante uses to identify himself in the services
|
12
|
-
field :token, type: String
|
13
|
-
# @!attribute [rw] max_results
|
14
|
-
# @return [Integer] the number of results the vigilante should be keeping at any time.
|
15
|
-
# The oldest result should be erased to not go over the limit
|
16
|
-
field :max_results, type: Integer, default: 20
|
17
|
-
|
18
|
-
# @!attribute [rw] reports
|
19
|
-
# @return [Array<Arkaan::monitoring::Results::Report>] the report generated by running this vigilante.
|
20
|
-
has_many :reports, class_name: 'Arkaan::Monitoring::Results::Report', inverse_of: :vigilante
|
21
|
-
|
22
|
-
validates :token, presence: {message: 'required'}
|
23
|
-
|
24
|
-
validates :max_results,
|
25
|
-
numericality: {greater_than: 0, message: 'minimum'}
|
26
|
-
|
27
|
-
# Adds a report to the collection of reports by eventually deleting the oldest one.
|
28
|
-
# @param report [Arkaan::Monitoring::Results::Report] the report to add to the vigilante,
|
29
|
-
# added only if it does not exceed the max number of reports the vigilante can store.
|
30
|
-
def add_report(report)
|
31
|
-
erase_oldest_result if result_full?
|
32
|
-
reports << report
|
33
|
-
end
|
34
|
-
|
35
|
-
# Checks if the list of reports is already full, or if more can be added.
|
36
|
-
# @return [Boolean] TRUE if the number of reports already exceeds the max number.
|
37
|
-
def results_full?
|
38
|
-
reports.to_a.count >= max_results
|
39
|
-
end
|
40
|
-
|
41
|
-
# Erases the oldest results to keep only MAX - 1 results in the list.
|
42
|
-
def erase_oldest_result
|
43
|
-
limit = reports.count + 1 - vigilante.max_results
|
44
|
-
reports.sort_by(created_at: :asc).limit(limit).each(&:delete)
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
module Arkaan
|
2
|
-
module Monitoring
|
3
|
-
# The websocket is a particular kind of service, just like the gateway. It always has the same signature.
|
4
|
-
# A websocket document is a particular instance of websocket, located on a server and answering to a URL.
|
5
|
-
# @author Vincent Courtois <courtois.vincent@outlook.com>
|
6
|
-
class Websocket
|
7
|
-
include Mongoid::Document
|
8
|
-
include Mongoid::Timestamps
|
9
|
-
include Arkaan::Concerns::Activable
|
10
|
-
include Arkaan::Concerns::Diagnosticable
|
11
|
-
|
12
|
-
# @!attribute [rw] url
|
13
|
-
# @return [String] the URL of the websocket to be contacted on.
|
14
|
-
field :url, type: String
|
15
|
-
|
16
|
-
# @!attribute [rw] creator
|
17
|
-
# @return [Arkaan::Account] the account that created this web socket instance in the database.
|
18
|
-
belongs_to :creator, class_name: 'Arkaan::Account', inverse_of: :web_sockets, optional: true
|
19
|
-
|
20
|
-
validates :url,
|
21
|
-
presence: {message: 'required'},
|
22
|
-
format: {with: /\A(ws:\/\/)([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?\z/, message: 'pattern', if: :url?}
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|