SMService 0.1.5 → 0.1.6
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/bin/console +47 -4
- data/examples/dummy.rb +15 -1
- data/lib/smservice.rb +6 -2
- data/lib/smservice/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c8aaf506f0389296ad7fa48e36ae5594d7d4a7ce11ae7644569d29b085111576
|
4
|
+
data.tar.gz: c906f849fc266bc43d021d520d34d49a88b5fd8649df3fa12ee0ad6a35069f2c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b475fc9ffdd3af20ebe238bd763a4c06573a737cf3a04fedc332aee96f69b421d2f084e69552e5ccf5b94222d602ce06bc047bf1db959062225e87ecf50a608b
|
7
|
+
data.tar.gz: f1a7da19e29540b16830be9b1829c7ab4ecfd4ce354ecbdb5448a919082c7815fa4a83a02955f35041ba1fb6159466571177501e9c381e40eb849294ae3eac5a
|
data/bin/console
CHANGED
@@ -8,7 +8,7 @@ Bundler.require
|
|
8
8
|
require 'smservice'
|
9
9
|
require_relative '../examples/dummy'
|
10
10
|
|
11
|
-
class SMService::
|
11
|
+
class SMService::TestCase
|
12
12
|
include SMService
|
13
13
|
|
14
14
|
def initialize
|
@@ -17,14 +17,57 @@ class SMService::Test
|
|
17
17
|
|
18
18
|
def action_test(headers, message)
|
19
19
|
LOGGER.info "#{self.class} - Processing action 'test'. Headers: #{headers.inspect}, message: #{message.inspect}"
|
20
|
+
|
21
|
+
# triggering 'someaction' as part of test plan
|
22
|
+
@tc_reply_to = headers['reply_to'] # where TC shall report-to at the end
|
23
|
+
message[:parent_action_headers] = headers # sending also parameters from caller
|
24
|
+
execute action: 'someaction', message: message
|
25
|
+
|
26
|
+
if headers['reply_to']
|
27
|
+
# sending reply back
|
28
|
+
LOGGER.info "#{self.class} - Action 'test' sending reply"
|
29
|
+
|
30
|
+
execute action: 'REPLY',
|
31
|
+
reply_to: headers['reply_to'],
|
32
|
+
message: {status: 'OK', more_data: ['...']}
|
33
|
+
|
34
|
+
LOGGER.info "#{self.class} - Action 'test' reply sent"
|
35
|
+
end
|
36
|
+
|
37
|
+
LOGGER.info "#{self.class} - Terminating action 'test'"
|
38
|
+
end
|
39
|
+
|
40
|
+
def action_reply(headers, message)
|
41
|
+
LOGGER.info "#{self.class} - Processing action 'reply'. Headers: #{headers.inspect}, message: #{message.inspect}"
|
42
|
+
|
43
|
+
# ... if conditions and validations to ensure that it is reply for this TC, by searching UUID etc etc, and by the end:
|
44
|
+
#
|
45
|
+
LOGGER.info "#{self.class} - Forwarding collected TC data to the caller, which is #{@tc_reply_to}"
|
46
|
+
execute action: 'REPLY',
|
47
|
+
reply_to: @tc_reply_to,
|
48
|
+
message: message
|
20
49
|
end
|
21
50
|
end
|
22
51
|
|
52
|
+
class SMService::API
|
53
|
+
include SMService
|
54
|
+
|
55
|
+
def initialize
|
56
|
+
super name: 'api'
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
|
23
61
|
dummy = SMService::Dummy.new
|
24
62
|
dummy.start!
|
25
63
|
|
26
|
-
|
27
|
-
|
64
|
+
tc = SMService::TestCase.new
|
65
|
+
tc.start!
|
66
|
+
|
67
|
+
api = SMService::API.new
|
68
|
+
api.start!
|
69
|
+
|
70
|
+
sleep 3
|
71
|
+
api.execute(action: 'test', message: {my_request: 'ping', my_data: 'add whatever data needed'})
|
28
72
|
|
29
|
-
# dummy.execute(action: 'test', message: {my_request: 'ping', my_data: 'add whatever data needed'})
|
30
73
|
binding.pry
|
data/examples/dummy.rb
CHANGED
@@ -6,6 +6,20 @@ class SMService::Dummy
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def action_someaction(headers, message)
|
9
|
-
LOGGER.info
|
9
|
+
LOGGER.info "#{self.class} - Processing action 'someaction'. Headers: #{headers.inspect}, message: #{message.inspect}"
|
10
|
+
|
11
|
+
if headers['reply_to']
|
12
|
+
# sending reply back
|
13
|
+
LOGGER.info "#{self.class} - Action 'someaction' sending reply"
|
14
|
+
|
15
|
+
execute action: 'REPLY',
|
16
|
+
reply_to: headers['reply_to'],
|
17
|
+
message: {status: 'OK', whatever: 'add it here'}
|
18
|
+
|
19
|
+
LOGGER.info "#{self.class} - Action 'someaction' reply sent"
|
20
|
+
end
|
21
|
+
|
22
|
+
LOGGER.info "#{self.class} - Terminating action 'someaction'"
|
23
|
+
|
10
24
|
end
|
11
25
|
end
|
data/lib/smservice.rb
CHANGED
@@ -126,12 +126,16 @@ module SMService
|
|
126
126
|
LOGGER.info "#{self.class} - Processing action 'update'. Headers: #{headers.inspect}, message: #{message.inspect}"
|
127
127
|
end
|
128
128
|
|
129
|
+
def action_reply(headers, message)
|
130
|
+
LOGGER.info "#{self.class} - Processing action 'reply'. Headers: #{headers.inspect}, message: #{message.inspect}"
|
131
|
+
end
|
132
|
+
|
129
133
|
# Requesting another service, registered at SM to execute given action, example:
|
130
134
|
# execute(action: 'create_customer_portal', message: {my_request: 'should create a customer', my_data: 'add whatever data needed'})
|
131
135
|
#
|
132
|
-
def execute(action:, message: nil)
|
136
|
+
def execute(action:, reply_to: nil, message: nil)
|
133
137
|
LOGGER.info "#{self.class} - SM execute request. Action: #{action.inspect}, message: #{message.inspect}"
|
134
|
-
action = {service: action, reply_to: @service_name}.to_msgpack
|
138
|
+
action = {service: action, reply_to: (reply_to || @service_name)}.to_msgpack
|
135
139
|
message = message.to_msgpack
|
136
140
|
@socket_out.send_strings [action, message]
|
137
141
|
end
|
data/lib/smservice/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: SMService
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrius Kairiukstis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-11-
|
11
|
+
date: 2017-11-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: logger
|