arkaan 0.7.0 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/arkaan/monitoring/route.rb +3 -3
- data/lib/arkaan/monitoring/service.rb +1 -1
- data/lib/arkaan/utils/controller.rb +20 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c9d0b93bf17b741d717240767aa10b61724cce7d
|
4
|
+
data.tar.gz: ad0862a9a838a87f589076e9e591ba7d836c8141
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1b266cfc05f76a91b9527f7fb0df999cffd521affbbe27bd42d8565e8ec5171cb81cf420692b48d13898bf963a23532f8f553cd178390a0af85c16f08f2dab7a
|
7
|
+
data.tar.gz: 95d74ccd55f89352c4a6fb1bc313d8b228db5b71cc58561a776810b244ff486410b551c8c6b9c2e26eb178eca5f1a9f218f05175cf53076f9bc536bdfa0a3658
|
@@ -18,13 +18,13 @@ module Arkaan
|
|
18
18
|
|
19
19
|
# @!attribute [rw] service
|
20
20
|
# @return [Arkaan::Monitoring::Service] the service in which this route is declared.
|
21
|
-
|
21
|
+
belongs_to :service, class_name: 'Arkaan::Monitoring::Service', inverse_of: :routes
|
22
22
|
|
23
23
|
validates :path,
|
24
|
-
format: {with: /\A(\/[
|
24
|
+
format: {with: /\A(\/|((\/[a-zA-Z0-9]+)+))\z/, message: 'route.path.format', if: :path?}
|
25
25
|
|
26
26
|
validates :verb,
|
27
27
|
inclusion: {message: 'route.verb.unknown', in: ['get', 'post', 'put', 'delete', 'patch', 'option']}
|
28
28
|
end
|
29
29
|
end
|
30
|
-
end
|
30
|
+
end
|
@@ -28,7 +28,7 @@ module Arkaan
|
|
28
28
|
embeds_many :instances, class_name: 'Arkaan::Monitoring::Instance', inverse_of: :service
|
29
29
|
# @!attribute [rw] routes
|
30
30
|
# @return [Array<Arkaan::Monitoring::Route>] the routes associated to this service, accessible from the gateway.
|
31
|
-
|
31
|
+
has_many :routes, class_name: 'Arkaan::Monitoring::Route', inverse_of: :service
|
32
32
|
|
33
33
|
validates :key, uniqueness: {message: 'service.key.uniq'}
|
34
34
|
|
@@ -20,6 +20,26 @@ module Arkaan
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
+
def self.declare_service(key)
|
24
|
+
@@micro_service = Arkaan::Monitoring::Service.find_by(key: key)
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.declare_route(verb, path, &block)
|
28
|
+
self.declare_route_with(verb, path, false, &block)
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.declare_premium_route(verb, path, &block)
|
32
|
+
self.declare_route_with(verb, path, true, &block)
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.declare_route_with(verb, path, premium, &block)
|
36
|
+
unless @@micro_service.nil?
|
37
|
+
@@micro_service.routes << Arkaan::Monitoring::Route.new(path: path, verb: verb, premium: premium)
|
38
|
+
@@micro_service.save!
|
39
|
+
end
|
40
|
+
self.public_send(verb, path, &block)
|
41
|
+
end
|
42
|
+
|
23
43
|
# Checks the presence of several fields given as parameters and halts the execution if it's not present.
|
24
44
|
# @param fields [Array<String>] an array of fields names to search in the parameters
|
25
45
|
def check_presence(*fields)
|