spsclient_m2m 0.3.1 → 0.3.2

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
  SHA1:
3
- metadata.gz: b09b941ed9215741d879bb1a8b3b61b14b94d471
4
- data.tar.gz: 3811e09e54d45639d0aef1cebe59f362dbaf384a
3
+ metadata.gz: c3215e94778d97380fb91eaadbc0ba55cd630593
4
+ data.tar.gz: 585c29648c9724beef8b8a7629103f4c72d7e4f3
5
5
  SHA512:
6
- metadata.gz: 269ce163230409714e1896adf5f5fd5aa8e042a834cde2adddc384bdffb94d9c7ae1d15f46c4d857e546ace33f30e640fbfd0421ff0d0e18ab6e986f4630e90d
7
- data.tar.gz: 872ea1d8dd1a479cdc68968c2bc7b5075dfb725b671caf71507ce85335d6c0246709335eccc9add524d31b5d5c74024aef6e78789bd7a9151c23729333caaed0
6
+ metadata.gz: 46c19b009809ffa210f8d1380c92a3e246d8097ae2b62c292d0c24b69bc584293bf38691f4082007fcea5ef97c1e9e39781c6a69ffbea1f59d71304fb69c1aa8
7
+ data.tar.gz: c496a5a4ced246539875c2b879f77a5c2eca5df2440818b9b9e0fd0748352d5cd68030eb0241d231f81d7c23fccbc2712ee2651b466fb46e7c2f6378ebda6925
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/lib/spsclient_m2m.rb CHANGED
@@ -3,7 +3,6 @@
3
3
  # file: spsclient_m2m.rb
4
4
 
5
5
 
6
- require 'logger'
7
6
  require 'polyrex'
8
7
  require 'spstrigger_execute'
9
8
  require 'sps-sub'
@@ -11,44 +10,55 @@ require 'sps-sub'
11
10
 
12
11
  class SPSClientM2M
13
12
 
14
- def initialize(rsc, reg, keywords, px_url, logfile: nil, \
13
+ def initialize(rsc, reg, keywords, px_url, log: nil, \
15
14
  sps_host: 'sps', sps_port: '59000', topic: '#',
16
15
  reload_keyword: /^reload$/)
17
16
 
18
- @rsc = rsc
19
- @log = Logger.new(logfile,'daily') if logfile
20
-
21
- @sps_address = "%s:%s" % [sps_host, sps_port]
22
- @topic = topic
17
+ @rsc, @log, @topic = rsc, log, topic
18
+
19
+ log.info 'SPSCLientM2M/initialize: active' if log
23
20
 
24
- @sps = SPSSub.new host: sps_host, port: sps_port
21
+ @sps_address = "%s:%s" % [sps_host, sps_port]
22
+ @sps = SPSSub.new host: sps_host, port: sps_port, log: log
25
23
 
26
24
  px = Polyrex.new px_url
27
25
 
28
- @ste = SPSTriggerExecute.new keywords, reg, px, logfile: 'ste.log'
29
- @keywords, @reload_keyword = keywords, reload_keyword
26
+ log.info 'SPSCLientM2M/initialize: before @ste' if log
27
+ @ste = SPSTriggerExecute.new keywords, reg, px, log: log
28
+ log.info 'SPSCLientM2M/initialize: after @ste' if log
29
+ @keywords, @reload_keyword, @reg = keywords, reload_keyword, reg
30
30
 
31
31
  end
32
32
 
33
33
  def run()
34
34
 
35
- rsc = @rsc
36
- ste = @ste
37
- keywords = @keywords
35
+ log.info 'SPSCLientM2M/run: active' if log
38
36
 
39
- @sps.subscribe(topic: @topic) do |raw_message, topic|
37
+ rsc, ste, keywords, reg, reload_keyword = @rsc, @ste, @keywords, @reg,
38
+ @reload_keyword
40
39
 
41
- if raw_message.strip =~ @reload_keyword then
40
+ @sps.subscribe(topic: @topic) do |raw_message, topic|
41
+
42
+ log.info 'SPSCLientM2M/run: received something' if log
43
+
44
+ if reg and topic == 'system/clock' then
45
+ reg.set_key 'hkey_services/spsclient_m2m/last_seen',
46
+ "#%s#" % Time.now.to_s
47
+ end
48
+
49
+ if raw_message.strip =~ reload_keyword then
50
+
51
+ log.info 'SPSClientM2M/run: reloading' if log
52
+ ste = SPSTriggerExecute.new keywords, reg=nil, px=nil, log: log
42
53
 
43
- puts 'reloading'
44
- ste = SPSTriggerExecute.new keywords, reg=nil, px=nil, logfile: 'ste.log'
45
54
  end
46
55
 
47
- puts "[%s] SPS M2M kywrd lstnr INFO %s: %s" % \
48
- [Time.now.strftime("%D %H:%M"), topic, raw_message]
49
-
50
- a = ste.mae topic, raw_message
51
- log 'a: ' + a.inspect
56
+ if log then
57
+ log.info "SPSClientM2M/run: received %s: %s" % [topic, raw_message]
58
+ end
59
+
60
+ a = ste.mae topic: topic, message: raw_message
61
+ log.info 'SPSClientM2M/run: a: ' + a.inspect if log
52
62
 
53
63
  # obj is the DRb object, r is the result from find_match,
54
64
  # a is the Dynarex lookup array
@@ -63,12 +73,18 @@ class SPSClientM2M
63
73
  package_path = x.shift
64
74
  package = package_path[/([^\/]+)\.rsf$/,1]
65
75
 
66
- log "job: %s path: %s package: %s" % [job, package_path, package]
67
- log 'foo: ' + rsc.r.hello
76
+ if log then
77
+ log.info "SPSClientM2M/run: job: %s path: %s package: %s" % \
78
+ [job, package_path, package]
79
+ end
80
+
68
81
  rsc.run_job package, job, {}, args=x, package_path: package_path
69
82
  },
70
83
  sps: ->(x, rsc){ @sps.notice x },
71
- ste: ->(x, rsc){ log 'before ste run'; ste.run x }
84
+ ste: ->(x, rsc){
85
+ log.info 'SPSClientM2M/run: before ste run' if log
86
+ ste.run x
87
+ }
72
88
  }
73
89
 
74
90
  end
@@ -80,11 +96,13 @@ class SPSClientM2M
80
96
  Thread.new do
81
97
 
82
98
  begin
99
+
83
100
  h[type].call x, rsc
84
101
  rescue
85
- warning = 'SPSClientM2M warning: ' + ($!).inspect
86
- puts warning
87
- log warning
102
+
103
+ err_msg = 'SPSClientM2M/run/error: ' + ($!).inspect
104
+ log ? log.debug(err_msg) : puts(err_msg)
105
+
88
106
  end
89
107
 
90
108
  end # /thread
@@ -96,10 +114,11 @@ class SPSClientM2M
96
114
  end
97
115
 
98
116
  end
99
-
117
+
100
118
  private
101
119
 
102
- def log(s)
103
- @log.debug(s) if @log
120
+ def log()
121
+ @log
104
122
  end
105
- end
123
+
124
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spsclient_m2m
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -12,26 +12,26 @@ cert_chain:
12
12
  -----BEGIN CERTIFICATE-----
13
13
  MIIDljCCAn6gAwIBAgIBATANBgkqhkiG9w0BAQUFADBIMRIwEAYDVQQDDAlnZW1t
14
14
  YXN0ZXIxHjAcBgoJkiaJk/IsZAEZFg5qYW1lc3JvYmVydHNvbjESMBAGCgmSJomT
15
- 8ixkARkWAmV1MB4XDTE2MDQyNjE5MzgxMFoXDTE3MDQyNjE5MzgxMFowSDESMBAG
15
+ 8ixkARkWAmV1MB4XDTE3MTAyOTEwMjY1NVoXDTE4MTAyOTEwMjY1NVowSDESMBAG
16
16
  A1UEAwwJZ2VtbWFzdGVyMR4wHAYKCZImiZPyLGQBGRYOamFtZXNyb2JlcnRzb24x
17
17
  EjAQBgoJkiaJk/IsZAEZFgJldTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
18
- ggEBAN0INqaz3cN0nq+803zH8krhxh9LwVbEhi0e6vmMXjr2IAEluB+SCRrQEELx
19
- FY/XRhkqTVSkXC9eXW9zgs6ij+aJIuUH8QGhLI6Nw+G5/Y4xL9j6V5yTT1X27/XJ
20
- JyEfP3LuEzcm/IlM7Gihg/mBSyKLlFl6XaGsuBNIvD7P/BgoPQxY+2fGStni1DC7
21
- gDL0ITWZNpOfF8a/AhV3l5L0yElZJQrU42fsZnsnQRITCBjHP2f8XlE6Xe66cytv
22
- scQzJOzrDBO2QXNq0asBXPHVbzJVVkYz1kyztO77Ri5xoPk8RfLtcJxhdbfNNogj
23
- 8SDD2mabP/Z0/QgYTfwTK59303MCAwEAAaOBijCBhzAJBgNVHRMEAjAAMAsGA1Ud
24
- DwQEAwIEsDAdBgNVHQ4EFgQUJyOv3ICWn5lJ9QbR6kdkiShirSEwJgYDVR0RBB8w
18
+ ggEBALk1PKr5eDSSMvprWKGzDShs3AezUuY8dAR1KFuqvlh7qgb6mFhrMS98A92C
19
+ lJ1V3cf13jiVm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NRkDsjeLOoXSRcJOOvLpLhN2ynp5gFeBGHDo3
29
+ FrmY/HMIPMGvTRuO1/I/74YIDU+Y0HJrbeh7btmPu+okxKT2qjjMClCoc2IVFWbe
30
+ VKWtMHdDKH9Lr1X7T6iMMX7Om6P0MLfcEhdTUIv+hXCaj5hzE+S/9FAHqu18S+/w
31
+ dBXn9TUi+xrV99j23F6po2HBGSFZdaNVFl9d+1zL8TzksvvfSxoxQWf3cCHRxQxa
32
+ dPHfn+8RHWvT5A==
33
33
  -----END CERTIFICATE-----
34
- date: 2017-04-16 00:00:00.000000000 Z
34
+ date: 2017-10-29 00:00:00.000000000 Z
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: polyrex
@@ -62,7 +62,7 @@ dependencies:
62
62
  version: '0.4'
63
63
  - - ">="
64
64
  - !ruby/object:Gem::Version
65
- version: 0.4.6
65
+ version: 0.4.7
66
66
  type: :runtime
67
67
  prerelease: false
68
68
  version_requirements: !ruby/object:Gem::Requirement
@@ -72,7 +72,7 @@ dependencies:
72
72
  version: '0.4'
73
73
  - - ">="
74
74
  - !ruby/object:Gem::Version
75
- version: 0.4.6
75
+ version: 0.4.7
76
76
  - !ruby/object:Gem::Dependency
77
77
  name: sps-sub
78
78
  requirement: !ruby/object:Gem::Requirement
@@ -82,7 +82,7 @@ dependencies:
82
82
  version: '0.3'
83
83
  - - ">="
84
84
  - !ruby/object:Gem::Version
85
- version: 0.3.4
85
+ version: 0.3.6
86
86
  type: :runtime
87
87
  prerelease: false
88
88
  version_requirements: !ruby/object:Gem::Requirement
@@ -92,7 +92,7 @@ dependencies:
92
92
  version: '0.3'
93
93
  - - ">="
94
94
  - !ruby/object:Gem::Version
95
- version: 0.3.4
95
+ version: 0.3.6
96
96
  description:
97
97
  email: james@jamesrobertson.eu
98
98
  executables: []
@@ -120,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
120
120
  version: '0'
121
121
  requirements: []
122
122
  rubyforge_project:
123
- rubygems_version: 2.6.8
123
+ rubygems_version: 2.6.13
124
124
  signing_key:
125
125
  specification_version: 4
126
126
  summary: The SPSClient_M2M gem is designed to run as a service with the RSF_Services
metadata.gz.sig CHANGED
Binary file