appfuel-service 0.3.4 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/appfuel/service/version.rb +1 -1
- data/lib/appfuel/service/worker.rb +47 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 754067554ec7f6f0f75a223c0e07c2896c425223
|
4
|
+
data.tar.gz: 6e9575e427b7db96f1d3d4e6d99759d85e63564f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 942044d4e57fe313e3ccae40cd640a8c32d01d30b25d2ca34ec5f2bfe6624f1b7d76cf2467bd82da5bb9752804a15b48de058536381f987562f591425b5e6230
|
7
|
+
data.tar.gz: 995f0f97d82549e7225faf7938656a3791ea761d5a454fb675111fe3dc9dcd0bf1ef4317ae353a17b5a5215cf2ebbf4322bfb51cf6a10fb23e62993332f1a2e1
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file. (Pending ap
|
|
5
5
|
|
6
6
|
|
7
7
|
# Releases
|
8
|
+
## [[0.4.0]](https://github.com/rsb/appfuel/releases/tag/0.4.0) 2017-09-27
|
9
|
+
### Added
|
10
|
+
- allow work to restrict action routes with `register`
|
11
|
+
|
8
12
|
## [[0.3.4]](https://github.com/rsb/appfuel/releases/tag/0.3.4) 2017-09-19
|
9
13
|
### Fixed
|
10
14
|
- standard config settings to logfile instead of log
|
@@ -16,6 +16,8 @@ module Appfuel
|
|
16
16
|
key = klass.container_class_path
|
17
17
|
container.register(key, klass)
|
18
18
|
container[consumer_key] << key
|
19
|
+
|
20
|
+
@allow_all_actions = true
|
19
21
|
end
|
20
22
|
|
21
23
|
def top_container_key
|
@@ -25,6 +27,31 @@ module Appfuel
|
|
25
27
|
def container_class_type
|
26
28
|
'consumers'
|
27
29
|
end
|
30
|
+
|
31
|
+
def allow_all_action?
|
32
|
+
@allow_all_actions
|
33
|
+
end
|
34
|
+
|
35
|
+
def register(routes)
|
36
|
+
@allow_all_actions = false
|
37
|
+
|
38
|
+
routes = [routes] if routes.is_a?(String)
|
39
|
+
|
40
|
+
unless routes.is_a?(Array)
|
41
|
+
fail "register accepts only String or Array"
|
42
|
+
end
|
43
|
+
@registered_actions = routes
|
44
|
+
end
|
45
|
+
|
46
|
+
def registered_actions
|
47
|
+
@registered_actions ||= []
|
48
|
+
end
|
49
|
+
|
50
|
+
def registered?(route)
|
51
|
+
return true if allowed_all_actions? == true
|
52
|
+
|
53
|
+
registered_actions.include?(route)
|
54
|
+
end
|
28
55
|
end
|
29
56
|
|
30
57
|
# Sneakers worker hook to handle messages from RabbitMQ
|
@@ -43,6 +70,11 @@ module Appfuel
|
|
43
70
|
return ack!
|
44
71
|
end
|
45
72
|
|
73
|
+
handle_invalid_routes(request.action_route) do |exception|
|
74
|
+
handle_exception("dispatch not allowed", exception, request)
|
75
|
+
return ack!
|
76
|
+
end
|
77
|
+
|
46
78
|
begin
|
47
79
|
response = dispatch(request, app_container)
|
48
80
|
rescue => e
|
@@ -61,7 +93,6 @@ module Appfuel
|
|
61
93
|
ack!
|
62
94
|
end
|
63
95
|
|
64
|
-
|
65
96
|
def rpc?(properties)
|
66
97
|
properties.correlation_id && properties.reply_to
|
67
98
|
end
|
@@ -87,6 +118,21 @@ module Appfuel
|
|
87
118
|
|
88
119
|
private
|
89
120
|
|
121
|
+
def handle_invalid_routes(route)
|
122
|
+
if self.class.registered_actions.empty? ||
|
123
|
+
self.class.registered?(request.action_route)
|
124
|
+
return false
|
125
|
+
end
|
126
|
+
|
127
|
+
msg = "route #{request.action_route} not allowed for queue #{queue}"
|
128
|
+
e = RuntimeError.new(msg)
|
129
|
+
if block_given?
|
130
|
+
yield e
|
131
|
+
else
|
132
|
+
return e
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
90
136
|
def handle_exception(label, e, request)
|
91
137
|
err_msg = "[queue #{queue}] #{label}: #{e.message}"
|
92
138
|
logger.error err_msg
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: appfuel-service
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Scott-Buccleuch
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-09-
|
11
|
+
date: 2017-09-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: appfuel
|