onedrb 0.2.0 → 0.4.1
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 +4 -4
- data/lib/onedrb.rb +97 -6
- data.tar.gz.sig +4 -2
- metadata +22 -2
- metadata.gz.sig +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3829bafa21b51494d1bc147e668427dddc6998da520a60e14eefcd6b9c99c8e5
|
4
|
+
data.tar.gz: 26afcc85a10fb500e8f4e8d9c69ff2d1c23def83b0feed1b6279e7df958742f0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4d41f05105f22e8be82720dd89d0199c643ac76817ca04ae43c40132bb2d07004a9311be375bb296775834fb0e9591ce113d927fb410d1dab109601e076b73aa
|
7
|
+
data.tar.gz: 725672d9bf14d981f1df49be58699194bea4f722379d319a8bd84af5c89be26c8760c3c5e1d0990d6459cb29aa9462ee8b7d7974e816d936460b150ac2022eff
|
checksums.yaml.gz.sig
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
k��r�
|
2
|
+
�z:��!���+�z괆d�v%wF�l���%C�`�R
|
3
|
+
�2kހ�dh�F�q+Tʟ���08�<(y/���JE7�bv�w�#�TrS�KUI;�9=F�I��q��@��Y����w{�zȇ��܃�?��U���=_t�>�[B��ҍ�K��jX$2H�����-2��7�P���'%�,�a���J��S�I�
|
4
|
+
���������Ƨ��1�U�q�1�>z&��U��f�SX�Q���饊@r1ݩ�M�P���8�0\��D�GY�E��S>�
|
data/lib/onedrb.rb
CHANGED
@@ -6,10 +6,48 @@
|
|
6
6
|
|
7
7
|
require 'drb'
|
8
8
|
require 'c32'
|
9
|
+
require 'app-mgr'
|
9
10
|
|
10
|
-
|
11
|
-
#
|
12
|
-
#
|
11
|
+
|
12
|
+
# Note: The Server object can also use a default ServiceMgr object.
|
13
|
+
# Which allows multiple services (user-defined objects) to be
|
14
|
+
# hosted dynamically.
|
15
|
+
# OneDrb recommended port: 57844 (as this port is recognised by the RSC gem)
|
16
|
+
#
|
17
|
+
class ServiceMgr < AppMgr
|
18
|
+
|
19
|
+
def initialize(rsf: nil, debug: false)
|
20
|
+
super(rsf: rsf, type: 'service', debug: debug)
|
21
|
+
@services = @app
|
22
|
+
end
|
23
|
+
|
24
|
+
|
25
|
+
def call(service, methodname, *a)
|
26
|
+
|
27
|
+
return @services[service.to_sym][:running] unless methodname
|
28
|
+
proc1 = @services[service.to_sym][:running].method(methodname.to_sym)
|
29
|
+
a.last.is_a?(Hash) ? proc1.call(*a[0..-2], **a.last) : proc1.call(*a)
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
|
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
|
42
|
+
|
43
|
+
def services()
|
44
|
+
@services.map do |key, object|
|
45
|
+
next unless object[:running]
|
46
|
+
[key, object[:running].public_methods - Object.public_methods]
|
47
|
+
end.compact
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
13
51
|
|
14
52
|
|
15
53
|
class OneDrbError < Exception
|
@@ -22,7 +60,7 @@ module OneDrb
|
|
22
60
|
using ColouredText
|
23
61
|
|
24
62
|
def initialize(host: '127.0.0.1', port: (49152..65535).to_a.sample.to_s,
|
25
|
-
obj:
|
63
|
+
obj: nil, log: nil)
|
26
64
|
|
27
65
|
log.info self.class.to_s + '/initialize: active' if log
|
28
66
|
|
@@ -63,10 +101,18 @@ module OneDrb
|
|
63
101
|
|
64
102
|
puts ('client connecting to port ' + port).info
|
65
103
|
@obj = DRbObject.new_with_uri("druby://#{host}:#{port}")
|
104
|
+
parent = self
|
105
|
+
@obj&.services.each do |name, methods|
|
106
|
+
|
107
|
+
make_class(name, methods, parent)
|
108
|
+
|
109
|
+
end
|
66
110
|
|
67
111
|
end
|
68
112
|
|
69
113
|
# Makes a remote call in 1 line of code using a URI
|
114
|
+
# Only available when using the ServiceMgr as the server object;
|
115
|
+
#
|
70
116
|
# e.g. OneDrb::Client.call 'odrb://clara.home/fun/go?arg=James&age=49'
|
71
117
|
#
|
72
118
|
def self.call(s, port: nil)
|
@@ -87,9 +133,24 @@ module OneDrb
|
|
87
133
|
a = a1.map(&:last)
|
88
134
|
|
89
135
|
client = OneDrb::Client.new host: hostname, port: port
|
90
|
-
proc1 = client[service].method(methodname.to_sym)
|
91
136
|
|
92
|
-
h.any?
|
137
|
+
if h.any? then
|
138
|
+
|
139
|
+
if a.any? then
|
140
|
+
client.call service.to_sym, methodname.to_sym, *a, **h
|
141
|
+
else
|
142
|
+
client.call service.to_sym, methodname.to_sym, **h
|
143
|
+
end
|
144
|
+
|
145
|
+
elsif a.any?
|
146
|
+
|
147
|
+
client.call service.to_sym, methodname.to_sym, *a
|
148
|
+
|
149
|
+
else
|
150
|
+
|
151
|
+
client.call service.to_sym, methodname.to_sym
|
152
|
+
|
153
|
+
end
|
93
154
|
|
94
155
|
end
|
95
156
|
|
@@ -97,6 +158,15 @@ module OneDrb
|
|
97
158
|
@obj
|
98
159
|
end
|
99
160
|
|
161
|
+
def restart(service)
|
162
|
+
|
163
|
+
return unless @obj.respond_to? :services
|
164
|
+
|
165
|
+
@obj.restart(service)
|
166
|
+
found = @obj.services.assoc(service)
|
167
|
+
make_class(*found, self) if found.any?
|
168
|
+
end
|
169
|
+
|
100
170
|
def method_missing(sym, *args)
|
101
171
|
|
102
172
|
if args.last.is_a?(Hash) then
|
@@ -107,6 +177,27 @@ module OneDrb
|
|
107
177
|
|
108
178
|
end
|
109
179
|
|
180
|
+
private
|
181
|
+
|
182
|
+
def make_class(name, methods, parent)
|
183
|
+
|
184
|
+
class_name = name.capitalize
|
185
|
+
klass = Object.const_set(class_name,Class.new)
|
186
|
+
|
187
|
+
klass.class_eval do
|
188
|
+
methods.each do |method_name|
|
189
|
+
define_method method_name do |*args|
|
190
|
+
parent.call name, method_name, *args
|
191
|
+
end
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
define_singleton_method name do
|
196
|
+
klass.new
|
197
|
+
end
|
198
|
+
|
199
|
+
end
|
200
|
+
|
110
201
|
end
|
111
202
|
|
112
203
|
end
|
data.tar.gz.sig
CHANGED
@@ -1,2 +1,4 @@
|
|
1
|
-
��
|
2
|
-
|
1
|
+
��ʟ�r՛�{Xұd����wU�"%qC+S��sߊ>~�Ҕ�gOF�Ұ��!�Qُ�NW�dǨx�m���މ���*~辱
|
2
|
+
�\n&rF?a+?�4�MC�@�UrŞ=w7 >z��Y~bȝS�R)d0�=��CP�@�E
|
3
|
+
@�R�DB�(N�R�Ɍ�܃�r��`�:���x���Z*�x5�P�i�� R�r6�
|
4
|
+
������[�
|
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.1
|
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-04-
|
38
|
+
date: 2022-04-25 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: []
|
metadata.gz.sig
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
����6��
|
2
|
+
��'d~��
|
3
|
+
ɍP�X��"�u*B�Tm��SY�kHU�5���aNU�T���
|
4
|
+
�G'z�Q�U8~ĥ�an�!KaWكO�Mɽ[���^��������"<<�i62<aŷ��,��h����8�+x��E�6�wW;[:mUdp�Qk:'jB��=�ZWo�l'A�B�&��dGy��&
|