gloox 0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 80dc33a83d1cefb944faedb5ce6226c9cdae8c6ddf29d65d90ad0c758f2940bb
4
+ data.tar.gz: d931ba3575cb52360374b0c3ed6ce65164a00eafb01f5f967ac7a43a69460638
5
+ SHA512:
6
+ metadata.gz: f26d5ff881ce062b70bf478ef7e056fae8c1e989216d1dbd34ea14935df655bc70e63c614790e07604952fb65d5399bcc67502d3f761d333e6b8da1dc6990e0f
7
+ data.tar.gz: 31d045c3fb13018903580ff249fc1b83d8b90101eb4465da0d606817f449e5bc3e038a278ddccc0d81da9ba61dd335b092539c799fc1d3bcd25dfa19aade5209
data/Gemfile ADDED
@@ -0,0 +1,25 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'rake', '13.0.3'
4
+
5
+ group :docs do
6
+ gem 'yard'
7
+ gem 'redcarpet'
8
+ end
9
+
10
+ group :spec do
11
+ gem 'rspec'
12
+ end
13
+
14
+ group :prof do
15
+ gem 'benchmark-ips'
16
+ gem 'memory_profiler'
17
+ end
18
+
19
+ gem "toq", path: '../toq'
20
+ gem "slotz", path: '../slotz'
21
+ gem "tiq", path: '../tiq'
22
+ gem "raktr", path: '../raktr'
23
+ gem 'msgpack'
24
+
25
+ gemspec
data/LICENSE.md ADDED
@@ -0,0 +1,375 @@
1
+ ```
2
+ Mozilla Public License Version 2.0
3
+ ==================================
4
+
5
+ 1. Definitions
6
+ --------------
7
+
8
+ 1.1. "Contributor"
9
+ means each individual or legal entity that creates, contributes to
10
+ the creation of, or owns Covered Software.
11
+
12
+ 1.2. "Contributor Version"
13
+ means the combination of the Contributions of others (if any) used
14
+ by a Contributor and that particular Contributor's Contribution.
15
+
16
+ 1.3. "Contribution"
17
+ means Covered Software of a particular Contributor.
18
+
19
+ 1.4. "Covered Software"
20
+ means Source Code Form to which the initial Contributor has attached
21
+ the notice in Exhibit A, the Executable Form of such Source Code
22
+ Form, and Modifications of such Source Code Form, in each case
23
+ including portions thereof.
24
+
25
+ 1.5. "Incompatible With Secondary Licenses"
26
+ means
27
+
28
+ (a) that the initial Contributor has attached the notice described
29
+ in Exhibit B to the Covered Software; or
30
+
31
+ (b) that the Covered Software was made available under the terms of
32
+ version 1.1 or earlier of the License, but not also under the
33
+ terms of a Secondary License.
34
+
35
+ 1.6. "Executable Form"
36
+ means any form of the work other than Source Code Form.
37
+
38
+ 1.7. "Larger Work"
39
+ means a work that combines Covered Software with other material, in
40
+ a separate file or files, that is not Covered Software.
41
+
42
+ 1.8. "License"
43
+ means this document.
44
+
45
+ 1.9. "Licensable"
46
+ means having the right to grant, to the maximum extent possible,
47
+ whether at the time of the initial grant or subsequently, any and
48
+ all of the rights conveyed by this License.
49
+
50
+ 1.10. "Modifications"
51
+ means any of the following:
52
+
53
+ (a) any file in Source Code Form that results from an addition to,
54
+ deletion from, or modification of the contents of Covered
55
+ Software; or
56
+
57
+ (b) any new file in Source Code Form that contains any Covered
58
+ Software.
59
+
60
+ 1.11. "Patent Claims" of a Contributor
61
+ means any patent claim(s), including without limitation, method,
62
+ process, and apparatus claims, in any patent Licensable by such
63
+ Contributor that would be infringed, but for the grant of the
64
+ License, by the making, using, selling, offering for sale, having
65
+ made, import, or transfer of either its Contributions or its
66
+ Contributor Version.
67
+
68
+ 1.12. "Secondary License"
69
+ means either the GNU General Public License, Version 2.0, the GNU
70
+ Lesser General Public License, Version 2.1, the GNU Affero General
71
+ Public License, Version 3.0, or any later versions of those
72
+ licenses.
73
+
74
+ 1.13. "Source Code Form"
75
+ means the form of the work preferred for making modifications.
76
+
77
+ 1.14. "You" (or "Your")
78
+ means an individual or a legal entity exercising rights under this
79
+ License. For legal entities, "You" includes any entity that
80
+ controls, is controlled by, or is under common control with You. For
81
+ purposes of this definition, "control" means (a) the power, direct
82
+ or indirect, to cause the direction or management of such entity,
83
+ whether by contract or otherwise, or (b) ownership of more than
84
+ fifty percent (50%) of the outstanding shares or beneficial
85
+ ownership of such entity.
86
+
87
+ 2. License Grants and Conditions
88
+ --------------------------------
89
+
90
+ 2.1. Grants
91
+
92
+ Each Contributor hereby grants You a world-wide, royalty-free,
93
+ non-exclusive license:
94
+
95
+ (a) under intellectual property rights (other than patent or trademark)
96
+ Licensable by such Contributor to use, reproduce, make available,
97
+ modify, display, perform, distribute, and otherwise exploit its
98
+ Contributions, either on an unmodified basis, with Modifications, or
99
+ as part of a Larger Work; and
100
+
101
+ (b) under Patent Claims of such Contributor to make, use, sell, offer
102
+ for sale, have made, import, and otherwise transfer either its
103
+ Contributions or its Contributor Version.
104
+
105
+ 2.2. Effective Date
106
+
107
+ The licenses granted in Section 2.1 with respect to any Contribution
108
+ become effective for each Contribution on the date the Contributor first
109
+ distributes such Contribution.
110
+
111
+ 2.3. Limitations on Grant Scope
112
+
113
+ The licenses granted in this Section 2 are the only rights granted under
114
+ this License. No additional rights or licenses will be implied from the
115
+ distribution or licensing of Covered Software under this License.
116
+ Notwithstanding Section 2.1(b) above, no patent license is granted by a
117
+ Contributor:
118
+
119
+ (a) for any code that a Contributor has removed from Covered Software;
120
+ or
121
+
122
+ (b) for infringements caused by: (i) Your and any other third party's
123
+ modifications of Covered Software, or (ii) the combination of its
124
+ Contributions with other software (except as part of its Contributor
125
+ Version); or
126
+
127
+ (c) under Patent Claims infringed by Covered Software in the absence of
128
+ its Contributions.
129
+
130
+ This License does not grant any rights in the trademarks, service marks,
131
+ or logos of any Contributor (except as may be necessary to comply with
132
+ the notice requirements in Section 3.4).
133
+
134
+ 2.4. Subsequent Licenses
135
+
136
+ No Contributor makes additional grants as a result of Your choice to
137
+ distribute the Covered Software under a subsequent version of this
138
+ License (see Section 10.2) or under the terms of a Secondary License (if
139
+ permitted under the terms of Section 3.3).
140
+
141
+ 2.5. Representation
142
+
143
+ Each Contributor represents that the Contributor believes its
144
+ Contributions are its original creation(s) or it has sufficient rights
145
+ to grant the rights to its Contributions conveyed by this License.
146
+
147
+ 2.6. Fair Use
148
+
149
+ This License is not intended to limit any rights You have under
150
+ applicable copyright doctrines of fair use, fair dealing, or other
151
+ equivalents.
152
+
153
+ 2.7. Conditions
154
+
155
+ Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
156
+ in Section 2.1.
157
+
158
+ 3. Responsibilities
159
+ -------------------
160
+
161
+ 3.1. Distribution of Source Form
162
+
163
+ All distribution of Covered Software in Source Code Form, including any
164
+ Modifications that You create or to which You contribute, must be under
165
+ the terms of this License. You must inform recipients that the Source
166
+ Code Form of the Covered Software is governed by the terms of this
167
+ License, and how they can obtain a copy of this License. You may not
168
+ attempt to alter or restrict the recipients' rights in the Source Code
169
+ Form.
170
+
171
+ 3.2. Distribution of Executable Form
172
+
173
+ If You distribute Covered Software in Executable Form then:
174
+
175
+ (a) such Covered Software must also be made available in Source Code
176
+ Form, as described in Section 3.1, and You must inform recipients of
177
+ the Executable Form how they can obtain a copy of such Source Code
178
+ Form by reasonable means in a timely manner, at a charge no more
179
+ than the cost of distribution to the recipient; and
180
+
181
+ (b) You may distribute such Executable Form under the terms of this
182
+ License, or sublicense it under different terms, provided that the
183
+ license for the Executable Form does not attempt to limit or alter
184
+ the recipients' rights in the Source Code Form under this License.
185
+
186
+ 3.3. Distribution of a Larger Work
187
+
188
+ You may create and distribute a Larger Work under terms of Your choice,
189
+ provided that You also comply with the requirements of this License for
190
+ the Covered Software. If the Larger Work is a combination of Covered
191
+ Software with a work governed by one or more Secondary Licenses, and the
192
+ Covered Software is not Incompatible With Secondary Licenses, this
193
+ License permits You to additionally distribute such Covered Software
194
+ under the terms of such Secondary License(s), so that the recipient of
195
+ the Larger Work may, at their option, further distribute the Covered
196
+ Software under the terms of either this License or such Secondary
197
+ License(s).
198
+
199
+ 3.4. Notices
200
+
201
+ You may not remove or alter the substance of any license notices
202
+ (including copyright notices, patent notices, disclaimers of warranty,
203
+ or limitations of liability) contained within the Source Code Form of
204
+ the Covered Software, except that You may alter any license notices to
205
+ the extent required to remedy known factual inaccuracies.
206
+
207
+ 3.5. Application of Additional Terms
208
+
209
+ You may choose to offer, and to charge a fee for, warranty, support,
210
+ indemnity or liability obligations to one or more recipients of Covered
211
+ Software. However, You may do so only on Your own behalf, and not on
212
+ behalf of any Contributor. You must make it absolutely clear that any
213
+ such warranty, support, indemnity, or liability obligation is offered by
214
+ You alone, and You hereby agree to indemnify every Contributor for any
215
+ liability incurred by such Contributor as a result of warranty, support,
216
+ indemnity or liability terms You offer. You may include additional
217
+ disclaimers of warranty and limitations of liability specific to any
218
+ jurisdiction.
219
+
220
+ 4. Inability to Comply Due to Statute or Regulation
221
+ ---------------------------------------------------
222
+
223
+ If it is impossible for You to comply with any of the terms of this
224
+ License with respect to some or all of the Covered Software due to
225
+ statute, judicial order, or regulation then You must: (a) comply with
226
+ the terms of this License to the maximum extent possible; and (b)
227
+ describe the limitations and the code they affect. Such description must
228
+ be placed in a text file included with all distributions of the Covered
229
+ Software under this License. Except to the extent prohibited by statute
230
+ or regulation, such description must be sufficiently detailed for a
231
+ recipient of ordinary skill to be able to understand it.
232
+
233
+ 5. Termination
234
+ --------------
235
+
236
+ 5.1. The rights granted under this License will terminate automatically
237
+ if You fail to comply with any of its terms. However, if You become
238
+ compliant, then the rights granted under this License from a particular
239
+ Contributor are reinstated (a) provisionally, unless and until such
240
+ Contributor explicitly and finally terminates Your grants, and (b) on an
241
+ ongoing basis, if such Contributor fails to notify You of the
242
+ non-compliance by some reasonable means prior to 60 days after You have
243
+ come back into compliance. Moreover, Your grants from a particular
244
+ Contributor are reinstated on an ongoing basis if such Contributor
245
+ notifies You of the non-compliance by some reasonable means, this is the
246
+ first time You have received notice of non-compliance with this License
247
+ from such Contributor, and You become compliant prior to 30 days after
248
+ Your receipt of the notice.
249
+
250
+ 5.2. If You initiate litigation against any entity by asserting a patent
251
+ infringement claim (excluding declaratory judgment actions,
252
+ counter-claims, and cross-claims) alleging that a Contributor Version
253
+ directly or indirectly infringes any patent, then the rights granted to
254
+ You by any and all Contributors for the Covered Software under Section
255
+ 2.1 of this License shall terminate.
256
+
257
+ 5.3. In the event of termination under Sections 5.1 or 5.2 above, all
258
+ end user license agreements (excluding distributors and resellers) which
259
+ have been validly granted by You or Your distributors under this License
260
+ prior to termination shall survive termination.
261
+
262
+ ************************************************************************
263
+ * *
264
+ * 6. Disclaimer of Warranty *
265
+ * ------------------------- *
266
+ * *
267
+ * Covered Software is provided under this License on an "as is" *
268
+ * basis, without warranty of any kind, either expressed, implied, or *
269
+ * statutory, including, without limitation, warranties that the *
270
+ * Covered Software is free of defects, merchantable, fit for a *
271
+ * particular purpose or non-infringing. The entire risk as to the *
272
+ * quality and performance of the Covered Software is with You. *
273
+ * Should any Covered Software prove defective in any respect, You *
274
+ * (not any Contributor) assume the cost of any necessary servicing, *
275
+ * repair, or correction. This disclaimer of warranty constitutes an *
276
+ * essential part of this License. No use of any Covered Software is *
277
+ * authorized under this License except under this disclaimer. *
278
+ * *
279
+ ************************************************************************
280
+
281
+ ************************************************************************
282
+ * *
283
+ * 7. Limitation of Liability *
284
+ * -------------------------- *
285
+ * *
286
+ * Under no circumstances and under no legal theory, whether tort *
287
+ * (including negligence), contract, or otherwise, shall any *
288
+ * Contributor, or anyone who distributes Covered Software as *
289
+ * permitted above, be liable to You for any direct, indirect, *
290
+ * special, incidental, or consequential damages of any character *
291
+ * including, without limitation, damages for lost profits, loss of *
292
+ * goodwill, work stoppage, computer failure or malfunction, or any *
293
+ * and all other commercial damages or losses, even if such party *
294
+ * shall have been informed of the possibility of such damages. This *
295
+ * limitation of liability shall not apply to liability for death or *
296
+ * personal injury resulting from such party's negligence to the *
297
+ * extent applicable law prohibits such limitation. Some *
298
+ * jurisdictions do not allow the exclusion or limitation of *
299
+ * incidental or consequential damages, so this exclusion and *
300
+ * limitation may not apply to You. *
301
+ * *
302
+ ************************************************************************
303
+
304
+ 8. Litigation
305
+ -------------
306
+
307
+ Any litigation relating to this License may be brought only in the
308
+ courts of a jurisdiction where the defendant maintains its principal
309
+ place of business and such litigation shall be governed by laws of that
310
+ jurisdiction, without reference to its conflict-of-law provisions.
311
+ Nothing in this Section shall prevent a party's ability to bring
312
+ cross-claims or counter-claims.
313
+
314
+ 9. Miscellaneous
315
+ ----------------
316
+
317
+ This License represents the complete agreement concerning the subject
318
+ matter hereof. If any provision of this License is held to be
319
+ unenforceable, such provision shall be reformed only to the extent
320
+ necessary to make it enforceable. Any law or regulation which provides
321
+ that the language of a contract shall be construed against the drafter
322
+ shall not be used to construe this License against a Contributor.
323
+
324
+ 10. Versions of the License
325
+ ---------------------------
326
+
327
+ 10.1. New Versions
328
+
329
+ Mozilla Foundation is the license steward. Except as provided in Section
330
+ 10.3, no one other than the license steward has the right to modify or
331
+ publish new versions of this License. Each version will be given a
332
+ distinguishing version number.
333
+
334
+ 10.2. Effect of New Versions
335
+
336
+ You may distribute the Covered Software under the terms of the version
337
+ of the License under which You originally received the Covered Software,
338
+ or under the terms of any subsequent version published by the license
339
+ steward.
340
+
341
+ 10.3. Modified Versions
342
+
343
+ If you create software not governed by this License, and you want to
344
+ create a new license for such software, you may create and use a
345
+ modified version of this License if you rename the license and remove
346
+ any references to the name of the license steward (except to note that
347
+ such modified license differs from this License).
348
+
349
+ 10.4. Distributing Source Code Form that is Incompatible With Secondary
350
+ Licenses
351
+
352
+ If You choose to distribute Source Code Form that is Incompatible With
353
+ Secondary Licenses under the terms of this version of the License, the
354
+ notice described in Exhibit B of this License must be attached.
355
+
356
+ Exhibit A - Source Code Form License Notice
357
+ -------------------------------------------
358
+
359
+ This Source Code Form is subject to the terms of the Mozilla Public
360
+ License, v. 2.0. If a copy of the MPL was not distributed with this
361
+ file, You can obtain one at https://mozilla.org/MPL/2.0/.
362
+
363
+ If it is not possible or desirable to put the notice in a particular
364
+ file, then You may include the notice in a location (such as a LICENSE
365
+ file in a relevant directory) where a recipient would be likely to look
366
+ for such a notice.
367
+
368
+ You may add additional accurate notices of copyright ownership.
369
+
370
+ Exhibit B - "Incompatible With Secondary Licenses" Notice
371
+ ---------------------------------------------------------
372
+
373
+ This Source Code Form is "Incompatible With Secondary Licenses", as
374
+ defined by the Mozilla Public License, v. 2.0.
375
+ ```
data/README.md ADDED
@@ -0,0 +1,107 @@
1
+ # GlooX (pronounced _glue-X_)
2
+
3
+ Bringing [Qadron](https://github.com/qadron) together, as a very special glue.
4
+
5
+ ## Agents
6
+
7
+ `GlooX::Agent` offers _Agent_ representations, _server-side_ presences if you must,
8
+ of armed `Tiq::Nodes`.
9
+
10
+ They allow for spawning/loading of Processes on remote Nodes, with auto load-balancing
11
+ across their Grid.
12
+
13
+ ```ruby
14
+ require 'gloox'
15
+
16
+ # Start off with two Agents, in a Grid of their own
17
+ agent = GlooX::Agent.new( url: 'localhost:9997' ).start
18
+ agent2 = GlooX::Agent.new( url: 'localhost:9999', peer: 'localhost:9997' ).start
19
+
20
+ # Connect over the network for RPC.
21
+ c = Tiq::Client.new( agent2.url )
22
+
23
+ p c.spawn(
24
+ 'Child',
25
+ "#{File.dirname(__FILE__)}/test/child.rb",
26
+ { e: 27 } # Global options set for the spawned Child.
27
+ )
28
+
29
+ p c.utilization
30
+ # => 0.7281599728827168
31
+
32
+ p "--- #{c.preferred}"
33
+ #=> localhost:9997
34
+ ```
35
+
36
+ ```ruby
37
+ p $options
38
+ class Child
39
+ Slotz::Reservation.provision( self,
40
+ disk: 1 * 1_000_000_000, # bytes
41
+ memory: 20 * 1_000_000_000 # bytes
42
+ )
43
+ end
44
+ ```
45
+
46
+ ### Add-ons
47
+
48
+ For the _Add-on_ feature see [Tiq](https://github.com/qadron/tiq?tab=readme-ov-file#add-ons).
49
+
50
+ ## Groups
51
+
52
+ You can group and/or assing duty/purpose to your _Agents_ by creating channels/shared structures across them.
53
+
54
+ There is one such example below, where two Agents share a group named `my_agents`, in addition to the group `data`,
55
+ used for internal purposes.
56
+
57
+ ```ruby
58
+ require 'gloox'
59
+
60
+ n1 = GlooX::Agent.new( url: "localhost:9999" ).start
61
+ n2 = GlooX::Agent.new( url: "localhost:9998", peer: 'localhost:9999' ).start
62
+
63
+ # Add as many groups/channels/shared-data structures as you want.
64
+ n1.create_group_handler 'my_agents'
65
+ sleep 1
66
+
67
+ n2.my_agents.on_set :a1 do |k, v|
68
+ p "#{k} => #{v}"
69
+ # => "a1 => 99"
70
+ end
71
+
72
+ n1.my_agents.set :a1, 99
73
+ sleep 1
74
+
75
+ p n2.my_agents.get :a1
76
+ # => 99
77
+ ```
78
+
79
+ ## Provisioning
80
+
81
+ Due to the nature of distributed computing, resource management is key to a happy workflow.
82
+
83
+ With [Slotz](https://github.com/qadron/slotz), you can set your payloads'/classes' resource requirements (disk, memory)
84
+ beforehand and have your distributed application run smoothly within the Node that was selected automatically as its best home.
85
+
86
+ ```ruby
87
+ require 'slotz'
88
+
89
+ class MyApp
90
+ Slotz::Reservation.provision( self,
91
+ disk: 1 * 1_000_000_000, # bytes
92
+ memory: 20 * 1_000_000_000 # bytes
93
+ )
94
+ end
95
+ ```
96
+
97
+ ## Security
98
+
99
+ All communications are TLS encrypted by default, using [Raktr](https://github.com/qadron/raktr) to facilitate network
100
+ communications for RPC, with RPC being offered by [Toq](https://github.com/qadron/toq).
101
+
102
+ 4 environment variables will have you sleeping safe and sound:
103
+
104
+ * Certificate Authority (RAKTR_TLS_CA)
105
+ * Private Key (RAKTR_TLS_PRIVATE_KEY)
106
+ * Public Key (RAKTR_TLS_PUBLIC_KEY)
107
+ * Certificate (RAKTR_TLS_CERTIFICATE)
data/gloox.gemspec ADDED
@@ -0,0 +1,37 @@
1
+ # coding: utf-8
2
+
3
+ Gem::Specification.new do |s|
4
+ require_relative File.expand_path( File.dirname( __FILE__ ) ) + '/lib/gloox/version'
5
+
6
+ s.name = 'gloox'
7
+ s.version = GlooX::VERSION
8
+ s.date = Time.now.strftime( '%Y-%m-%d' )
9
+ s.summary = ''
10
+
11
+ s.homepage = 'https://github.com/qadron/cuboid'
12
+ s.email = 'tasos.laskos@gmail.com'
13
+ s.authors = [ 'Tasos Laskos' ]
14
+ s.licenses = ['MPL v2']
15
+
16
+ s.files += Dir.glob( 'config/**/**' )
17
+ s.files += Dir.glob( 'lib/**/**' )
18
+ s.files += Dir.glob( 'logs/**/**' )
19
+ s.files += Dir.glob( 'components/**/**' )
20
+ s.files += Dir.glob( 'spec/**/**' )
21
+ s.files += %w(Gemfile gloox.gemspec)
22
+ s.test_files = Dir.glob( 'spec/**/**' )
23
+
24
+ s.extra_rdoc_files = %w(README.md LICENSE.md)
25
+
26
+ s.rdoc_options = [ '--charset=UTF-8' ]
27
+
28
+ s.add_dependency 'awesome_print', '1.9.2'
29
+ s.add_dependency 'bundler'
30
+ s.add_dependency 'slotz'
31
+ s.add_dependency 'tiq'
32
+ s.add_dependency 'toq'
33
+
34
+ s.description = <<DESCRIPTION
35
+ DESCRIPTION
36
+
37
+ end
@@ -0,0 +1,106 @@
1
+ require 'slotz'
2
+ require 'tiq'
3
+
4
+ module GlooX
5
+ class Agent < Tiq::Node
6
+ PREFERENCE_STRATEGIES = Set.new([:horizontal, :vertical, :direct])
7
+
8
+ def initialize(*)
9
+ super
10
+
11
+ @loader = Slotz::Loader.new
12
+ end
13
+
14
+ def spawn( *args )
15
+ probable_strategy = args.shift
16
+ strategy = probable_strategy.to_s.to_sym
17
+
18
+ if PREFERENCE_STRATEGIES.include? strategy
19
+ spawn2( strategy, *args )
20
+ else
21
+ args.unshift probable_strategy
22
+ spawn2( nil, *args )
23
+ end
24
+
25
+ nil
26
+ end
27
+
28
+ def utilization
29
+ Slotz.utilization
30
+ end
31
+
32
+ def preferred( strategy = nil, &block )
33
+ strategy = (strategy || :vertical).to_sym
34
+ if !PREFERENCE_STRATEGIES.include? strategy
35
+ block.call :error_unknown_strategy
36
+ raise ArgumentError, "Unknown strategy: #{strategy}"
37
+ end
38
+
39
+ if strategy == :direct || !grid_member?
40
+ block.call( self.utilization >= 1.0 ? nil : @url )
41
+ return
42
+ end
43
+
44
+ pick_utilization = proc do |url, utilization|
45
+ (utilization == 1 || utilization.rpc_exception?) ?
46
+ nil : [url, utilization]
47
+ end
48
+
49
+ adjust_score_by_strategy = proc do |score|
50
+ case strategy
51
+ when :horizontal
52
+ score
53
+
54
+ when :vertical
55
+ -score
56
+ end
57
+ end
58
+
59
+ each = proc do |peer, iter|
60
+ connect_to_peer( peer ).utilization do |utilization|
61
+ iter.return pick_utilization.call( peer, utilization )
62
+ end
63
+ end
64
+
65
+ after = proc do |nodes|
66
+ nodes << pick_utilization.call( @url, self.utilization )
67
+ nodes.compact!
68
+
69
+ # All nodes are at max utilization, pass.
70
+ if nodes.empty?
71
+ block.call
72
+ next
73
+ end
74
+
75
+ block.call nodes.sort_by { |_, score| adjust_score_by_strategy.call score }[0][0]
76
+ end
77
+
78
+ @reactor.create_iterator( @peers ).map( each, after )
79
+ nil
80
+ end
81
+
82
+ private
83
+
84
+ def spawn2( strategy = nil, *args )
85
+ if !grid_member?
86
+ @loader.load( *args )
87
+ return
88
+ end
89
+
90
+ preferred strategy do |preferred_url|
91
+ if preferred_url.nil?
92
+ next
93
+ end
94
+
95
+ if preferred_url == @url
96
+ @loader.load( *args )
97
+ next
98
+ end
99
+
100
+ connect_to_peer( preferred_url ).spawn( :direct, *args ) {}
101
+ end
102
+
103
+ nil
104
+ end
105
+ end
106
+ end
@@ -0,0 +1,3 @@
1
+ module GlooX
2
+ VERSION = '0.1'
3
+ end
data/lib/gloox.rb ADDED
@@ -0,0 +1,4 @@
1
+ require_relative 'gloox/agent'
2
+
3
+ module Gloox
4
+ end
metadata ADDED
@@ -0,0 +1,122 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gloox
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.1'
5
+ platform: ruby
6
+ authors:
7
+ - Tasos Laskos
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2025-10-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: awesome_print
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '='
18
+ - !ruby/object:Gem::Version
19
+ version: 1.9.2
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '='
25
+ - !ruby/object:Gem::Version
26
+ version: 1.9.2
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: slotz
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: tiq
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: toq
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: ''
84
+ email: tasos.laskos@gmail.com
85
+ executables: []
86
+ extensions: []
87
+ extra_rdoc_files:
88
+ - README.md
89
+ - LICENSE.md
90
+ files:
91
+ - Gemfile
92
+ - LICENSE.md
93
+ - README.md
94
+ - gloox.gemspec
95
+ - lib/gloox.rb
96
+ - lib/gloox/agent.rb
97
+ - lib/gloox/version.rb
98
+ homepage: https://github.com/qadron/cuboid
99
+ licenses:
100
+ - MPL v2
101
+ metadata: {}
102
+ post_install_message:
103
+ rdoc_options:
104
+ - "--charset=UTF-8"
105
+ require_paths:
106
+ - lib
107
+ required_ruby_version: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ required_rubygems_version: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ requirements: []
118
+ rubygems_version: 3.4.22
119
+ signing_key:
120
+ specification_version: 4
121
+ summary: ''
122
+ test_files: []