rse 0.3.0 → 0.4.0

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.
Files changed (6) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/lib/rse.rb +116 -83
  4. data.tar.gz.sig +0 -0
  5. metadata +39 -38
  6. metadata.gz.sig +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e4815a8971c00376767179739875abeb246ab65a28ff6a43cba52055238585e2
4
- data.tar.gz: 1e0008e4927b0cdc5771965c682eb3246daca3eed882c4c6c2fe0611038efaf3
3
+ metadata.gz: f1157852fad295d25dac2a7e5e8907d3c0afd61682d4fdf2b926de56bfc116aa
4
+ data.tar.gz: 9ee0c46b6cace3db05c107f1f29e3c7ff105a8bd51b87310dcdd0895bf8d30d4
5
5
  SHA512:
6
- metadata.gz: 573f887917c5ba682e637f8b1901b6afb404499bbbd9d07a957f59eed5c8dffd7b05524f2f379a5ee65609f35ad2313abe277131afb01ba8cd88752873b60918
7
- data.tar.gz: fade8a505895afcf58d04e3c0573f3efe87c5fcdaad7c02cf69c09311acb2364b7cb3ec05110890cc74f4f5ed9b0d336b5aa02d33b27b306d738e341a9ce912b
6
+ metadata.gz: 71df363891458d1a2f70ee1c325469395f11644dfdcfafb9965f81292340ec2833855751de0abaa09fb994f829a3b8b1ab10a077d12518f4d6a9b7ca446600b7
7
+ data.tar.gz: 8fa3a49adac81375fc07e17b9527a523703a918b48625a1e1f07f2257a4c7966133d655fc28b82f57c18860c319924195923b6f0276212ad9d526fb066919420
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/rse.rb CHANGED
@@ -12,27 +12,32 @@ require 'spspublog_drb_client'
12
12
 
13
13
 
14
14
  module Rse
15
-
15
+
16
16
  class Server
17
17
  using ColouredText
18
-
19
- def initialize(package_basepath=nil, host: '0.0.0.0', port: '61000',
20
- debug: false, loghost: nil, logport: '9090',
18
+
19
+ def initialize(package_basepath=nil, host: '0.0.0.0', port: '61000',
20
+ debug: false, loghost: nil, logport: '9090', log: nil,
21
21
  reghost: nil, spshost: nil, app_rsf: nil)
22
22
 
23
23
  @host, @port, @debug = host, port, debug
24
24
 
25
25
  puts 'before spspublog'.info if @debug
26
- log = loghost ? SPSPubLogDRbClient.new(host: loghost, port: logport) : nil
27
-
26
+
27
+ log2 = if log then
28
+ log
29
+ elsif loghost
30
+ SPSPubLogDRbClient.new(host: loghost, port: logport)
31
+ end
32
+
28
33
  puts 'before reg'.info if @debug
29
34
  reg = reghost ? RemoteDwsRegistry.new(domain: reghost) : nil
30
35
 
31
- @rs = rs = RSFServices.new reg, package_basepath: package_basepath,
32
- log: log, app_rsf: app_rsf, debug: debug
33
-
36
+ @rs = rs = RSFServices.new reg, package_basepath: package_basepath,
37
+ log: log2, app_rsf: app_rsf, debug: debug
38
+
34
39
  @rs.services['sps'] = SPSPub.new(host: spshost) if spshost
35
-
40
+
36
41
  puts 'ready'
37
42
 
38
43
  end
@@ -45,34 +50,34 @@ module Rse
45
50
 
46
51
  end
47
52
  end
48
-
53
+
49
54
  class Subscriber < SPSSub
50
-
55
+
51
56
  def initialize(host: 'rse.home', spshost: 'sps.home')
52
-
57
+
53
58
  @rsc = RSC.new(host)
54
59
  super(host: spshost)
55
60
 
56
61
  end
57
-
62
+
58
63
  def subscribe(topic: 'rse/#')
59
-
64
+
60
65
  super(topic: topic) do |msg, topic|
61
-
66
+
62
67
  a = topic.split('/')[1..-1]
63
-
68
+
64
69
  if a.length < 2 then
65
-
70
+
66
71
  begin
67
72
  r = @rsc.run_job(a.first, msg)
68
73
  rescue
69
74
  self.notice 'rse_result: no job ' + a.first
70
75
  end
71
-
76
+
72
77
  self.notice 'rse_result: ' + r.inspect
73
-
78
+
74
79
  else
75
-
80
+
76
81
  package, job = a
77
82
 
78
83
  begin
@@ -80,122 +85,150 @@ module Rse
80
85
  rescue
81
86
  self.notice 'rse_result: no job ' + a.first
82
87
  end
83
-
88
+
84
89
  self.notice "rse_result/%s/%s: %s" % [package, job, r.inspect ]
85
90
  end
86
-
91
+
87
92
  end
88
- end
89
-
90
- end
93
+ end
94
+
95
+ end
91
96
 
92
97
  end
93
98
 
94
99
 
95
100
  module RseProxy
96
-
101
+
97
102
  class PassThru
98
103
 
99
- def initialize(serversx=[], servers: serversx, log: nil )
100
-
104
+ # job_filter (which is optional) expects a block
105
+ #
106
+ def initialize(serversx=[], servers: serversx, log: nil, jobfilter: nil )
107
+
101
108
  DRb.start_service
102
-
109
+
103
110
  @servers = servers.map do |x|
104
-
105
- host, port = x.is_a?(Hash) ? [x[:host], x[:port]] : x
106
-
111
+
112
+ host, port = x.is_a?(Hash) ? [x[:host], x[:port]] : x
113
+
107
114
  end
108
-
115
+
109
116
  @log = Logger.new log, 'daily' if log
110
-
117
+
118
+ @rse = nil
119
+ @jobfilter = jobfilter
120
+
111
121
  end
112
122
 
113
123
  def delete()
114
124
  fetch_server() { |rse| rse.delete }
115
125
  end
116
-
126
+
117
127
  def get()
118
128
  fetch_server() { |rse| rse.get }
119
129
  end
120
-
130
+
121
131
  def put()
122
132
  fetch_server() { |rse| rse.put }
123
133
  end
124
-
134
+
125
135
  def post()
126
136
  fetch_server() { |rse| rse.post }
127
137
  end
128
-
138
+
129
139
  def package_methods(name)
130
140
  fetch_server() { |rse| rse.package_methods(name) }
131
141
  end
132
-
142
+
133
143
  def run_job(package, job, params={}, *args)
134
-
135
- @log.info "package: %s, job: %s, params: %s, args: %s" \
136
- % [package, job, params, args] if @log
137
-
138
- fetch_server() { |rse| rse.run_job package, job, params, *args }
139
-
140
- end
141
-
142
- def fetch_server()
143
-
144
+
145
+ if @log then
146
+ @log.info "package: %s, job: %s, " +
147
+ "params: %s, args: %s" % [package, job, params, args]
148
+ end
149
+
150
+ #we pass in the job to determine the server
151
+ fetch_server(job) do |rse|
152
+ rse.run_job package, job, params, *args
153
+ end
154
+
155
+ end
156
+
157
+ def fetch_server(job=nil)
158
+
159
+ host, port = nil, nil
160
+
161
+ exit if @servers.empty?
162
+
163
+ # using a job filter we can send a job (by checking its name) to
164
+ # a specific server
165
+ #
166
+ r = @jobfilter.call(job) if job and @jobfilter.is_a? Proc
167
+
168
+ server = if r then
169
+ r
170
+ else
171
+ @log.info 'job: ' + job.inspect if @log
172
+ @servers.first
173
+ end
174
+
175
+ puts 'server: ' + server.inspect
176
+
144
177
  begin
145
-
146
- servers = @servers.clone
147
-
148
- server = servers.shift
149
178
  host, port = server
150
- rse = DRbObject.new_with_uri("druby://#{host}:#{port}")
151
- yield(rse) if block_given?
152
-
179
+ @rse = DRbObject.new_with_uri("druby://#{host}:#{port}")
180
+
181
+ yield(@rse) if block_given?
182
+
153
183
  rescue
154
-
184
+
185
+ @servers.shift unless port.to_i > 61005
186
+ @rse = nil
155
187
  puts ($!).inspect
156
- @log.warn "server #{host}:#{port} down" if @log
157
- retry if servers.any?
158
-
188
+ @log.warn "server #{host}:#{port} #{($!).inspect}" if @log
189
+ #sleep 1
190
+ #jr20210725 retry
191
+
192
+
159
193
  end
160
-
194
+
161
195
  end
162
196
 
163
197
  def type()
164
198
  fetch_server() { |rse| rse.type }
165
199
  end
166
-
200
+
167
201
  def type=(s)
168
202
  fetch_server() { |rse| rse.type=(s) }
169
203
  end
170
-
204
+
171
205
  private
172
-
173
- def method_missing(method_name, *args)
206
+
207
+ def method_missing(method_name, *args)
174
208
  fetch_server() { |rse| rse.get.method(method_name).call(*args) }
175
- end
176
-
177
-
209
+ end
210
+
211
+
178
212
  end
179
213
 
180
214
  class Server
181
-
182
- def initialize(host: 'rse.home', port: '61000', servers: [], log: nil,
183
- spshost: 'sps.home')
184
-
215
+
216
+ def initialize(host: 'rse.home', port: '61000', servers: [], log: nil,
217
+ spshost: 'sps.home', jobfilter: nil)
218
+
185
219
  @host, @port, @servers, @log = host, port, servers, log
186
220
  @spshost = spshost
187
-
221
+ @jobfilter = jobfilter
222
+
188
223
  end
189
-
224
+
190
225
  def start()
191
-
192
- DRb.start_service "druby://#{@host}:#{@port}",
193
- PassThru.new(@servers, log: @log)
194
- DRb.thread.join
195
-
226
+
227
+ DRb.start_service "druby://#{@host}:#{@port}",
228
+ PassThru.new(@servers, log: @log, jobfilter: @jobfilter)
229
+ DRb.thread.join
230
+
196
231
  end
197
232
  end
198
-
199
- end
200
-
201
233
 
234
+ end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rse
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -11,31 +11,31 @@ cert_chain:
11
11
  - |
12
12
  -----BEGIN CERTIFICATE-----
13
13
  MIIEXjCCAsagAwIBAgIBATANBgkqhkiG9w0BAQsFADAsMSowKAYDVQQDDCFnZW1t
14
- YXN0ZXIvREM9amFtZXNyb2JlcnRzb24vREM9ZXUwHhcNMjAxMTIyMjEyNDA3WhcN
15
- MjExMTIyMjEyNDA3WjAsMSowKAYDVQQDDCFnZW1tYXN0ZXIvREM9amFtZXNyb2Jl
16
- cnRzb24vREM9ZXUwggGiMA0GCSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQCihhtC
17
- NWhPDa/+7n40XI/Gwe6vP1Fh5BN3PCm+oKlMMM0R8054kn1OiCsnX1Y+D9/L6ru7
18
- +h1EnAkl87iZpi9gQdYkZv6jXd1/MSjb9fIYo9vHUBx9cNxFCUdI9VYFuECCWzYM
19
- O47FEYzXcCoRWOMEi0jClV3rrXrQOdX4rgxnNW0r6Z4RGhnAe4IHA0l7eOdO9TVC
20
- KJR1NIcqtAPhXvDN+tJjvH/ruHyTq1gJU/6rkBfqRPN4CboFQv6m10SwaQvSXcbi
21
- RtK4WzbX13SQNazl4txUf2Gho+Ox+Uqr9teQOhWbmj2XSJJpIXBBvP1xzGvXzONp
22
- dc8lMhyz9hn4PDcbL1HtS0uGHAORdN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EjQ0r5Ih2
32
+ aIljodE+UKtgJTKsVQ8B7VOzygL5ifDq9VJ5EPvPN9CVopIHmEeJUHzDy1lO5B8m
33
+ YNYycxb46Jr0FhPdqmYV9C7kgduvaF30PUCX4nzHjIItXLvGVuhTXksSwldD85NX
34
+ 4dt+Bk5nY7dMy57gzGYIcLJSLoz0vR5V9tMoFpaATj9+QRhkuhPJAv12rers1Imr
35
+ uURNkBXNIh3CdFpGJunoxVicC2OU2CglMgh+92Fjj2tRAV1M5njVnDnXcDSIsw7T
36
+ b5bDlFc8Qgl3+y8V3vxPf7WX
37
37
  -----END CERTIFICATE-----
38
- date: 2020-11-22 00:00:00.000000000 Z
38
+ date: 2021-12-13 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: sps-pub
@@ -81,22 +81,22 @@ dependencies:
81
81
  name: rsf_services
82
82
  requirement: !ruby/object:Gem::Requirement
83
83
  requirements:
84
- - - ">="
85
- - !ruby/object:Gem::Version
86
- version: 0.8.0
87
84
  - - "~>"
88
85
  - !ruby/object:Gem::Version
89
- version: '0.8'
86
+ version: '0.9'
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: 0.9.5
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- version: 0.8.0
97
94
  - - "~>"
98
95
  - !ruby/object:Gem::Version
99
- version: '0.8'
96
+ version: '0.9'
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ version: 0.9.5
100
100
  - !ruby/object:Gem::Dependency
101
101
  name: remote_dwsregistry
102
102
  requirement: !ruby/object:Gem::Requirement
@@ -123,22 +123,22 @@ dependencies:
123
123
  requirements:
124
124
  - - "~>"
125
125
  - !ruby/object:Gem::Version
126
- version: '0.1'
126
+ version: '0.2'
127
127
  - - ">="
128
128
  - !ruby/object:Gem::Version
129
- version: 0.1.1
129
+ version: 0.2.1
130
130
  type: :runtime
131
131
  prerelease: false
132
132
  version_requirements: !ruby/object:Gem::Requirement
133
133
  requirements:
134
134
  - - "~>"
135
135
  - !ruby/object:Gem::Version
136
- version: '0.1'
136
+ version: '0.2'
137
137
  - - ">="
138
138
  - !ruby/object:Gem::Version
139
- version: 0.1.1
139
+ version: 0.2.1
140
140
  description:
141
- email: james@jamesrobertson.eu
141
+ email: digital.robertson@gmail.com
142
142
  executables: []
143
143
  extensions: []
144
144
  extra_rdoc_files: []
@@ -163,7 +163,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
163
163
  - !ruby/object:Gem::Version
164
164
  version: '0'
165
165
  requirements: []
166
- rubygems_version: 3.0.3
166
+ rubyforge_project:
167
+ rubygems_version: 2.7.10
167
168
  signing_key:
168
169
  specification_version: 4
169
170
  summary: Executes Ruby jobs (using the rsf_services gem) from a DRb server.
metadata.gz.sig CHANGED
Binary file