onedrb 0.3.0 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/onedrb.rb +60 -37
- data.tar.gz.sig +0 -0
- metadata +23 -3
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b157ce44bacdecc88e29fcd4c9ea63a2c87aad10a64b7a4dc40287a80d5c3b41
|
4
|
+
data.tar.gz: fa0b98b2770d33ece4ff519fd70e5cecb1dcbdcbe38256e3467781a373a5cd62
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 206ad75b01f4cd51cff4fb30b031f13ce5383947961a0ee90bd59abb1a317bea881d65e8a115fab7cfd86818330ecacc89b51a85a5718f36c752b75d495e4038
|
7
|
+
data.tar.gz: 7ece4f05de5579fa22fa1cdb43249b4a50103589f3dfe82aa3ce34889abee7f8de72695b2fa18108c0b60fe679d802a24a3eb460d3914f371d77c52e78364516
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/onedrb.rb
CHANGED
@@ -6,48 +6,47 @@
|
|
6
6
|
|
7
7
|
require 'drb'
|
8
8
|
require 'c32'
|
9
|
+
require 'app-mgr'
|
10
|
+
|
9
11
|
|
10
12
|
# Note: The Server object can also use a default ServiceMgr object.
|
11
13
|
# Which allows multiple services (user-defined objects) to be
|
12
14
|
# hosted dynamically.
|
15
|
+
# OneDrb recommended port: 57844 (as this port is recognised by the RSC gem)
|
16
|
+
#
|
17
|
+
class ServiceMgr < AppMgr
|
13
18
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
def initialize()
|
18
|
-
@services = {}
|
19
|
+
def initialize(rsf: nil, debug: false)
|
20
|
+
super(rsf: rsf, type: 'service', debug: debug)
|
21
|
+
@services = @app
|
19
22
|
end
|
20
23
|
|
21
24
|
|
22
25
|
def call(service, methodname, *a)
|
23
26
|
|
24
|
-
|
27
|
+
return @services[service.to_sym][:running] unless methodname
|
28
|
+
proc1 = @services[service.to_sym][:running].method(methodname.to_sym)
|
25
29
|
a.last.is_a?(Hash) ? proc1.call(*a[0..-2], **a.last) : proc1.call(*a)
|
26
30
|
|
27
31
|
end
|
28
32
|
|
29
|
-
def [](key)
|
30
|
-
@services[key]
|
31
|
-
end
|
32
|
-
|
33
|
-
def []=(key, value)
|
34
|
-
@services[key] = value
|
35
33
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
34
|
+
# OneDRb version 2; Allows multiple user-defined objects to be
|
35
|
+
# served from 1 DRb service
|
36
|
+
#
|
37
|
+
# not used by any client, but may be in future
|
38
|
+
#
|
39
|
+
#def odrb2?()
|
40
|
+
# true
|
41
|
+
#end
|
40
42
|
|
41
43
|
def services()
|
42
44
|
@services.map do |key, object|
|
43
|
-
|
44
|
-
|
45
|
+
next unless object[:running]
|
46
|
+
[key, object[:running].public_methods - Object.public_methods]
|
47
|
+
end.compact
|
45
48
|
end
|
46
49
|
|
47
|
-
def method_missing(sym, *args)
|
48
|
-
puts 'servicemgr sym: ' + sym.inspect
|
49
|
-
puts 'args: ' + args.inspect
|
50
|
-
end
|
51
50
|
end
|
52
51
|
|
53
52
|
|
@@ -61,7 +60,7 @@ module OneDrb
|
|
61
60
|
using ColouredText
|
62
61
|
|
63
62
|
def initialize(host: '127.0.0.1', port: (49152..65535).to_a.sample.to_s,
|
64
|
-
obj:
|
63
|
+
obj: nil, log: nil)
|
65
64
|
|
66
65
|
log.info self.class.to_s + '/initialize: active' if log
|
67
66
|
|
@@ -103,21 +102,13 @@ module OneDrb
|
|
103
102
|
puts ('client connecting to port ' + port).info
|
104
103
|
@obj = DRbObject.new_with_uri("druby://#{host}:#{port}")
|
105
104
|
parent = self
|
106
|
-
@obj&.services.each do |name, methods|
|
107
105
|
|
108
|
-
|
109
|
-
klass = Object.const_set(class_name,Class.new)
|
106
|
+
if @obj.respond_to? :services then
|
110
107
|
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
parent.call name, method_name, *args
|
115
|
-
end
|
116
|
-
end
|
117
|
-
end
|
108
|
+
@obj&.services.each do |name, methods|
|
109
|
+
|
110
|
+
make_class(name, methods, parent)
|
118
111
|
|
119
|
-
define_singleton_method name do
|
120
|
-
klass.new
|
121
112
|
end
|
122
113
|
|
123
114
|
end
|
@@ -125,6 +116,8 @@ module OneDrb
|
|
125
116
|
end
|
126
117
|
|
127
118
|
# Makes a remote call in 1 line of code using a URI
|
119
|
+
# Only available when using the ServiceMgr as the server object;
|
120
|
+
#
|
128
121
|
# e.g. OneDrb::Client.call 'odrb://clara.home/fun/go?arg=James&age=49'
|
129
122
|
#
|
130
123
|
def self.call(s, port: nil)
|
@@ -170,9 +163,16 @@ module OneDrb
|
|
170
163
|
@obj
|
171
164
|
end
|
172
165
|
|
173
|
-
def
|
166
|
+
def restart(service)
|
174
167
|
|
175
|
-
|
168
|
+
return unless @obj.respond_to? :services
|
169
|
+
|
170
|
+
@obj.restart(service)
|
171
|
+
found = @obj.services.assoc(service)
|
172
|
+
make_class(*found, self) if found.any?
|
173
|
+
end
|
174
|
+
|
175
|
+
def method_missing(sym, *args)
|
176
176
|
|
177
177
|
if args.last.is_a?(Hash) then
|
178
178
|
@obj.send(sym, *args[0..-2], **args.last)
|
@@ -182,6 +182,29 @@ module OneDrb
|
|
182
182
|
|
183
183
|
end
|
184
184
|
|
185
|
+
private
|
186
|
+
|
187
|
+
def make_class(name, methods, parent)
|
188
|
+
|
189
|
+
class_name = name.capitalize
|
190
|
+
klass = Object.const_set(class_name,Class.new)
|
191
|
+
|
192
|
+
klass.class_eval do
|
193
|
+
methods.each do |method_name|
|
194
|
+
define_method method_name do |*args|
|
195
|
+
parent.call name, method_name, *args
|
196
|
+
end
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
define_singleton_method name do
|
201
|
+
klass.new
|
202
|
+
end
|
203
|
+
|
204
|
+
end
|
205
|
+
|
185
206
|
end
|
186
207
|
|
187
208
|
end
|
209
|
+
|
210
|
+
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: onedrb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -35,7 +35,7 @@ cert_chain:
|
|
35
35
|
lK7OtCGPauDHVuIWDW0EnHb+MMBt6F5SqC+PSy9iOzs4zAWkJMFp86MOEK2yrfnO
|
36
36
|
/ghrVtneK08DqmYOaive8I6P
|
37
37
|
-----END CERTIFICATE-----
|
38
|
-
date: 2022-
|
38
|
+
date: 2022-06-23 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: c32
|
@@ -57,6 +57,26 @@ dependencies:
|
|
57
57
|
- - ">="
|
58
58
|
- !ruby/object:Gem::Version
|
59
59
|
version: 0.3.0
|
60
|
+
- !ruby/object:Gem::Dependency
|
61
|
+
name: app-mgr
|
62
|
+
requirement: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - "~>"
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '0.4'
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 0.4.0
|
70
|
+
type: :runtime
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - "~>"
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0.4'
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: 0.4.0
|
60
80
|
description:
|
61
81
|
email: digital.robertson@gmail.com
|
62
82
|
executables: []
|
@@ -83,7 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
83
103
|
- !ruby/object:Gem::Version
|
84
104
|
version: '0'
|
85
105
|
requirements: []
|
86
|
-
rubygems_version: 3.
|
106
|
+
rubygems_version: 3.3.7
|
87
107
|
signing_key:
|
88
108
|
specification_version: 4
|
89
109
|
summary: Makes it convenient to make an object remotely accessible.
|
metadata.gz.sig
CHANGED
Binary file
|