datawire_mdk 2.0.5
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 +7 -0
- data/lib/datawire-quark-core.rb +1213 -0
- data/lib/datawire_mdk_md.rb +54752 -0
- data/lib/mdk.rb +962 -0
- data/lib/mdk_discovery.rb +1518 -0
- data/lib/mdk_discovery/protocol.rb +818 -0
- data/lib/mdk_discovery/synapse.rb +267 -0
- data/lib/mdk_introspection.rb +281 -0
- data/lib/mdk_introspection/aws.rb +101 -0
- data/lib/mdk_introspection/kubernetes.rb +125 -0
- data/lib/mdk_protocol.rb +1255 -0
- data/lib/mdk_runtime.rb +2135 -0
- data/lib/mdk_runtime/actors.rb +457 -0
- data/lib/mdk_runtime/files.rb +575 -0
- data/lib/mdk_runtime/promise.rb +814 -0
- data/lib/mdk_tracing.rb +369 -0
- data/lib/mdk_tracing/api.rb +188 -0
- data/lib/mdk_tracing/protocol.rb +850 -0
- data/lib/mdk_util.rb +141 -0
- data/lib/quark.rb +3684 -0
- data/lib/quark/behaviors.rb +494 -0
- data/lib/quark/concurrent.rb +1250 -0
- data/lib/quark/error.rb +84 -0
- data/lib/quark/logging.rb +278 -0
- data/lib/quark/mock.rb +1223 -0
- data/lib/quark/os.rb +286 -0
- data/lib/quark/reflect.rb +489 -0
- data/lib/quark/spi.rb +130 -0
- data/lib/quark/spi_api.rb +489 -0
- data/lib/quark/spi_api_tracing.rb +1426 -0
- data/lib/quark/test.rb +766 -0
- metadata +142 -0
data/lib/mdk_util.rb
ADDED
@@ -0,0 +1,141 @@
|
|
1
|
+
# Quark 1.0.406 run at 2016-08-31 13:21:53.028839
|
2
|
+
module Quark
|
3
|
+
require "quark"
|
4
|
+
def self.mdk_util; MdkUtil; end
|
5
|
+
module MdkUtil
|
6
|
+
require "datawire-quark-core"
|
7
|
+
require_relative 'quark/reflect' # 0 ('quark',) ()
|
8
|
+
require_relative 'mdk_runtime/promise' # 0 ('mdk_runtime',) ()
|
9
|
+
require_relative 'quark' # 0 () ()
|
10
|
+
require_relative 'datawire_mdk_md' # 0 () ()
|
11
|
+
|
12
|
+
|
13
|
+
def self.WaitForPromise; WaitForPromise; end
|
14
|
+
##
|
15
|
+
# Utility to blockingly wait for a Promise to get a value.
|
16
|
+
|
17
|
+
class WaitForPromise < ::DatawireQuarkCore::QuarkObject
|
18
|
+
extend ::DatawireQuarkCore::Static
|
19
|
+
|
20
|
+
static mdk_util_WaitForPromise_ref: -> { nil }
|
21
|
+
|
22
|
+
|
23
|
+
|
24
|
+
def initialize()
|
25
|
+
self.__init_fields__
|
26
|
+
|
27
|
+
nil
|
28
|
+
end
|
29
|
+
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
def _finished(value, done)
|
34
|
+
|
35
|
+
done.acquire()
|
36
|
+
done.wakeup()
|
37
|
+
done.release()
|
38
|
+
return true
|
39
|
+
|
40
|
+
nil
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.wait(p, timeout, description)
|
44
|
+
|
45
|
+
snapshot = p.value()
|
46
|
+
if (snapshot.hasValue())
|
47
|
+
return snapshot.getValue()
|
48
|
+
end
|
49
|
+
done = ::DatawireQuarkCore::Condition.new()
|
50
|
+
waiter = ::Quark.mdk_util.WaitForPromise.new()
|
51
|
+
p.andThen(::Quark.quark._BoundMethod.new(waiter, "_finished", ::DatawireQuarkCore::List.new([done])))
|
52
|
+
msTimeout = ((timeout) * (1000.0)).round()
|
53
|
+
done.acquire()
|
54
|
+
done.waitWakeup(msTimeout)
|
55
|
+
done.release()
|
56
|
+
snapshot = p.value()
|
57
|
+
if (!(snapshot.hasValue()))
|
58
|
+
raise (("Timeout waiting for ") + (description))
|
59
|
+
end
|
60
|
+
return snapshot.getValue()
|
61
|
+
|
62
|
+
nil
|
63
|
+
end
|
64
|
+
|
65
|
+
def _getClass()
|
66
|
+
|
67
|
+
return "mdk_util.WaitForPromise"
|
68
|
+
|
69
|
+
nil
|
70
|
+
end
|
71
|
+
|
72
|
+
def _getField(name)
|
73
|
+
|
74
|
+
return nil
|
75
|
+
|
76
|
+
nil
|
77
|
+
end
|
78
|
+
|
79
|
+
def _setField(name, value)
|
80
|
+
|
81
|
+
nil
|
82
|
+
|
83
|
+
nil
|
84
|
+
end
|
85
|
+
|
86
|
+
def __init_fields__()
|
87
|
+
|
88
|
+
|
89
|
+
nil
|
90
|
+
end
|
91
|
+
|
92
|
+
|
93
|
+
end
|
94
|
+
WaitForPromise.unlazy_statics
|
95
|
+
|
96
|
+
def self.toNativePromise(p)
|
97
|
+
|
98
|
+
if (!(false))
|
99
|
+
raise ("This method only works on Javascript.")
|
100
|
+
end
|
101
|
+
return
|
102
|
+
|
103
|
+
|
104
|
+
nil
|
105
|
+
end
|
106
|
+
|
107
|
+
def self.extend(list, value, size)
|
108
|
+
|
109
|
+
while (((list).size) < (size)) do
|
110
|
+
(list) << (value)
|
111
|
+
end
|
112
|
+
|
113
|
+
|
114
|
+
nil
|
115
|
+
end
|
116
|
+
|
117
|
+
def self.versionMatch(requested, actual)
|
118
|
+
|
119
|
+
if ((requested) == (nil))
|
120
|
+
return true
|
121
|
+
end
|
122
|
+
reqparts = ::DatawireQuarkCore.split(requested, ".")
|
123
|
+
actparts = ::DatawireQuarkCore.split(actual, ".")
|
124
|
+
::Quark.mdk_util.extend(reqparts, "0", 3)
|
125
|
+
::Quark.mdk_util.extend(actparts, "0", 3)
|
126
|
+
if (((reqparts)[0]) != ((actparts)[0]))
|
127
|
+
return false
|
128
|
+
end
|
129
|
+
if (((actparts)[1]) > ((reqparts)[1]))
|
130
|
+
return true
|
131
|
+
end
|
132
|
+
if (((actparts)[1]) < ((reqparts)[1]))
|
133
|
+
return false
|
134
|
+
end
|
135
|
+
return ((actparts)[2]) >= ((reqparts)[2])
|
136
|
+
|
137
|
+
|
138
|
+
nil
|
139
|
+
end
|
140
|
+
end # module MdkUtil
|
141
|
+
end # module Quark
|
data/lib/quark.rb
ADDED
@@ -0,0 +1,3684 @@
|
|
1
|
+
# Quark 1.0.406 run at 2016-08-31 13:21:53.028839
|
2
|
+
module Quark
|
3
|
+
require_relative "datawire-quark-core"
|
4
|
+
def self.quark; Quark; end
|
5
|
+
module Quark
|
6
|
+
require "datawire-quark-core"
|
7
|
+
require_relative 'quark/reflect' # 0 ('quark',) ()
|
8
|
+
require_relative 'datawire_mdk_md' # 0 () ()
|
9
|
+
require_relative 'quark/concurrent' # 0 ('quark',) ()
|
10
|
+
require_relative 'quark/error' # 0 ('quark',) ()
|
11
|
+
require_relative 'quark/logging' # 0 ('quark',) ()
|
12
|
+
require_relative 'quark/behaviors' # 0 ('quark',) ()
|
13
|
+
require_relative 'quark/test' # 0 ('quark',) ()
|
14
|
+
require_relative 'quark/spi' # 0 ('quark',) ()
|
15
|
+
require_relative 'quark/spi_api' # 0 ('quark',) ()
|
16
|
+
require_relative 'quark/spi_api_tracing' # 0 ('quark',) ()
|
17
|
+
require_relative 'quark/os' # 0 ('quark',) ()
|
18
|
+
require_relative 'quark/mock' # 0 ('quark',) ()
|
19
|
+
|
20
|
+
|
21
|
+
def self.Task; Task; end
|
22
|
+
class Task < ::DatawireQuarkCore::QuarkObject
|
23
|
+
extend ::DatawireQuarkCore::Static
|
24
|
+
|
25
|
+
static quark_Task_ref: -> { nil }
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
def initialize()
|
30
|
+
self.__init_fields__
|
31
|
+
|
32
|
+
nil
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
|
38
|
+
def onExecute(runtime)
|
39
|
+
raise NotImplementedError, '`Task.onExecute` is an abstract method'
|
40
|
+
|
41
|
+
nil
|
42
|
+
end
|
43
|
+
|
44
|
+
def __init_fields__()
|
45
|
+
|
46
|
+
|
47
|
+
nil
|
48
|
+
end
|
49
|
+
|
50
|
+
|
51
|
+
end
|
52
|
+
Task.unlazy_statics
|
53
|
+
|
54
|
+
def self.Runtime; Runtime; end
|
55
|
+
class Runtime < ::DatawireQuarkCore::QuarkObject
|
56
|
+
extend ::DatawireQuarkCore::Static
|
57
|
+
|
58
|
+
static quark_Runtime_ref: -> { nil }
|
59
|
+
|
60
|
+
|
61
|
+
|
62
|
+
def initialize()
|
63
|
+
self.__init_fields__
|
64
|
+
|
65
|
+
nil
|
66
|
+
end
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
def open(url, handler)
|
72
|
+
raise NotImplementedError, '`Runtime.open` is an abstract method'
|
73
|
+
|
74
|
+
nil
|
75
|
+
end
|
76
|
+
|
77
|
+
def request(request, handler)
|
78
|
+
raise NotImplementedError, '`Runtime.request` is an abstract method'
|
79
|
+
|
80
|
+
nil
|
81
|
+
end
|
82
|
+
|
83
|
+
def schedule(handler, delayInSeconds)
|
84
|
+
raise NotImplementedError, '`Runtime.schedule` is an abstract method'
|
85
|
+
|
86
|
+
nil
|
87
|
+
end
|
88
|
+
|
89
|
+
def codec()
|
90
|
+
raise NotImplementedError, '`Runtime.codec` is an abstract method'
|
91
|
+
|
92
|
+
nil
|
93
|
+
end
|
94
|
+
|
95
|
+
def serveHTTP(url, servlet)
|
96
|
+
raise NotImplementedError, '`Runtime.serveHTTP` is an abstract method'
|
97
|
+
|
98
|
+
nil
|
99
|
+
end
|
100
|
+
|
101
|
+
def serveWS(url, servlet)
|
102
|
+
raise NotImplementedError, '`Runtime.serveWS` is an abstract method'
|
103
|
+
|
104
|
+
nil
|
105
|
+
end
|
106
|
+
|
107
|
+
def respond(request, response)
|
108
|
+
raise NotImplementedError, '`Runtime.respond` is an abstract method'
|
109
|
+
|
110
|
+
nil
|
111
|
+
end
|
112
|
+
|
113
|
+
##
|
114
|
+
# Display the explanatory message and then terminate the program
|
115
|
+
|
116
|
+
def fail(message)
|
117
|
+
raise NotImplementedError, '`Runtime.fail` is an abstract method'
|
118
|
+
|
119
|
+
nil
|
120
|
+
end
|
121
|
+
|
122
|
+
##
|
123
|
+
# Get a logger for the specified topic.
|
124
|
+
|
125
|
+
def logger(topic)
|
126
|
+
raise NotImplementedError, '`Runtime.logger` is an abstract method'
|
127
|
+
|
128
|
+
nil
|
129
|
+
end
|
130
|
+
|
131
|
+
##
|
132
|
+
# Get epoch time in milliseconds
|
133
|
+
|
134
|
+
def now()
|
135
|
+
raise NotImplementedError, '`Runtime.now` is an abstract method'
|
136
|
+
|
137
|
+
nil
|
138
|
+
end
|
139
|
+
|
140
|
+
##
|
141
|
+
# Suspend execution of this thread for some number of seconds
|
142
|
+
|
143
|
+
def sleep(seconds)
|
144
|
+
raise NotImplementedError, '`Runtime.sleep` is an abstract method'
|
145
|
+
|
146
|
+
nil
|
147
|
+
end
|
148
|
+
|
149
|
+
##
|
150
|
+
# Get a v4 random UUID (Universally Unique IDentifier)
|
151
|
+
|
152
|
+
def uuid()
|
153
|
+
raise NotImplementedError, '`Runtime.uuid` is an abstract method'
|
154
|
+
|
155
|
+
nil
|
156
|
+
end
|
157
|
+
|
158
|
+
##
|
159
|
+
# Call a UnaryCallable safely, catching native exceptions.
|
160
|
+
#
|
161
|
+
# The UnaryCallable is called with null.
|
162
|
+
#
|
163
|
+
# The result of calling the UnaryCallable will be returned, unless an
|
164
|
+
# exception is caught in which case the default is returned.
|
165
|
+
#
|
166
|
+
|
167
|
+
def callSafely(callable, defaultResult)
|
168
|
+
raise NotImplementedError, '`Runtime.callSafely` is an abstract method'
|
169
|
+
|
170
|
+
nil
|
171
|
+
end
|
172
|
+
|
173
|
+
def __init_fields__()
|
174
|
+
|
175
|
+
|
176
|
+
nil
|
177
|
+
end
|
178
|
+
|
179
|
+
|
180
|
+
end
|
181
|
+
Runtime.unlazy_statics
|
182
|
+
|
183
|
+
##
|
184
|
+
# Get epoch time in milliseconds
|
185
|
+
|
186
|
+
def self.now()
|
187
|
+
|
188
|
+
return ::Quark.quark.concurrent.Context.runtime().now()
|
189
|
+
|
190
|
+
|
191
|
+
nil
|
192
|
+
end
|
193
|
+
|
194
|
+
##
|
195
|
+
# Suspend execution of this thread for some number of seconds
|
196
|
+
|
197
|
+
def self.sleep(seconds)
|
198
|
+
|
199
|
+
::Quark.quark.concurrent.Context.runtime().sleep(seconds)
|
200
|
+
|
201
|
+
|
202
|
+
nil
|
203
|
+
end
|
204
|
+
|
205
|
+
##
|
206
|
+
# Get a v4 random UUID (Universally Unique IDentifier)
|
207
|
+
|
208
|
+
def self.uuid()
|
209
|
+
|
210
|
+
return ::Quark.quark.concurrent.Context.runtime().uuid()
|
211
|
+
|
212
|
+
|
213
|
+
nil
|
214
|
+
end
|
215
|
+
|
216
|
+
|
217
|
+
def self.Maybe; Maybe; end
|
218
|
+
class Maybe < ::DatawireQuarkCore::QuarkObject
|
219
|
+
extend ::DatawireQuarkCore::Static
|
220
|
+
|
221
|
+
static quark_Maybe_quark_Object__ref: -> { nil }
|
222
|
+
|
223
|
+
|
224
|
+
|
225
|
+
def initialize()
|
226
|
+
self.__init_fields__
|
227
|
+
|
228
|
+
nil
|
229
|
+
end
|
230
|
+
|
231
|
+
|
232
|
+
|
233
|
+
|
234
|
+
def getValue()
|
235
|
+
raise NotImplementedError, '`Maybe.getValue` is an abstract method'
|
236
|
+
|
237
|
+
nil
|
238
|
+
end
|
239
|
+
|
240
|
+
def hasValue()
|
241
|
+
raise NotImplementedError, '`Maybe.hasValue` is an abstract method'
|
242
|
+
|
243
|
+
nil
|
244
|
+
end
|
245
|
+
|
246
|
+
def __init_fields__()
|
247
|
+
|
248
|
+
|
249
|
+
nil
|
250
|
+
end
|
251
|
+
|
252
|
+
|
253
|
+
end
|
254
|
+
Maybe.unlazy_statics
|
255
|
+
|
256
|
+
def self.ParsedNumber; ParsedNumber; end
|
257
|
+
class ParsedNumber < ::DatawireQuarkCore::QuarkObject
|
258
|
+
attr_accessor :_value, :_hasValue
|
259
|
+
extend ::DatawireQuarkCore::Static
|
260
|
+
|
261
|
+
static MINUS: -> { ("-")[0].ord }
|
262
|
+
static PLUS: -> { ("+")[0].ord }
|
263
|
+
static ZERO: -> { ("0")[0].ord }
|
264
|
+
static NINE: -> { ("9")[0].ord }
|
265
|
+
|
266
|
+
|
267
|
+
|
268
|
+
def initialize()
|
269
|
+
self.__init_fields__
|
270
|
+
|
271
|
+
nil
|
272
|
+
end
|
273
|
+
|
274
|
+
|
275
|
+
|
276
|
+
|
277
|
+
def getValue()
|
278
|
+
|
279
|
+
return (self)._value
|
280
|
+
|
281
|
+
nil
|
282
|
+
end
|
283
|
+
|
284
|
+
def hasValue()
|
285
|
+
|
286
|
+
return (self)._hasValue
|
287
|
+
|
288
|
+
nil
|
289
|
+
end
|
290
|
+
|
291
|
+
def _parseLong(num)
|
292
|
+
|
293
|
+
i = 0
|
294
|
+
val = (0)
|
295
|
+
neg = false
|
296
|
+
if ((i) == ((num).size))
|
297
|
+
return (0)
|
298
|
+
end
|
299
|
+
first = (num)[0].ord
|
300
|
+
if (((first) == (::Quark.quark.ParsedNumber.MINUS)) || ((first) == (::Quark.quark.ParsedNumber.PLUS)))
|
301
|
+
neg = (first) == (::Quark.quark.ParsedNumber.MINUS)
|
302
|
+
i = (i) + (1)
|
303
|
+
end
|
304
|
+
if ((i) == ((num).size))
|
305
|
+
return (0)
|
306
|
+
end
|
307
|
+
while ((i) < ((num).size)) do
|
308
|
+
d = (num)[i].ord
|
309
|
+
if (((d) < (::Quark.quark.ParsedNumber.ZERO)) || ((d) > (::Quark.quark.ParsedNumber.NINE)))
|
310
|
+
break
|
311
|
+
else
|
312
|
+
val = ((10) * (val)) + (((d) - (::Quark.quark.ParsedNumber.ZERO)))
|
313
|
+
end
|
314
|
+
i = (i) + (1)
|
315
|
+
end
|
316
|
+
(self)._hasValue = (i) == ((num).size)
|
317
|
+
if (neg)
|
318
|
+
return -(val)
|
319
|
+
else
|
320
|
+
return val
|
321
|
+
end
|
322
|
+
|
323
|
+
nil
|
324
|
+
end
|
325
|
+
|
326
|
+
def _getClass()
|
327
|
+
|
328
|
+
return "quark.ParsedNumber<quark.Object>"
|
329
|
+
|
330
|
+
nil
|
331
|
+
end
|
332
|
+
|
333
|
+
def _getField(name)
|
334
|
+
|
335
|
+
if ((name) == ("MINUS"))
|
336
|
+
return ::Quark.quark.ParsedNumber.MINUS
|
337
|
+
end
|
338
|
+
if ((name) == ("PLUS"))
|
339
|
+
return ::Quark.quark.ParsedNumber.PLUS
|
340
|
+
end
|
341
|
+
if ((name) == ("ZERO"))
|
342
|
+
return ::Quark.quark.ParsedNumber.ZERO
|
343
|
+
end
|
344
|
+
if ((name) == ("NINE"))
|
345
|
+
return ::Quark.quark.ParsedNumber.NINE
|
346
|
+
end
|
347
|
+
if ((name) == ("_value"))
|
348
|
+
return (self)._value
|
349
|
+
end
|
350
|
+
if ((name) == ("_hasValue"))
|
351
|
+
return (self)._hasValue
|
352
|
+
end
|
353
|
+
return nil
|
354
|
+
|
355
|
+
nil
|
356
|
+
end
|
357
|
+
|
358
|
+
def _setField(name, value)
|
359
|
+
|
360
|
+
if ((name) == ("MINUS"))
|
361
|
+
::Quark.quark.ParsedNumber.MINUS = ::DatawireQuarkCore.cast(value) { ::Integer }
|
362
|
+
end
|
363
|
+
if ((name) == ("PLUS"))
|
364
|
+
::Quark.quark.ParsedNumber.PLUS = ::DatawireQuarkCore.cast(value) { ::Integer }
|
365
|
+
end
|
366
|
+
if ((name) == ("ZERO"))
|
367
|
+
::Quark.quark.ParsedNumber.ZERO = ::DatawireQuarkCore.cast(value) { ::Integer }
|
368
|
+
end
|
369
|
+
if ((name) == ("NINE"))
|
370
|
+
::Quark.quark.ParsedNumber.NINE = ::DatawireQuarkCore.cast(value) { ::Integer }
|
371
|
+
end
|
372
|
+
if ((name) == ("_value"))
|
373
|
+
(self)._value = ::DatawireQuarkCore.cast(value) { ::Quark.T }
|
374
|
+
end
|
375
|
+
if ((name) == ("_hasValue"))
|
376
|
+
(self)._hasValue = ::DatawireQuarkCore.cast(value) { ::Object }
|
377
|
+
end
|
378
|
+
|
379
|
+
nil
|
380
|
+
end
|
381
|
+
|
382
|
+
def __init_fields__()
|
383
|
+
|
384
|
+
self._value = nil
|
385
|
+
self._hasValue = false
|
386
|
+
|
387
|
+
nil
|
388
|
+
end
|
389
|
+
|
390
|
+
|
391
|
+
end
|
392
|
+
ParsedNumber.unlazy_statics
|
393
|
+
|
394
|
+
def self.ParsedInt; ParsedInt; end
|
395
|
+
class ParsedInt < ::Quark.quark.ParsedNumber
|
396
|
+
attr_accessor :MIN, :MAX
|
397
|
+
extend ::DatawireQuarkCore::Static
|
398
|
+
|
399
|
+
static quark_ParsedNumber_quark_int__ref: -> { nil }
|
400
|
+
static quark_ParsedInt_ref: -> { nil }
|
401
|
+
|
402
|
+
|
403
|
+
|
404
|
+
def initialize(num)
|
405
|
+
|
406
|
+
super()
|
407
|
+
temp = self._parseLong(num)
|
408
|
+
if (((temp) < (((self).MIN))) || ((temp) > (((self).MAX))))
|
409
|
+
(self)._hasValue = false
|
410
|
+
if ((temp) < ((0)))
|
411
|
+
(self)._value = (self).MIN
|
412
|
+
else
|
413
|
+
(self)._value = (self).MAX
|
414
|
+
end
|
415
|
+
else
|
416
|
+
(self)._value = (temp)
|
417
|
+
end
|
418
|
+
|
419
|
+
nil
|
420
|
+
end
|
421
|
+
|
422
|
+
|
423
|
+
|
424
|
+
|
425
|
+
def _getClass()
|
426
|
+
|
427
|
+
return "quark.ParsedInt"
|
428
|
+
|
429
|
+
nil
|
430
|
+
end
|
431
|
+
|
432
|
+
def _getField(name)
|
433
|
+
|
434
|
+
if ((name) == ("MINUS"))
|
435
|
+
return ::Quark.quark.ParsedNumber.MINUS
|
436
|
+
end
|
437
|
+
if ((name) == ("PLUS"))
|
438
|
+
return ::Quark.quark.ParsedNumber.PLUS
|
439
|
+
end
|
440
|
+
if ((name) == ("ZERO"))
|
441
|
+
return ::Quark.quark.ParsedNumber.ZERO
|
442
|
+
end
|
443
|
+
if ((name) == ("NINE"))
|
444
|
+
return ::Quark.quark.ParsedNumber.NINE
|
445
|
+
end
|
446
|
+
if ((name) == ("_value"))
|
447
|
+
return (self)._value
|
448
|
+
end
|
449
|
+
if ((name) == ("_hasValue"))
|
450
|
+
return (self)._hasValue
|
451
|
+
end
|
452
|
+
if ((name) == ("MIN"))
|
453
|
+
return (self).MIN
|
454
|
+
end
|
455
|
+
if ((name) == ("MAX"))
|
456
|
+
return (self).MAX
|
457
|
+
end
|
458
|
+
return nil
|
459
|
+
|
460
|
+
nil
|
461
|
+
end
|
462
|
+
|
463
|
+
def _setField(name, value)
|
464
|
+
|
465
|
+
if ((name) == ("MINUS"))
|
466
|
+
::Quark.quark.ParsedNumber.MINUS = ::DatawireQuarkCore.cast(value) { ::Integer }
|
467
|
+
end
|
468
|
+
if ((name) == ("PLUS"))
|
469
|
+
::Quark.quark.ParsedNumber.PLUS = ::DatawireQuarkCore.cast(value) { ::Integer }
|
470
|
+
end
|
471
|
+
if ((name) == ("ZERO"))
|
472
|
+
::Quark.quark.ParsedNumber.ZERO = ::DatawireQuarkCore.cast(value) { ::Integer }
|
473
|
+
end
|
474
|
+
if ((name) == ("NINE"))
|
475
|
+
::Quark.quark.ParsedNumber.NINE = ::DatawireQuarkCore.cast(value) { ::Integer }
|
476
|
+
end
|
477
|
+
if ((name) == ("_value"))
|
478
|
+
(self)._value = ::DatawireQuarkCore.cast(value) { ::Integer }
|
479
|
+
end
|
480
|
+
if ((name) == ("_hasValue"))
|
481
|
+
(self)._hasValue = ::DatawireQuarkCore.cast(value) { ::Object }
|
482
|
+
end
|
483
|
+
if ((name) == ("MIN"))
|
484
|
+
(self).MIN = ::DatawireQuarkCore.cast(value) { ::Integer }
|
485
|
+
end
|
486
|
+
if ((name) == ("MAX"))
|
487
|
+
(self).MAX = ::DatawireQuarkCore.cast(value) { ::Integer }
|
488
|
+
end
|
489
|
+
|
490
|
+
nil
|
491
|
+
end
|
492
|
+
|
493
|
+
def __init_fields__()
|
494
|
+
|
495
|
+
super
|
496
|
+
self.MIN = (-(2147483647)) - (1)
|
497
|
+
self.MAX = 2147483647
|
498
|
+
|
499
|
+
nil
|
500
|
+
end
|
501
|
+
|
502
|
+
|
503
|
+
end
|
504
|
+
ParsedInt.unlazy_statics
|
505
|
+
|
506
|
+
def self.ParsedLong; ParsedLong; end
|
507
|
+
class ParsedLong < ::Quark.quark.ParsedNumber
|
508
|
+
extend ::DatawireQuarkCore::Static
|
509
|
+
|
510
|
+
static quark_ParsedNumber_quark_long__ref: -> { nil }
|
511
|
+
static quark_ParsedLong_ref: -> { nil }
|
512
|
+
|
513
|
+
|
514
|
+
|
515
|
+
def initialize(num)
|
516
|
+
|
517
|
+
super()
|
518
|
+
(self)._value = self._parseLong(num)
|
519
|
+
|
520
|
+
nil
|
521
|
+
end
|
522
|
+
|
523
|
+
|
524
|
+
|
525
|
+
|
526
|
+
def _getClass()
|
527
|
+
|
528
|
+
return "quark.ParsedLong"
|
529
|
+
|
530
|
+
nil
|
531
|
+
end
|
532
|
+
|
533
|
+
def _getField(name)
|
534
|
+
|
535
|
+
if ((name) == ("MINUS"))
|
536
|
+
return ::Quark.quark.ParsedNumber.MINUS
|
537
|
+
end
|
538
|
+
if ((name) == ("PLUS"))
|
539
|
+
return ::Quark.quark.ParsedNumber.PLUS
|
540
|
+
end
|
541
|
+
if ((name) == ("ZERO"))
|
542
|
+
return ::Quark.quark.ParsedNumber.ZERO
|
543
|
+
end
|
544
|
+
if ((name) == ("NINE"))
|
545
|
+
return ::Quark.quark.ParsedNumber.NINE
|
546
|
+
end
|
547
|
+
if ((name) == ("_value"))
|
548
|
+
return (self)._value
|
549
|
+
end
|
550
|
+
if ((name) == ("_hasValue"))
|
551
|
+
return (self)._hasValue
|
552
|
+
end
|
553
|
+
return nil
|
554
|
+
|
555
|
+
nil
|
556
|
+
end
|
557
|
+
|
558
|
+
def _setField(name, value)
|
559
|
+
|
560
|
+
if ((name) == ("MINUS"))
|
561
|
+
::Quark.quark.ParsedNumber.MINUS = ::DatawireQuarkCore.cast(value) { ::Integer }
|
562
|
+
end
|
563
|
+
if ((name) == ("PLUS"))
|
564
|
+
::Quark.quark.ParsedNumber.PLUS = ::DatawireQuarkCore.cast(value) { ::Integer }
|
565
|
+
end
|
566
|
+
if ((name) == ("ZERO"))
|
567
|
+
::Quark.quark.ParsedNumber.ZERO = ::DatawireQuarkCore.cast(value) { ::Integer }
|
568
|
+
end
|
569
|
+
if ((name) == ("NINE"))
|
570
|
+
::Quark.quark.ParsedNumber.NINE = ::DatawireQuarkCore.cast(value) { ::Integer }
|
571
|
+
end
|
572
|
+
if ((name) == ("_value"))
|
573
|
+
(self)._value = ::DatawireQuarkCore.cast(value) { ::Integer }
|
574
|
+
end
|
575
|
+
if ((name) == ("_hasValue"))
|
576
|
+
(self)._hasValue = ::DatawireQuarkCore.cast(value) { ::Object }
|
577
|
+
end
|
578
|
+
|
579
|
+
nil
|
580
|
+
end
|
581
|
+
|
582
|
+
def __init_fields__()
|
583
|
+
|
584
|
+
super
|
585
|
+
|
586
|
+
nil
|
587
|
+
end
|
588
|
+
|
589
|
+
|
590
|
+
end
|
591
|
+
ParsedLong.unlazy_statics
|
592
|
+
|
593
|
+
def self.ListUtil; ListUtil; end
|
594
|
+
class ListUtil < ::DatawireQuarkCore::QuarkObject
|
595
|
+
extend ::DatawireQuarkCore::Static
|
596
|
+
|
597
|
+
static quark_List_quark_Object__ref: -> { nil }
|
598
|
+
|
599
|
+
|
600
|
+
|
601
|
+
def initialize()
|
602
|
+
self.__init_fields__
|
603
|
+
|
604
|
+
nil
|
605
|
+
end
|
606
|
+
|
607
|
+
|
608
|
+
|
609
|
+
|
610
|
+
def slice(list, start, stop)
|
611
|
+
|
612
|
+
result = ::DatawireQuarkCore::List.new([])
|
613
|
+
if ((start) >= ((list).size))
|
614
|
+
start = (list).size
|
615
|
+
else
|
616
|
+
start = (start) % ((list).size)
|
617
|
+
end
|
618
|
+
if ((stop) >= ((list).size))
|
619
|
+
stop = (list).size
|
620
|
+
else
|
621
|
+
stop = (stop) % ((list).size)
|
622
|
+
end
|
623
|
+
idx = start
|
624
|
+
while ((idx) < (stop)) do
|
625
|
+
(result) << ((list)[idx])
|
626
|
+
idx = (idx) + (1)
|
627
|
+
end
|
628
|
+
return result
|
629
|
+
|
630
|
+
nil
|
631
|
+
end
|
632
|
+
|
633
|
+
def _getClass()
|
634
|
+
|
635
|
+
return "quark.ListUtil<quark.Object>"
|
636
|
+
|
637
|
+
nil
|
638
|
+
end
|
639
|
+
|
640
|
+
def _getField(name)
|
641
|
+
|
642
|
+
return nil
|
643
|
+
|
644
|
+
nil
|
645
|
+
end
|
646
|
+
|
647
|
+
def _setField(name, value)
|
648
|
+
|
649
|
+
nil
|
650
|
+
|
651
|
+
nil
|
652
|
+
end
|
653
|
+
|
654
|
+
def __init_fields__()
|
655
|
+
|
656
|
+
|
657
|
+
nil
|
658
|
+
end
|
659
|
+
|
660
|
+
|
661
|
+
end
|
662
|
+
ListUtil.unlazy_statics
|
663
|
+
|
664
|
+
def self.UnaryCallable; UnaryCallable; end
|
665
|
+
class UnaryCallable < ::DatawireQuarkCore::QuarkObject
|
666
|
+
extend ::DatawireQuarkCore::Static
|
667
|
+
|
668
|
+
static quark_UnaryCallable_ref: -> { nil }
|
669
|
+
|
670
|
+
|
671
|
+
|
672
|
+
def initialize()
|
673
|
+
self.__init_fields__
|
674
|
+
|
675
|
+
nil
|
676
|
+
end
|
677
|
+
|
678
|
+
|
679
|
+
|
680
|
+
|
681
|
+
def call(arg)
|
682
|
+
raise NotImplementedError, '`UnaryCallable.call` is an abstract method'
|
683
|
+
|
684
|
+
nil
|
685
|
+
end
|
686
|
+
|
687
|
+
def __init_fields__()
|
688
|
+
|
689
|
+
|
690
|
+
nil
|
691
|
+
end
|
692
|
+
|
693
|
+
|
694
|
+
end
|
695
|
+
UnaryCallable.unlazy_statics
|
696
|
+
|
697
|
+
##
|
698
|
+
# Allow native code to call UnaryCallables.
|
699
|
+
|
700
|
+
def self.callUnaryCallable(callee, arg)
|
701
|
+
|
702
|
+
return (callee).call(arg)
|
703
|
+
|
704
|
+
|
705
|
+
nil
|
706
|
+
end
|
707
|
+
|
708
|
+
|
709
|
+
def self._getLogger(topic)
|
710
|
+
|
711
|
+
if (::Quark.quark.logging.Config._autoconfig())
|
712
|
+
::Quark.quark.logging.makeConfig().configure()
|
713
|
+
end
|
714
|
+
return ::Quark.quark.concurrent.Context.runtime().logger(topic)
|
715
|
+
|
716
|
+
|
717
|
+
nil
|
718
|
+
end
|
719
|
+
|
720
|
+
|
721
|
+
|
722
|
+
##
|
723
|
+
# Serializes object tree into JSON. skips over fields starting with underscore
|
724
|
+
|
725
|
+
def self.toJSON(obj, cls)
|
726
|
+
|
727
|
+
result = ::DatawireQuarkCore::JSONObject.new
|
728
|
+
if ((obj) == (nil))
|
729
|
+
result.setNull()
|
730
|
+
return result
|
731
|
+
end
|
732
|
+
if (((cls) == (nil)) || (cls.isAbstract()))
|
733
|
+
cls = ::Quark.quark.reflect.QuarkClass.get(::DatawireQuarkCore._getClass(obj))
|
734
|
+
end
|
735
|
+
idx = 0
|
736
|
+
if (((cls).name) == ("quark.String"))
|
737
|
+
result.setString(::DatawireQuarkCore.cast(obj) { ::String })
|
738
|
+
return result
|
739
|
+
end
|
740
|
+
if (((((((cls).name) == ("quark.byte")) || (((cls).name) == ("quark.short"))) || (((cls).name) == ("quark.int"))) || (((cls).name) == ("quark.long"))) || (((cls).name) == ("quark.float")))
|
741
|
+
result.setNumber(obj)
|
742
|
+
return result
|
743
|
+
end
|
744
|
+
if (((cls).name) == ("quark.List"))
|
745
|
+
result.setList()
|
746
|
+
list = ::DatawireQuarkCore.cast(obj) { ::DatawireQuarkCore::List }
|
747
|
+
while ((idx) < ((list).size)) do
|
748
|
+
result.setListItem(idx, ::Quark.quark.toJSON((list)[idx], nil))
|
749
|
+
idx = (idx) + (1)
|
750
|
+
end
|
751
|
+
return result
|
752
|
+
end
|
753
|
+
if (((cls).name) == ("quark.Map"))
|
754
|
+
result.setObject()
|
755
|
+
map = ::DatawireQuarkCore.cast(obj) { ::Hash }
|
756
|
+
keys = ::DatawireQuarkCore::List.new((map).keys)
|
757
|
+
key = nil
|
758
|
+
strKey = nil
|
759
|
+
keyMap = {}
|
760
|
+
strKeys = ::DatawireQuarkCore::List.new([])
|
761
|
+
while ((idx) < ((keys).size)) do
|
762
|
+
key = (keys)[idx]
|
763
|
+
strKey = (key).to_s
|
764
|
+
strKey = ::Quark.quark.toJSON(key, (cls.getParameters())[0]).toString()
|
765
|
+
(keyMap)[strKey] = (key)
|
766
|
+
(strKeys) << (strKey)
|
767
|
+
idx = (idx) + (1)
|
768
|
+
end
|
769
|
+
(strKeys).sort!
|
770
|
+
idx = 0
|
771
|
+
hash = ::DatawireQuarkCore.cast(nil) { ::DatawireQuarkCore::JSONObject }
|
772
|
+
hashIdx = 0
|
773
|
+
while ((idx) < ((strKeys).size)) do
|
774
|
+
strKey = (strKeys)[idx]
|
775
|
+
key = (keyMap)[strKey]
|
776
|
+
value = (map)[key]
|
777
|
+
if (((::Quark.quark.reflect.QuarkClass.get(::DatawireQuarkCore._getClass(key))).name) == ("quark.String"))
|
778
|
+
(result).setObjectItem((::DatawireQuarkCore.cast(key) { ::String }), (::Quark.quark.toJSON(value, (cls.getParameters())[1])))
|
779
|
+
else
|
780
|
+
if ((hash) == (nil))
|
781
|
+
hash = ::DatawireQuarkCore::JSONObject.new.setList()
|
782
|
+
(result).setObjectItem(("$map"), (hash))
|
783
|
+
end
|
784
|
+
hash.setListItem(hashIdx, ::Quark.quark.toJSON(key, (cls.getParameters())[0]))
|
785
|
+
hash.setListItem((hashIdx) + (1), ::Quark.quark.toJSON(value, (cls.getParameters())[1]))
|
786
|
+
hashIdx = (hashIdx) + (2)
|
787
|
+
end
|
788
|
+
idx = (idx) + (1)
|
789
|
+
end
|
790
|
+
return result
|
791
|
+
end
|
792
|
+
(result).setObjectItem(("$class"), (::DatawireQuarkCore::JSONObject.new.setString((cls).id)))
|
793
|
+
fields = cls.getFields()
|
794
|
+
while ((idx) < ((fields).size)) do
|
795
|
+
fieldName = ((fields)[idx]).name
|
796
|
+
if (!((fieldName).start_with?("_")))
|
797
|
+
(result).setObjectItem((fieldName), (::Quark.quark.toJSON((obj)._getField(fieldName), (fields)[idx].getType())))
|
798
|
+
end
|
799
|
+
idx = (idx) + (1)
|
800
|
+
end
|
801
|
+
return result
|
802
|
+
|
803
|
+
|
804
|
+
nil
|
805
|
+
end
|
806
|
+
|
807
|
+
##
|
808
|
+
# deserialize json into provided result object. Skip over fields starting with underscore
|
809
|
+
|
810
|
+
def self.fromJSON(cls, result, json)
|
811
|
+
|
812
|
+
if ((((json) == (nil)) || (json.isNull())) || (json.isUndefined()))
|
813
|
+
return nil
|
814
|
+
end
|
815
|
+
idx = 0
|
816
|
+
if (((cls) == (nil)) || (cls.isAbstract()))
|
817
|
+
type = json.getType()
|
818
|
+
if ((type) == ("boolean"))
|
819
|
+
cls = ::Quark.quark.reflect.QuarkClass.BOOL
|
820
|
+
end
|
821
|
+
if ((type) == ("number"))
|
822
|
+
cls = ::Quark.quark.reflect.QuarkClass.BOOL
|
823
|
+
end
|
824
|
+
if ((type) == ("string"))
|
825
|
+
cls = ::Quark.quark.reflect.QuarkClass.STRING
|
826
|
+
end
|
827
|
+
if ((type) == ("list"))
|
828
|
+
if ((result) == (nil))
|
829
|
+
result = ::DatawireQuarkCore::List.new([])
|
830
|
+
end
|
831
|
+
cls = ::Quark.quark.reflect.QuarkClass.get(::DatawireQuarkCore._getClass(result))
|
832
|
+
end
|
833
|
+
if ((type) == ("object"))
|
834
|
+
klazz = (json).getObjectItem("$class").getString()
|
835
|
+
if ((klazz) != (nil))
|
836
|
+
cls = ::Quark.quark.reflect.QuarkClass.get(klazz)
|
837
|
+
else
|
838
|
+
if ((result) == (nil))
|
839
|
+
result = {}
|
840
|
+
end
|
841
|
+
cls = ::Quark.quark.reflect.QuarkClass.get(::DatawireQuarkCore._getClass(result))
|
842
|
+
end
|
843
|
+
end
|
844
|
+
end
|
845
|
+
if ((result) == (nil))
|
846
|
+
if (((cls).name) == ("quark.String"))
|
847
|
+
s = json.getString()
|
848
|
+
return s
|
849
|
+
end
|
850
|
+
if (((cls).name) == ("quark.float"))
|
851
|
+
flt = json.getNumber()
|
852
|
+
return flt
|
853
|
+
end
|
854
|
+
if (((cls).name) == ("quark.int"))
|
855
|
+
i = (json).getNumber.round
|
856
|
+
return i
|
857
|
+
end
|
858
|
+
if (((cls).name) == ("quark.long"))
|
859
|
+
l = (json.getNumber()).round()
|
860
|
+
return l
|
861
|
+
end
|
862
|
+
if (((cls).name) == ("quark.bool"))
|
863
|
+
b = json.getBool()
|
864
|
+
return b
|
865
|
+
end
|
866
|
+
result = cls.construct(::DatawireQuarkCore::List.new([]))
|
867
|
+
end
|
868
|
+
if (((cls).name) == ("quark.List"))
|
869
|
+
list = ::DatawireQuarkCore.cast(result) { ::DatawireQuarkCore::List }
|
870
|
+
while ((idx) < (json.size())) do
|
871
|
+
(list) << (::Quark.quark.fromJSON((cls.getParameters())[0], nil, json.getListItem(idx)))
|
872
|
+
idx = (idx) + (1)
|
873
|
+
end
|
874
|
+
return list
|
875
|
+
end
|
876
|
+
if (((cls).name) == ("quark.Map"))
|
877
|
+
map = ::DatawireQuarkCore.cast(result) { ::Hash }
|
878
|
+
keys = json.keys()
|
879
|
+
while ((idx) < ((keys).size)) do
|
880
|
+
key = (keys)[idx]
|
881
|
+
value = (json).getObjectItem(key)
|
882
|
+
if ((key) != ("$map"))
|
883
|
+
(map)[key] = (::Quark.quark.fromJSON((cls.getParameters())[1], nil, value))
|
884
|
+
else
|
885
|
+
hashIdx = 0
|
886
|
+
while ((hashIdx) < (value.size())) do
|
887
|
+
hkey = ::Quark.quark.fromJSON((cls.getParameters())[0], nil, value.getListItem(hashIdx))
|
888
|
+
hvalue = ::Quark.quark.fromJSON((cls.getParameters())[1], nil, value.getListItem((hashIdx) + (1)))
|
889
|
+
(map)[hkey] = (hvalue)
|
890
|
+
hashIdx = (hashIdx) + (2)
|
891
|
+
end
|
892
|
+
end
|
893
|
+
idx = (idx) + (1)
|
894
|
+
end
|
895
|
+
end
|
896
|
+
fields = cls.getFields()
|
897
|
+
while ((idx) < ((fields).size)) do
|
898
|
+
f = (fields)[idx]
|
899
|
+
idx = (idx) + (1)
|
900
|
+
if (((f).name).start_with?("_"))
|
901
|
+
next
|
902
|
+
end
|
903
|
+
if (((json).getObjectItem((f).name).isDefined()) && (!((json).getObjectItem((f).name).isNull())))
|
904
|
+
(result)._setField(((f).name), (::Quark.quark.fromJSON(f.getType(), nil, (json).getObjectItem((f).name))))
|
905
|
+
end
|
906
|
+
end
|
907
|
+
return result
|
908
|
+
|
909
|
+
|
910
|
+
nil
|
911
|
+
end
|
912
|
+
|
913
|
+
|
914
|
+
def self.ServletError; ServletError; end
|
915
|
+
class ServletError < ::Quark.quark.error.Error
|
916
|
+
extend ::DatawireQuarkCore::Static
|
917
|
+
|
918
|
+
static quark_ServletError_ref: -> { nil }
|
919
|
+
|
920
|
+
|
921
|
+
|
922
|
+
def initialize(message)
|
923
|
+
|
924
|
+
super(message)
|
925
|
+
|
926
|
+
nil
|
927
|
+
end
|
928
|
+
|
929
|
+
|
930
|
+
|
931
|
+
|
932
|
+
def _getClass()
|
933
|
+
|
934
|
+
return "quark.ServletError"
|
935
|
+
|
936
|
+
nil
|
937
|
+
end
|
938
|
+
|
939
|
+
def _getField(name)
|
940
|
+
|
941
|
+
if ((name) == ("message"))
|
942
|
+
return (self).message
|
943
|
+
end
|
944
|
+
return nil
|
945
|
+
|
946
|
+
nil
|
947
|
+
end
|
948
|
+
|
949
|
+
def _setField(name, value)
|
950
|
+
|
951
|
+
if ((name) == ("message"))
|
952
|
+
(self).message = ::DatawireQuarkCore.cast(value) { ::String }
|
953
|
+
end
|
954
|
+
|
955
|
+
nil
|
956
|
+
end
|
957
|
+
|
958
|
+
def __init_fields__()
|
959
|
+
|
960
|
+
super
|
961
|
+
|
962
|
+
nil
|
963
|
+
end
|
964
|
+
|
965
|
+
|
966
|
+
end
|
967
|
+
ServletError.unlazy_statics
|
968
|
+
|
969
|
+
def self.Servlet; Servlet; end
|
970
|
+
##
|
971
|
+
# A service addresable with an url
|
972
|
+
|
973
|
+
class Servlet < ::DatawireQuarkCore::QuarkObject
|
974
|
+
extend ::DatawireQuarkCore::Static
|
975
|
+
|
976
|
+
static quark_Servlet_ref: -> { nil }
|
977
|
+
|
978
|
+
|
979
|
+
|
980
|
+
def initialize()
|
981
|
+
self.__init_fields__
|
982
|
+
|
983
|
+
nil
|
984
|
+
end
|
985
|
+
|
986
|
+
|
987
|
+
|
988
|
+
|
989
|
+
##
|
990
|
+
# called after the servlet is successfully installed. The url will be the actual url used, important especially if ephemeral port was requested
|
991
|
+
|
992
|
+
def onServletInit(url, runtime)
|
993
|
+
|
994
|
+
nil
|
995
|
+
|
996
|
+
nil
|
997
|
+
end
|
998
|
+
|
999
|
+
##
|
1000
|
+
# called if the servlet could not be installed
|
1001
|
+
|
1002
|
+
def onServletError(url, error)
|
1003
|
+
|
1004
|
+
nil
|
1005
|
+
|
1006
|
+
nil
|
1007
|
+
end
|
1008
|
+
|
1009
|
+
##
|
1010
|
+
# called when the servlet is removed
|
1011
|
+
|
1012
|
+
def onServletEnd(url)
|
1013
|
+
|
1014
|
+
nil
|
1015
|
+
|
1016
|
+
nil
|
1017
|
+
end
|
1018
|
+
|
1019
|
+
def __init_fields__()
|
1020
|
+
|
1021
|
+
|
1022
|
+
nil
|
1023
|
+
end
|
1024
|
+
|
1025
|
+
|
1026
|
+
end
|
1027
|
+
Servlet.unlazy_statics
|
1028
|
+
|
1029
|
+
def self.Resolver; Resolver; end
|
1030
|
+
class Resolver < ::DatawireQuarkCore::QuarkObject
|
1031
|
+
extend ::DatawireQuarkCore::Static
|
1032
|
+
|
1033
|
+
static quark_Resolver_ref: -> { nil }
|
1034
|
+
|
1035
|
+
|
1036
|
+
|
1037
|
+
def initialize()
|
1038
|
+
self.__init_fields__
|
1039
|
+
|
1040
|
+
nil
|
1041
|
+
end
|
1042
|
+
|
1043
|
+
|
1044
|
+
|
1045
|
+
|
1046
|
+
def resolve(serviceName)
|
1047
|
+
raise NotImplementedError, '`Resolver.resolve` is an abstract method'
|
1048
|
+
|
1049
|
+
nil
|
1050
|
+
end
|
1051
|
+
|
1052
|
+
def __init_fields__()
|
1053
|
+
|
1054
|
+
|
1055
|
+
nil
|
1056
|
+
end
|
1057
|
+
|
1058
|
+
|
1059
|
+
end
|
1060
|
+
Resolver.unlazy_statics
|
1061
|
+
|
1062
|
+
def self.ResponseHolder; ResponseHolder; end
|
1063
|
+
class ResponseHolder < ::DatawireQuarkCore::QuarkObject
|
1064
|
+
attr_accessor :response, :failure
|
1065
|
+
extend ::DatawireQuarkCore::Static
|
1066
|
+
|
1067
|
+
static quark_ResponseHolder_ref: -> { nil }
|
1068
|
+
|
1069
|
+
|
1070
|
+
|
1071
|
+
def initialize()
|
1072
|
+
self.__init_fields__
|
1073
|
+
|
1074
|
+
nil
|
1075
|
+
end
|
1076
|
+
|
1077
|
+
|
1078
|
+
|
1079
|
+
|
1080
|
+
def onHTTPResponse(request, response)
|
1081
|
+
|
1082
|
+
(self).response = response
|
1083
|
+
|
1084
|
+
nil
|
1085
|
+
end
|
1086
|
+
|
1087
|
+
def onHTTPError(request, error)
|
1088
|
+
|
1089
|
+
@failure = error
|
1090
|
+
|
1091
|
+
nil
|
1092
|
+
end
|
1093
|
+
|
1094
|
+
def _getClass()
|
1095
|
+
|
1096
|
+
return "quark.ResponseHolder"
|
1097
|
+
|
1098
|
+
nil
|
1099
|
+
end
|
1100
|
+
|
1101
|
+
def _getField(name)
|
1102
|
+
|
1103
|
+
if ((name) == ("response"))
|
1104
|
+
return (self).response
|
1105
|
+
end
|
1106
|
+
if ((name) == ("failure"))
|
1107
|
+
return (self).failure
|
1108
|
+
end
|
1109
|
+
return nil
|
1110
|
+
|
1111
|
+
nil
|
1112
|
+
end
|
1113
|
+
|
1114
|
+
def _setField(name, value)
|
1115
|
+
|
1116
|
+
if ((name) == ("response"))
|
1117
|
+
(self).response = ::DatawireQuarkCore.cast(value) { ::Quark.quark.HTTPResponse }
|
1118
|
+
end
|
1119
|
+
if ((name) == ("failure"))
|
1120
|
+
(self).failure = ::DatawireQuarkCore.cast(value) { ::Quark.quark.HTTPError }
|
1121
|
+
end
|
1122
|
+
|
1123
|
+
nil
|
1124
|
+
end
|
1125
|
+
|
1126
|
+
def onHTTPInit(request)
|
1127
|
+
|
1128
|
+
nil
|
1129
|
+
|
1130
|
+
nil
|
1131
|
+
end
|
1132
|
+
|
1133
|
+
def onHTTPFinal(request)
|
1134
|
+
|
1135
|
+
nil
|
1136
|
+
|
1137
|
+
nil
|
1138
|
+
end
|
1139
|
+
|
1140
|
+
def __init_fields__()
|
1141
|
+
|
1142
|
+
self.response = nil
|
1143
|
+
self.failure = nil
|
1144
|
+
|
1145
|
+
nil
|
1146
|
+
end
|
1147
|
+
|
1148
|
+
|
1149
|
+
end
|
1150
|
+
ResponseHolder.unlazy_statics
|
1151
|
+
|
1152
|
+
def self.Service; Service; end
|
1153
|
+
class Service < ::DatawireQuarkCore::QuarkObject
|
1154
|
+
extend ::DatawireQuarkCore::Static
|
1155
|
+
|
1156
|
+
static quark_Service_ref: -> { nil }
|
1157
|
+
|
1158
|
+
|
1159
|
+
|
1160
|
+
def initialize()
|
1161
|
+
self.__init_fields__
|
1162
|
+
|
1163
|
+
nil
|
1164
|
+
end
|
1165
|
+
|
1166
|
+
|
1167
|
+
|
1168
|
+
|
1169
|
+
def getName()
|
1170
|
+
raise NotImplementedError, '`Service.getName` is an abstract method'
|
1171
|
+
|
1172
|
+
nil
|
1173
|
+
end
|
1174
|
+
|
1175
|
+
def getInstance()
|
1176
|
+
raise NotImplementedError, '`Service.getInstance` is an abstract method'
|
1177
|
+
|
1178
|
+
nil
|
1179
|
+
end
|
1180
|
+
|
1181
|
+
def getTimeout()
|
1182
|
+
raise NotImplementedError, '`Service.getTimeout` is an abstract method'
|
1183
|
+
|
1184
|
+
nil
|
1185
|
+
end
|
1186
|
+
|
1187
|
+
def rpc(methodName, args)
|
1188
|
+
|
1189
|
+
rpc = ::Quark.quark.behaviors.RPC.new(self, methodName)
|
1190
|
+
return rpc.call(args)
|
1191
|
+
|
1192
|
+
nil
|
1193
|
+
end
|
1194
|
+
|
1195
|
+
def __init_fields__()
|
1196
|
+
|
1197
|
+
|
1198
|
+
nil
|
1199
|
+
end
|
1200
|
+
|
1201
|
+
|
1202
|
+
end
|
1203
|
+
Service.unlazy_statics
|
1204
|
+
|
1205
|
+
def self.BaseService; BaseService; end
|
1206
|
+
class BaseService < ::DatawireQuarkCore::QuarkObject
|
1207
|
+
extend ::DatawireQuarkCore::Static
|
1208
|
+
|
1209
|
+
static quark_BaseService_ref: -> { nil }
|
1210
|
+
|
1211
|
+
|
1212
|
+
|
1213
|
+
def initialize()
|
1214
|
+
self.__init_fields__
|
1215
|
+
|
1216
|
+
nil
|
1217
|
+
end
|
1218
|
+
|
1219
|
+
|
1220
|
+
|
1221
|
+
|
1222
|
+
def getName()
|
1223
|
+
|
1224
|
+
return ::DatawireQuarkCore.cast(nil) { ::String }
|
1225
|
+
|
1226
|
+
nil
|
1227
|
+
end
|
1228
|
+
|
1229
|
+
def getInstance()
|
1230
|
+
|
1231
|
+
return ::DatawireQuarkCore.cast(nil) { ::Quark.quark.ServiceInstance }
|
1232
|
+
|
1233
|
+
nil
|
1234
|
+
end
|
1235
|
+
|
1236
|
+
def getTimeout()
|
1237
|
+
|
1238
|
+
return -(1.0)
|
1239
|
+
|
1240
|
+
nil
|
1241
|
+
end
|
1242
|
+
|
1243
|
+
def _getClass()
|
1244
|
+
|
1245
|
+
return "quark.BaseService"
|
1246
|
+
|
1247
|
+
nil
|
1248
|
+
end
|
1249
|
+
|
1250
|
+
def _getField(name)
|
1251
|
+
|
1252
|
+
return nil
|
1253
|
+
|
1254
|
+
nil
|
1255
|
+
end
|
1256
|
+
|
1257
|
+
def _setField(name, value)
|
1258
|
+
|
1259
|
+
nil
|
1260
|
+
|
1261
|
+
nil
|
1262
|
+
end
|
1263
|
+
|
1264
|
+
def rpc(methodName, args)
|
1265
|
+
|
1266
|
+
rpc = ::Quark.quark.behaviors.RPC.new(self, methodName)
|
1267
|
+
return rpc.call(args)
|
1268
|
+
|
1269
|
+
nil
|
1270
|
+
end
|
1271
|
+
|
1272
|
+
def __init_fields__()
|
1273
|
+
|
1274
|
+
|
1275
|
+
nil
|
1276
|
+
end
|
1277
|
+
|
1278
|
+
|
1279
|
+
end
|
1280
|
+
BaseService.unlazy_statics
|
1281
|
+
|
1282
|
+
def self.ServiceInstance; ServiceInstance; end
|
1283
|
+
class ServiceInstance < ::DatawireQuarkCore::QuarkObject
|
1284
|
+
attr_accessor :serviceName, :url, :breaker
|
1285
|
+
extend ::DatawireQuarkCore::Static
|
1286
|
+
|
1287
|
+
static quark_ServiceInstance_ref: -> { nil }
|
1288
|
+
|
1289
|
+
|
1290
|
+
|
1291
|
+
def initialize(serviceName, url, failureLimit, retestDelay)
|
1292
|
+
|
1293
|
+
self.__init_fields__
|
1294
|
+
(self).serviceName = serviceName
|
1295
|
+
(self).url = url
|
1296
|
+
(self).breaker = ::Quark.quark.behaviors.CircuitBreaker.new((((("[") + (serviceName)) + (" at ")) + (url)) + ("]"), failureLimit, retestDelay)
|
1297
|
+
|
1298
|
+
nil
|
1299
|
+
end
|
1300
|
+
|
1301
|
+
|
1302
|
+
|
1303
|
+
|
1304
|
+
def isActive()
|
1305
|
+
|
1306
|
+
return ((self).breaker).active
|
1307
|
+
|
1308
|
+
nil
|
1309
|
+
end
|
1310
|
+
|
1311
|
+
def getURL()
|
1312
|
+
|
1313
|
+
return (self).url
|
1314
|
+
|
1315
|
+
nil
|
1316
|
+
end
|
1317
|
+
|
1318
|
+
def succeed(info)
|
1319
|
+
|
1320
|
+
if (!(self.isActive()))
|
1321
|
+
::Quark.quark.Client.logger.info(((("- CLOSE breaker for ") + ((self).serviceName)) + (" at ")) + ((self).url))
|
1322
|
+
end
|
1323
|
+
(self).breaker.succeed()
|
1324
|
+
|
1325
|
+
nil
|
1326
|
+
end
|
1327
|
+
|
1328
|
+
def fail(info)
|
1329
|
+
|
1330
|
+
if (!(self.isActive()))
|
1331
|
+
::Quark.quark.Client.logger.warn(((("- OPEN breaker for ") + ((self).serviceName)) + (" at ")) + ((self).url))
|
1332
|
+
end
|
1333
|
+
(self).breaker.fail()
|
1334
|
+
|
1335
|
+
nil
|
1336
|
+
end
|
1337
|
+
|
1338
|
+
def _getClass()
|
1339
|
+
|
1340
|
+
return "quark.ServiceInstance"
|
1341
|
+
|
1342
|
+
nil
|
1343
|
+
end
|
1344
|
+
|
1345
|
+
def _getField(name)
|
1346
|
+
|
1347
|
+
if ((name) == ("serviceName"))
|
1348
|
+
return (self).serviceName
|
1349
|
+
end
|
1350
|
+
if ((name) == ("url"))
|
1351
|
+
return (self).url
|
1352
|
+
end
|
1353
|
+
if ((name) == ("breaker"))
|
1354
|
+
return (self).breaker
|
1355
|
+
end
|
1356
|
+
return nil
|
1357
|
+
|
1358
|
+
nil
|
1359
|
+
end
|
1360
|
+
|
1361
|
+
def _setField(name, value)
|
1362
|
+
|
1363
|
+
if ((name) == ("serviceName"))
|
1364
|
+
(self).serviceName = ::DatawireQuarkCore.cast(value) { ::String }
|
1365
|
+
end
|
1366
|
+
if ((name) == ("url"))
|
1367
|
+
(self).url = ::DatawireQuarkCore.cast(value) { ::String }
|
1368
|
+
end
|
1369
|
+
if ((name) == ("breaker"))
|
1370
|
+
(self).breaker = ::DatawireQuarkCore.cast(value) { ::Quark.quark.behaviors.CircuitBreaker }
|
1371
|
+
end
|
1372
|
+
|
1373
|
+
nil
|
1374
|
+
end
|
1375
|
+
|
1376
|
+
def __init_fields__()
|
1377
|
+
|
1378
|
+
self.serviceName = nil
|
1379
|
+
self.url = nil
|
1380
|
+
self.breaker = nil
|
1381
|
+
|
1382
|
+
nil
|
1383
|
+
end
|
1384
|
+
|
1385
|
+
|
1386
|
+
end
|
1387
|
+
ServiceInstance.unlazy_statics
|
1388
|
+
|
1389
|
+
def self.DegenerateResolver; DegenerateResolver; end
|
1390
|
+
##
|
1391
|
+
# DegenerateResolver assumes that the serviceName is an URL.
|
1392
|
+
|
1393
|
+
class DegenerateResolver < ::DatawireQuarkCore::QuarkObject
|
1394
|
+
extend ::DatawireQuarkCore::Static
|
1395
|
+
|
1396
|
+
static quark_DegenerateResolver_ref: -> { nil }
|
1397
|
+
|
1398
|
+
|
1399
|
+
|
1400
|
+
def initialize()
|
1401
|
+
self.__init_fields__
|
1402
|
+
|
1403
|
+
nil
|
1404
|
+
end
|
1405
|
+
|
1406
|
+
|
1407
|
+
|
1408
|
+
|
1409
|
+
def resolve(serviceName)
|
1410
|
+
|
1411
|
+
return ::DatawireQuarkCore::List.new([serviceName])
|
1412
|
+
|
1413
|
+
nil
|
1414
|
+
end
|
1415
|
+
|
1416
|
+
def _getClass()
|
1417
|
+
|
1418
|
+
return "quark.DegenerateResolver"
|
1419
|
+
|
1420
|
+
nil
|
1421
|
+
end
|
1422
|
+
|
1423
|
+
def _getField(name)
|
1424
|
+
|
1425
|
+
return nil
|
1426
|
+
|
1427
|
+
nil
|
1428
|
+
end
|
1429
|
+
|
1430
|
+
def _setField(name, value)
|
1431
|
+
|
1432
|
+
nil
|
1433
|
+
|
1434
|
+
nil
|
1435
|
+
end
|
1436
|
+
|
1437
|
+
def __init_fields__()
|
1438
|
+
|
1439
|
+
|
1440
|
+
nil
|
1441
|
+
end
|
1442
|
+
|
1443
|
+
|
1444
|
+
end
|
1445
|
+
DegenerateResolver.unlazy_statics
|
1446
|
+
|
1447
|
+
def self.Client; Client; end
|
1448
|
+
class Client < ::DatawireQuarkCore::QuarkObject
|
1449
|
+
attr_accessor :resolver, :serviceName, :_timeout, :_failureLimit, :_retestDelay, :mutex, :instanceMap, :counter
|
1450
|
+
extend ::DatawireQuarkCore::Static
|
1451
|
+
|
1452
|
+
static logger: -> { ::Quark.quark._getLogger("quark.client") }
|
1453
|
+
static quark_Map_quark_String_quark_ServiceInstance__ref: -> { nil }
|
1454
|
+
static quark_Client_ref: -> { nil }
|
1455
|
+
|
1456
|
+
|
1457
|
+
|
1458
|
+
def initialize(serviceName)
|
1459
|
+
|
1460
|
+
self.__init_fields__
|
1461
|
+
(self).serviceName = serviceName
|
1462
|
+
(self).resolver = ::Quark.quark.DegenerateResolver.new()
|
1463
|
+
(self)._timeout = 0.0
|
1464
|
+
(self).mutex = ::DatawireQuarkCore::Lock.new()
|
1465
|
+
(self).instanceMap = {}
|
1466
|
+
(self).counter = 0
|
1467
|
+
failureLimit = ::DatawireQuarkCore.cast((self)._getField("failureLimit")) { ::Integer }
|
1468
|
+
if ((failureLimit) != (nil))
|
1469
|
+
(self)._failureLimit = failureLimit
|
1470
|
+
end
|
1471
|
+
::Quark.quark.Client.logger.info((((self).to_s) + (" failureLimit ")) + (((self)._failureLimit).to_s))
|
1472
|
+
retestDelay = ::DatawireQuarkCore.cast((self)._getField("retestDelay")) { ::Float }
|
1473
|
+
if ((retestDelay) != (nil))
|
1474
|
+
(self)._retestDelay = retestDelay
|
1475
|
+
end
|
1476
|
+
::Quark.quark.Client.logger.info((((self).to_s) + (" retestDelay ")) + (((self)._retestDelay).to_s))
|
1477
|
+
|
1478
|
+
nil
|
1479
|
+
end
|
1480
|
+
|
1481
|
+
|
1482
|
+
|
1483
|
+
|
1484
|
+
def setResolver(resolver)
|
1485
|
+
|
1486
|
+
(self).resolver = resolver
|
1487
|
+
|
1488
|
+
nil
|
1489
|
+
end
|
1490
|
+
|
1491
|
+
def getInstance()
|
1492
|
+
|
1493
|
+
urls = (self).resolver.resolve((self).serviceName)
|
1494
|
+
if (((urls).size) <= (0))
|
1495
|
+
return ::DatawireQuarkCore.cast(nil) { ::Quark.quark.ServiceInstance }
|
1496
|
+
end
|
1497
|
+
(urls).sort!
|
1498
|
+
(self).mutex.acquire()
|
1499
|
+
result = ::DatawireQuarkCore.cast(nil) { ::Quark.quark.ServiceInstance }
|
1500
|
+
next_ = ((self).counter) % ((urls).size)
|
1501
|
+
(self).counter = ((self).counter) + (1)
|
1502
|
+
idx = next_
|
1503
|
+
while (true) do
|
1504
|
+
url = (urls)[idx]
|
1505
|
+
instance = ((self).instanceMap)[url]
|
1506
|
+
if ((instance) == (nil))
|
1507
|
+
instance = ::Quark.quark.ServiceInstance.new((self).serviceName, url, @_failureLimit, @_retestDelay)
|
1508
|
+
((self).instanceMap)[url] = (instance)
|
1509
|
+
end
|
1510
|
+
if (instance.isActive())
|
1511
|
+
::Quark.quark.Client.logger.info(((((("- ") + ((self).serviceName)) + (" using instance ")) + (((idx) + (1)).to_s)) + (": ")) + (url))
|
1512
|
+
result = instance
|
1513
|
+
break
|
1514
|
+
end
|
1515
|
+
idx = ((idx) + (1)) % ((urls).size)
|
1516
|
+
if ((idx) == (next_))
|
1517
|
+
::Quark.quark.Client.logger.info((("- ") + ((self).serviceName)) + (": no live instances! giving up."))
|
1518
|
+
break
|
1519
|
+
end
|
1520
|
+
end
|
1521
|
+
(self).mutex.release()
|
1522
|
+
return result
|
1523
|
+
|
1524
|
+
nil
|
1525
|
+
end
|
1526
|
+
|
1527
|
+
def getName()
|
1528
|
+
|
1529
|
+
return (self).serviceName
|
1530
|
+
|
1531
|
+
nil
|
1532
|
+
end
|
1533
|
+
|
1534
|
+
def getTimeout()
|
1535
|
+
|
1536
|
+
return (self)._timeout
|
1537
|
+
|
1538
|
+
nil
|
1539
|
+
end
|
1540
|
+
|
1541
|
+
def setTimeout(timeout)
|
1542
|
+
|
1543
|
+
(self)._timeout = timeout
|
1544
|
+
|
1545
|
+
nil
|
1546
|
+
end
|
1547
|
+
|
1548
|
+
def _getClass()
|
1549
|
+
|
1550
|
+
return "quark.Client"
|
1551
|
+
|
1552
|
+
nil
|
1553
|
+
end
|
1554
|
+
|
1555
|
+
def _getField(name)
|
1556
|
+
|
1557
|
+
if ((name) == ("logger"))
|
1558
|
+
return ::Quark.quark.Client.logger
|
1559
|
+
end
|
1560
|
+
if ((name) == ("resolver"))
|
1561
|
+
return (self).resolver
|
1562
|
+
end
|
1563
|
+
if ((name) == ("serviceName"))
|
1564
|
+
return (self).serviceName
|
1565
|
+
end
|
1566
|
+
if ((name) == ("_timeout"))
|
1567
|
+
return (self)._timeout
|
1568
|
+
end
|
1569
|
+
if ((name) == ("_failureLimit"))
|
1570
|
+
return (self)._failureLimit
|
1571
|
+
end
|
1572
|
+
if ((name) == ("_retestDelay"))
|
1573
|
+
return (self)._retestDelay
|
1574
|
+
end
|
1575
|
+
if ((name) == ("mutex"))
|
1576
|
+
return (self).mutex
|
1577
|
+
end
|
1578
|
+
if ((name) == ("instanceMap"))
|
1579
|
+
return (self).instanceMap
|
1580
|
+
end
|
1581
|
+
if ((name) == ("counter"))
|
1582
|
+
return (self).counter
|
1583
|
+
end
|
1584
|
+
return nil
|
1585
|
+
|
1586
|
+
nil
|
1587
|
+
end
|
1588
|
+
|
1589
|
+
def _setField(name, value)
|
1590
|
+
|
1591
|
+
if ((name) == ("logger"))
|
1592
|
+
::Quark.quark.Client.logger = value
|
1593
|
+
end
|
1594
|
+
if ((name) == ("resolver"))
|
1595
|
+
(self).resolver = ::DatawireQuarkCore.cast(value) { ::Quark.quark.Resolver }
|
1596
|
+
end
|
1597
|
+
if ((name) == ("serviceName"))
|
1598
|
+
(self).serviceName = ::DatawireQuarkCore.cast(value) { ::String }
|
1599
|
+
end
|
1600
|
+
if ((name) == ("_timeout"))
|
1601
|
+
(self)._timeout = ::DatawireQuarkCore.cast(value) { ::Float }
|
1602
|
+
end
|
1603
|
+
if ((name) == ("_failureLimit"))
|
1604
|
+
(self)._failureLimit = ::DatawireQuarkCore.cast(value) { ::Integer }
|
1605
|
+
end
|
1606
|
+
if ((name) == ("_retestDelay"))
|
1607
|
+
(self)._retestDelay = ::DatawireQuarkCore.cast(value) { ::Float }
|
1608
|
+
end
|
1609
|
+
if ((name) == ("mutex"))
|
1610
|
+
(self).mutex = ::DatawireQuarkCore.cast(value) { ::DatawireQuarkCore::Lock }
|
1611
|
+
end
|
1612
|
+
if ((name) == ("instanceMap"))
|
1613
|
+
(self).instanceMap = ::DatawireQuarkCore.cast(value) { ::Hash }
|
1614
|
+
end
|
1615
|
+
if ((name) == ("counter"))
|
1616
|
+
(self).counter = ::DatawireQuarkCore.cast(value) { ::Integer }
|
1617
|
+
end
|
1618
|
+
|
1619
|
+
nil
|
1620
|
+
end
|
1621
|
+
|
1622
|
+
def __init_fields__()
|
1623
|
+
|
1624
|
+
self.resolver = nil
|
1625
|
+
self.serviceName = nil
|
1626
|
+
self._timeout = nil
|
1627
|
+
self._failureLimit = 3
|
1628
|
+
self._retestDelay = 30.0
|
1629
|
+
self.mutex = nil
|
1630
|
+
self.instanceMap = nil
|
1631
|
+
self.counter = nil
|
1632
|
+
|
1633
|
+
nil
|
1634
|
+
end
|
1635
|
+
|
1636
|
+
|
1637
|
+
end
|
1638
|
+
Client.unlazy_statics
|
1639
|
+
|
1640
|
+
def self.ServerResponder; ServerResponder; end
|
1641
|
+
class ServerResponder < ::DatawireQuarkCore::QuarkObject
|
1642
|
+
attr_accessor :sendCORS, :request, :response
|
1643
|
+
extend ::DatawireQuarkCore::Static
|
1644
|
+
|
1645
|
+
static quark_ServerResponder_ref: -> { nil }
|
1646
|
+
|
1647
|
+
|
1648
|
+
|
1649
|
+
def initialize(sendCORS, request, response)
|
1650
|
+
|
1651
|
+
self.__init_fields__
|
1652
|
+
(self).sendCORS = sendCORS
|
1653
|
+
(self).request = request
|
1654
|
+
(self).response = response
|
1655
|
+
|
1656
|
+
nil
|
1657
|
+
end
|
1658
|
+
|
1659
|
+
|
1660
|
+
|
1661
|
+
|
1662
|
+
def onFuture(result)
|
1663
|
+
|
1664
|
+
error = result.getError()
|
1665
|
+
if ((error) != (nil))
|
1666
|
+
@response.setCode(404)
|
1667
|
+
else
|
1668
|
+
if ((self).sendCORS)
|
1669
|
+
(self).response.setHeader("Access-Control-Allow-Origin", "*")
|
1670
|
+
end
|
1671
|
+
(self).response.setBody(::Quark.quark.toJSON(result, nil).toString())
|
1672
|
+
(self).response.setCode(200)
|
1673
|
+
end
|
1674
|
+
::Quark.quark.concurrent.Context.runtime().respond(@request, @response)
|
1675
|
+
|
1676
|
+
nil
|
1677
|
+
end
|
1678
|
+
|
1679
|
+
def _getClass()
|
1680
|
+
|
1681
|
+
return "quark.ServerResponder"
|
1682
|
+
|
1683
|
+
nil
|
1684
|
+
end
|
1685
|
+
|
1686
|
+
def _getField(name)
|
1687
|
+
|
1688
|
+
if ((name) == ("sendCORS"))
|
1689
|
+
return (self).sendCORS
|
1690
|
+
end
|
1691
|
+
if ((name) == ("request"))
|
1692
|
+
return (self).request
|
1693
|
+
end
|
1694
|
+
if ((name) == ("response"))
|
1695
|
+
return (self).response
|
1696
|
+
end
|
1697
|
+
return nil
|
1698
|
+
|
1699
|
+
nil
|
1700
|
+
end
|
1701
|
+
|
1702
|
+
def _setField(name, value)
|
1703
|
+
|
1704
|
+
if ((name) == ("sendCORS"))
|
1705
|
+
(self).sendCORS = ::DatawireQuarkCore.cast(value) { ::Object }
|
1706
|
+
end
|
1707
|
+
if ((name) == ("request"))
|
1708
|
+
(self).request = ::DatawireQuarkCore.cast(value) { ::Quark.quark.HTTPRequest }
|
1709
|
+
end
|
1710
|
+
if ((name) == ("response"))
|
1711
|
+
(self).response = ::DatawireQuarkCore.cast(value) { ::Quark.quark.HTTPResponse }
|
1712
|
+
end
|
1713
|
+
|
1714
|
+
nil
|
1715
|
+
end
|
1716
|
+
|
1717
|
+
def __init_fields__()
|
1718
|
+
|
1719
|
+
self.sendCORS = nil
|
1720
|
+
self.request = nil
|
1721
|
+
self.response = nil
|
1722
|
+
|
1723
|
+
nil
|
1724
|
+
end
|
1725
|
+
|
1726
|
+
|
1727
|
+
end
|
1728
|
+
ServerResponder.unlazy_statics
|
1729
|
+
|
1730
|
+
def self.Server; Server; end
|
1731
|
+
class Server < ::DatawireQuarkCore::QuarkObject
|
1732
|
+
attr_accessor :impl, :_sendCORS
|
1733
|
+
extend ::DatawireQuarkCore::Static
|
1734
|
+
|
1735
|
+
static quark_Server_quark_Object__ref: -> { nil }
|
1736
|
+
|
1737
|
+
|
1738
|
+
|
1739
|
+
def initialize(impl)
|
1740
|
+
|
1741
|
+
self.__init_fields__
|
1742
|
+
(self).impl = impl
|
1743
|
+
(self)._sendCORS = false
|
1744
|
+
|
1745
|
+
nil
|
1746
|
+
end
|
1747
|
+
|
1748
|
+
|
1749
|
+
|
1750
|
+
|
1751
|
+
def sendCORS(send)
|
1752
|
+
|
1753
|
+
(self)._sendCORS = send
|
1754
|
+
|
1755
|
+
nil
|
1756
|
+
end
|
1757
|
+
|
1758
|
+
def onHTTPRequest(request, response)
|
1759
|
+
|
1760
|
+
body = request.getBody()
|
1761
|
+
envelope = ::DatawireQuarkCore::JSONObject.parse(body)
|
1762
|
+
if ((((envelope).getObjectItem("$method")) == (envelope.undefined())) || (((envelope).getObjectItem("rpc")) == (envelope.undefined())))
|
1763
|
+
response.setBody((("Failed to understand request.\n\n") + (body)) + ("\n"))
|
1764
|
+
response.setCode(400)
|
1765
|
+
::Quark.quark.concurrent.Context.runtime().respond(request, response)
|
1766
|
+
else
|
1767
|
+
methodName = (envelope).getObjectItem("$method").getString()
|
1768
|
+
json = (envelope).getObjectItem("rpc")
|
1769
|
+
method = ::Quark.quark.reflect.QuarkClass.get(::DatawireQuarkCore._getClass(self)).getField("impl").getType().getMethod(methodName)
|
1770
|
+
params = method.getParameters()
|
1771
|
+
args = ::DatawireQuarkCore::List.new([])
|
1772
|
+
idx = 0
|
1773
|
+
while ((idx) < ((params).size)) do
|
1774
|
+
(args) << (::Quark.quark.fromJSON((params)[idx], nil, json.getListItem(idx)))
|
1775
|
+
idx = (idx) + (1)
|
1776
|
+
end
|
1777
|
+
result = ::DatawireQuarkCore.cast(method.invoke(@impl, args)) { ::Quark.quark.concurrent.Future }
|
1778
|
+
result.onFinished(::Quark.quark.ServerResponder.new((self)._sendCORS, request, response))
|
1779
|
+
end
|
1780
|
+
|
1781
|
+
nil
|
1782
|
+
end
|
1783
|
+
|
1784
|
+
def onServletError(url, error)
|
1785
|
+
|
1786
|
+
::Quark.quark.concurrent.Context.runtime().fail(((("RPC Server failed to register ") + (url)) + (" due to: ")) + (error.getMessage()))
|
1787
|
+
|
1788
|
+
nil
|
1789
|
+
end
|
1790
|
+
|
1791
|
+
def _getClass()
|
1792
|
+
|
1793
|
+
return "quark.Server<quark.Object>"
|
1794
|
+
|
1795
|
+
nil
|
1796
|
+
end
|
1797
|
+
|
1798
|
+
def _getField(name)
|
1799
|
+
|
1800
|
+
if ((name) == ("impl"))
|
1801
|
+
return (self).impl
|
1802
|
+
end
|
1803
|
+
if ((name) == ("_sendCORS"))
|
1804
|
+
return (self)._sendCORS
|
1805
|
+
end
|
1806
|
+
return nil
|
1807
|
+
|
1808
|
+
nil
|
1809
|
+
end
|
1810
|
+
|
1811
|
+
def _setField(name, value)
|
1812
|
+
|
1813
|
+
if ((name) == ("impl"))
|
1814
|
+
(self).impl = ::DatawireQuarkCore.cast(value) { ::Quark.T }
|
1815
|
+
end
|
1816
|
+
if ((name) == ("_sendCORS"))
|
1817
|
+
(self)._sendCORS = ::DatawireQuarkCore.cast(value) { ::Object }
|
1818
|
+
end
|
1819
|
+
|
1820
|
+
nil
|
1821
|
+
end
|
1822
|
+
|
1823
|
+
def serveHTTP(url)
|
1824
|
+
|
1825
|
+
::Quark.quark.concurrent.Context.runtime().serveHTTP(url, self)
|
1826
|
+
|
1827
|
+
nil
|
1828
|
+
end
|
1829
|
+
|
1830
|
+
##
|
1831
|
+
# called after the servlet is successfully installed. The url will be the actual url used, important especially if ephemeral port was requested
|
1832
|
+
|
1833
|
+
def onServletInit(url, runtime)
|
1834
|
+
|
1835
|
+
nil
|
1836
|
+
|
1837
|
+
nil
|
1838
|
+
end
|
1839
|
+
|
1840
|
+
##
|
1841
|
+
# called when the servlet is removed
|
1842
|
+
|
1843
|
+
def onServletEnd(url)
|
1844
|
+
|
1845
|
+
nil
|
1846
|
+
|
1847
|
+
nil
|
1848
|
+
end
|
1849
|
+
|
1850
|
+
def __init_fields__()
|
1851
|
+
|
1852
|
+
self.impl = nil
|
1853
|
+
self._sendCORS = nil
|
1854
|
+
|
1855
|
+
nil
|
1856
|
+
end
|
1857
|
+
|
1858
|
+
|
1859
|
+
end
|
1860
|
+
Server.unlazy_statics
|
1861
|
+
|
1862
|
+
|
1863
|
+
|
1864
|
+
def self.HTTPError; HTTPError; end
|
1865
|
+
class HTTPError < ::Quark.quark.error.Error
|
1866
|
+
extend ::DatawireQuarkCore::Static
|
1867
|
+
|
1868
|
+
static quark_HTTPError_ref: -> { nil }
|
1869
|
+
|
1870
|
+
|
1871
|
+
|
1872
|
+
def initialize(message)
|
1873
|
+
|
1874
|
+
super(message)
|
1875
|
+
|
1876
|
+
nil
|
1877
|
+
end
|
1878
|
+
|
1879
|
+
|
1880
|
+
|
1881
|
+
|
1882
|
+
def _getClass()
|
1883
|
+
|
1884
|
+
return "quark.HTTPError"
|
1885
|
+
|
1886
|
+
nil
|
1887
|
+
end
|
1888
|
+
|
1889
|
+
def _getField(name)
|
1890
|
+
|
1891
|
+
if ((name) == ("message"))
|
1892
|
+
return (self).message
|
1893
|
+
end
|
1894
|
+
return nil
|
1895
|
+
|
1896
|
+
nil
|
1897
|
+
end
|
1898
|
+
|
1899
|
+
def _setField(name, value)
|
1900
|
+
|
1901
|
+
if ((name) == ("message"))
|
1902
|
+
(self).message = ::DatawireQuarkCore.cast(value) { ::String }
|
1903
|
+
end
|
1904
|
+
|
1905
|
+
nil
|
1906
|
+
end
|
1907
|
+
|
1908
|
+
def __init_fields__()
|
1909
|
+
|
1910
|
+
super
|
1911
|
+
|
1912
|
+
nil
|
1913
|
+
end
|
1914
|
+
|
1915
|
+
|
1916
|
+
end
|
1917
|
+
HTTPError.unlazy_statics
|
1918
|
+
|
1919
|
+
def self.HTTPHandler; HTTPHandler; end
|
1920
|
+
class HTTPHandler < ::DatawireQuarkCore::QuarkObject
|
1921
|
+
extend ::DatawireQuarkCore::Static
|
1922
|
+
|
1923
|
+
static quark_HTTPHandler_ref: -> { nil }
|
1924
|
+
|
1925
|
+
|
1926
|
+
|
1927
|
+
def initialize()
|
1928
|
+
self.__init_fields__
|
1929
|
+
|
1930
|
+
nil
|
1931
|
+
end
|
1932
|
+
|
1933
|
+
|
1934
|
+
|
1935
|
+
|
1936
|
+
def onHTTPInit(request)
|
1937
|
+
|
1938
|
+
nil
|
1939
|
+
|
1940
|
+
nil
|
1941
|
+
end
|
1942
|
+
|
1943
|
+
def onHTTPResponse(request, response)
|
1944
|
+
|
1945
|
+
nil
|
1946
|
+
|
1947
|
+
nil
|
1948
|
+
end
|
1949
|
+
|
1950
|
+
def onHTTPError(request, message)
|
1951
|
+
|
1952
|
+
nil
|
1953
|
+
|
1954
|
+
nil
|
1955
|
+
end
|
1956
|
+
|
1957
|
+
def onHTTPFinal(request)
|
1958
|
+
|
1959
|
+
nil
|
1960
|
+
|
1961
|
+
nil
|
1962
|
+
end
|
1963
|
+
|
1964
|
+
def __init_fields__()
|
1965
|
+
|
1966
|
+
|
1967
|
+
nil
|
1968
|
+
end
|
1969
|
+
|
1970
|
+
|
1971
|
+
end
|
1972
|
+
HTTPHandler.unlazy_statics
|
1973
|
+
|
1974
|
+
def self.HTTPRequest; HTTPRequest; end
|
1975
|
+
class HTTPRequest < ::DatawireQuarkCore::QuarkObject
|
1976
|
+
extend ::DatawireQuarkCore::Static
|
1977
|
+
|
1978
|
+
static quark_HTTPRequest_ref: -> { nil }
|
1979
|
+
|
1980
|
+
|
1981
|
+
|
1982
|
+
def initialize()
|
1983
|
+
self.__init_fields__
|
1984
|
+
|
1985
|
+
nil
|
1986
|
+
end
|
1987
|
+
|
1988
|
+
|
1989
|
+
|
1990
|
+
|
1991
|
+
def getUrl()
|
1992
|
+
raise NotImplementedError, '`HTTPRequest.getUrl` is an abstract method'
|
1993
|
+
|
1994
|
+
nil
|
1995
|
+
end
|
1996
|
+
|
1997
|
+
def setMethod(method)
|
1998
|
+
raise NotImplementedError, '`HTTPRequest.setMethod` is an abstract method'
|
1999
|
+
|
2000
|
+
nil
|
2001
|
+
end
|
2002
|
+
|
2003
|
+
def getMethod()
|
2004
|
+
raise NotImplementedError, '`HTTPRequest.getMethod` is an abstract method'
|
2005
|
+
|
2006
|
+
nil
|
2007
|
+
end
|
2008
|
+
|
2009
|
+
def setBody(data)
|
2010
|
+
raise NotImplementedError, '`HTTPRequest.setBody` is an abstract method'
|
2011
|
+
|
2012
|
+
nil
|
2013
|
+
end
|
2014
|
+
|
2015
|
+
def getBody()
|
2016
|
+
raise NotImplementedError, '`HTTPRequest.getBody` is an abstract method'
|
2017
|
+
|
2018
|
+
nil
|
2019
|
+
end
|
2020
|
+
|
2021
|
+
def setHeader(key, value)
|
2022
|
+
raise NotImplementedError, '`HTTPRequest.setHeader` is an abstract method'
|
2023
|
+
|
2024
|
+
nil
|
2025
|
+
end
|
2026
|
+
|
2027
|
+
def getHeader(key)
|
2028
|
+
raise NotImplementedError, '`HTTPRequest.getHeader` is an abstract method'
|
2029
|
+
|
2030
|
+
nil
|
2031
|
+
end
|
2032
|
+
|
2033
|
+
def getHeaders()
|
2034
|
+
raise NotImplementedError, '`HTTPRequest.getHeaders` is an abstract method'
|
2035
|
+
|
2036
|
+
nil
|
2037
|
+
end
|
2038
|
+
|
2039
|
+
def __init_fields__()
|
2040
|
+
|
2041
|
+
|
2042
|
+
nil
|
2043
|
+
end
|
2044
|
+
|
2045
|
+
|
2046
|
+
end
|
2047
|
+
HTTPRequest.unlazy_statics
|
2048
|
+
|
2049
|
+
def self.HTTPResponse; HTTPResponse; end
|
2050
|
+
class HTTPResponse < ::DatawireQuarkCore::QuarkObject
|
2051
|
+
extend ::DatawireQuarkCore::Static
|
2052
|
+
|
2053
|
+
static quark_HTTPResponse_ref: -> { nil }
|
2054
|
+
|
2055
|
+
|
2056
|
+
|
2057
|
+
def initialize()
|
2058
|
+
self.__init_fields__
|
2059
|
+
|
2060
|
+
nil
|
2061
|
+
end
|
2062
|
+
|
2063
|
+
|
2064
|
+
|
2065
|
+
|
2066
|
+
def getCode()
|
2067
|
+
raise NotImplementedError, '`HTTPResponse.getCode` is an abstract method'
|
2068
|
+
|
2069
|
+
nil
|
2070
|
+
end
|
2071
|
+
|
2072
|
+
def setCode(code)
|
2073
|
+
raise NotImplementedError, '`HTTPResponse.setCode` is an abstract method'
|
2074
|
+
|
2075
|
+
nil
|
2076
|
+
end
|
2077
|
+
|
2078
|
+
def getBody()
|
2079
|
+
raise NotImplementedError, '`HTTPResponse.getBody` is an abstract method'
|
2080
|
+
|
2081
|
+
nil
|
2082
|
+
end
|
2083
|
+
|
2084
|
+
def setBody(body)
|
2085
|
+
raise NotImplementedError, '`HTTPResponse.setBody` is an abstract method'
|
2086
|
+
|
2087
|
+
nil
|
2088
|
+
end
|
2089
|
+
|
2090
|
+
def setHeader(key, value)
|
2091
|
+
raise NotImplementedError, '`HTTPResponse.setHeader` is an abstract method'
|
2092
|
+
|
2093
|
+
nil
|
2094
|
+
end
|
2095
|
+
|
2096
|
+
def getHeader(key)
|
2097
|
+
raise NotImplementedError, '`HTTPResponse.getHeader` is an abstract method'
|
2098
|
+
|
2099
|
+
nil
|
2100
|
+
end
|
2101
|
+
|
2102
|
+
def getHeaders()
|
2103
|
+
raise NotImplementedError, '`HTTPResponse.getHeaders` is an abstract method'
|
2104
|
+
|
2105
|
+
nil
|
2106
|
+
end
|
2107
|
+
|
2108
|
+
def __init_fields__()
|
2109
|
+
|
2110
|
+
|
2111
|
+
nil
|
2112
|
+
end
|
2113
|
+
|
2114
|
+
|
2115
|
+
end
|
2116
|
+
HTTPResponse.unlazy_statics
|
2117
|
+
|
2118
|
+
def self.HTTPServlet; HTTPServlet; end
|
2119
|
+
##
|
2120
|
+
# Http servlet
|
2121
|
+
|
2122
|
+
class HTTPServlet < ::DatawireQuarkCore::QuarkObject
|
2123
|
+
extend ::DatawireQuarkCore::Static
|
2124
|
+
|
2125
|
+
static quark_HTTPServlet_ref: -> { nil }
|
2126
|
+
|
2127
|
+
|
2128
|
+
|
2129
|
+
def initialize()
|
2130
|
+
self.__init_fields__
|
2131
|
+
|
2132
|
+
nil
|
2133
|
+
end
|
2134
|
+
|
2135
|
+
|
2136
|
+
|
2137
|
+
|
2138
|
+
##
|
2139
|
+
# incoming request. respond with Runtime.respond(). After responding the objects may get recycled by the runtime
|
2140
|
+
|
2141
|
+
def onHTTPRequest(request, response)
|
2142
|
+
|
2143
|
+
nil
|
2144
|
+
|
2145
|
+
nil
|
2146
|
+
end
|
2147
|
+
|
2148
|
+
def serveHTTP(url)
|
2149
|
+
|
2150
|
+
::Quark.quark.concurrent.Context.runtime().serveHTTP(url, self)
|
2151
|
+
|
2152
|
+
nil
|
2153
|
+
end
|
2154
|
+
|
2155
|
+
def __init_fields__()
|
2156
|
+
|
2157
|
+
|
2158
|
+
nil
|
2159
|
+
end
|
2160
|
+
|
2161
|
+
|
2162
|
+
end
|
2163
|
+
HTTPServlet.unlazy_statics
|
2164
|
+
|
2165
|
+
|
2166
|
+
def self.WSError; WSError; end
|
2167
|
+
class WSError < ::Quark.quark.error.Error
|
2168
|
+
extend ::DatawireQuarkCore::Static
|
2169
|
+
|
2170
|
+
static quark_WSError_ref: -> { nil }
|
2171
|
+
|
2172
|
+
|
2173
|
+
|
2174
|
+
def initialize(message)
|
2175
|
+
|
2176
|
+
super(message)
|
2177
|
+
|
2178
|
+
nil
|
2179
|
+
end
|
2180
|
+
|
2181
|
+
|
2182
|
+
|
2183
|
+
|
2184
|
+
def _getClass()
|
2185
|
+
|
2186
|
+
return "quark.WSError"
|
2187
|
+
|
2188
|
+
nil
|
2189
|
+
end
|
2190
|
+
|
2191
|
+
def _getField(name)
|
2192
|
+
|
2193
|
+
if ((name) == ("message"))
|
2194
|
+
return (self).message
|
2195
|
+
end
|
2196
|
+
return nil
|
2197
|
+
|
2198
|
+
nil
|
2199
|
+
end
|
2200
|
+
|
2201
|
+
def _setField(name, value)
|
2202
|
+
|
2203
|
+
if ((name) == ("message"))
|
2204
|
+
(self).message = ::DatawireQuarkCore.cast(value) { ::String }
|
2205
|
+
end
|
2206
|
+
|
2207
|
+
nil
|
2208
|
+
end
|
2209
|
+
|
2210
|
+
def __init_fields__()
|
2211
|
+
|
2212
|
+
super
|
2213
|
+
|
2214
|
+
nil
|
2215
|
+
end
|
2216
|
+
|
2217
|
+
|
2218
|
+
end
|
2219
|
+
WSError.unlazy_statics
|
2220
|
+
|
2221
|
+
def self.WSHandler; WSHandler; end
|
2222
|
+
class WSHandler < ::DatawireQuarkCore::QuarkObject
|
2223
|
+
extend ::DatawireQuarkCore::Static
|
2224
|
+
|
2225
|
+
static quark_WSHandler_ref: -> { nil }
|
2226
|
+
|
2227
|
+
|
2228
|
+
|
2229
|
+
def initialize()
|
2230
|
+
self.__init_fields__
|
2231
|
+
|
2232
|
+
nil
|
2233
|
+
end
|
2234
|
+
|
2235
|
+
|
2236
|
+
|
2237
|
+
|
2238
|
+
##
|
2239
|
+
# Called when the WebSocket is first created.
|
2240
|
+
|
2241
|
+
def onWSInit(socket)
|
2242
|
+
|
2243
|
+
nil
|
2244
|
+
|
2245
|
+
nil
|
2246
|
+
end
|
2247
|
+
|
2248
|
+
##
|
2249
|
+
# Called when the WebSocket connects successfully.
|
2250
|
+
|
2251
|
+
def onWSConnected(socket)
|
2252
|
+
|
2253
|
+
nil
|
2254
|
+
|
2255
|
+
nil
|
2256
|
+
end
|
2257
|
+
|
2258
|
+
##
|
2259
|
+
# Called when the WebSocket receives a message.
|
2260
|
+
|
2261
|
+
def onWSMessage(socket, message)
|
2262
|
+
|
2263
|
+
nil
|
2264
|
+
|
2265
|
+
nil
|
2266
|
+
end
|
2267
|
+
|
2268
|
+
##
|
2269
|
+
# Called when the WebSocket receives a binary message.
|
2270
|
+
|
2271
|
+
def onWSBinary(socket, message)
|
2272
|
+
|
2273
|
+
nil
|
2274
|
+
|
2275
|
+
nil
|
2276
|
+
end
|
2277
|
+
|
2278
|
+
##
|
2279
|
+
# Called when the WebSocket disconnects cleanly.
|
2280
|
+
|
2281
|
+
def onWSClosed(socket)
|
2282
|
+
|
2283
|
+
nil
|
2284
|
+
|
2285
|
+
nil
|
2286
|
+
end
|
2287
|
+
|
2288
|
+
##
|
2289
|
+
# Called when the WebSocket disconnects with an error, or fails to connect.
|
2290
|
+
|
2291
|
+
def onWSError(socket, error)
|
2292
|
+
|
2293
|
+
nil
|
2294
|
+
|
2295
|
+
nil
|
2296
|
+
end
|
2297
|
+
|
2298
|
+
##
|
2299
|
+
# Called when the WebSocket is done with life, one way or another.
|
2300
|
+
|
2301
|
+
def onWSFinal(socket)
|
2302
|
+
|
2303
|
+
nil
|
2304
|
+
|
2305
|
+
nil
|
2306
|
+
end
|
2307
|
+
|
2308
|
+
def __init_fields__()
|
2309
|
+
|
2310
|
+
|
2311
|
+
nil
|
2312
|
+
end
|
2313
|
+
|
2314
|
+
|
2315
|
+
end
|
2316
|
+
WSHandler.unlazy_statics
|
2317
|
+
|
2318
|
+
def self.WebSocket; WebSocket; end
|
2319
|
+
class WebSocket < ::DatawireQuarkCore::QuarkObject
|
2320
|
+
extend ::DatawireQuarkCore::Static
|
2321
|
+
|
2322
|
+
static quark_WebSocket_ref: -> { nil }
|
2323
|
+
|
2324
|
+
|
2325
|
+
|
2326
|
+
def initialize()
|
2327
|
+
self.__init_fields__
|
2328
|
+
|
2329
|
+
nil
|
2330
|
+
end
|
2331
|
+
|
2332
|
+
|
2333
|
+
|
2334
|
+
|
2335
|
+
def send(message)
|
2336
|
+
raise NotImplementedError, '`WebSocket.send` is an abstract method'
|
2337
|
+
|
2338
|
+
nil
|
2339
|
+
end
|
2340
|
+
|
2341
|
+
def sendBinary(bytes)
|
2342
|
+
raise NotImplementedError, '`WebSocket.sendBinary` is an abstract method'
|
2343
|
+
|
2344
|
+
nil
|
2345
|
+
end
|
2346
|
+
|
2347
|
+
def close()
|
2348
|
+
raise NotImplementedError, '`WebSocket.close` is an abstract method'
|
2349
|
+
|
2350
|
+
nil
|
2351
|
+
end
|
2352
|
+
|
2353
|
+
def __init_fields__()
|
2354
|
+
|
2355
|
+
|
2356
|
+
nil
|
2357
|
+
end
|
2358
|
+
|
2359
|
+
|
2360
|
+
end
|
2361
|
+
WebSocket.unlazy_statics
|
2362
|
+
|
2363
|
+
def self.WSServlet; WSServlet; end
|
2364
|
+
##
|
2365
|
+
# Websocket servlet
|
2366
|
+
|
2367
|
+
class WSServlet < ::DatawireQuarkCore::QuarkObject
|
2368
|
+
extend ::DatawireQuarkCore::Static
|
2369
|
+
|
2370
|
+
static quark_WSServlet_ref: -> { nil }
|
2371
|
+
|
2372
|
+
|
2373
|
+
|
2374
|
+
def initialize()
|
2375
|
+
self.__init_fields__
|
2376
|
+
|
2377
|
+
nil
|
2378
|
+
end
|
2379
|
+
|
2380
|
+
|
2381
|
+
|
2382
|
+
|
2383
|
+
##
|
2384
|
+
# called for each new incoming WebSocket connection
|
2385
|
+
|
2386
|
+
def onWSConnect(upgrade_request)
|
2387
|
+
|
2388
|
+
return ::DatawireQuarkCore.cast(nil) { ::Quark.quark.WSHandler }
|
2389
|
+
|
2390
|
+
nil
|
2391
|
+
end
|
2392
|
+
|
2393
|
+
def serveWS(url)
|
2394
|
+
|
2395
|
+
::Quark.quark.concurrent.Context.runtime().serveWS(url, self)
|
2396
|
+
|
2397
|
+
nil
|
2398
|
+
end
|
2399
|
+
|
2400
|
+
def __init_fields__()
|
2401
|
+
|
2402
|
+
|
2403
|
+
nil
|
2404
|
+
end
|
2405
|
+
|
2406
|
+
|
2407
|
+
end
|
2408
|
+
WSServlet.unlazy_statics
|
2409
|
+
|
2410
|
+
|
2411
|
+
|
2412
|
+
def self.URL; URL; end
|
2413
|
+
##
|
2414
|
+
# A URL class.
|
2415
|
+
|
2416
|
+
class URL < ::DatawireQuarkCore::QuarkObject
|
2417
|
+
attr_accessor :scheme, :host, :port, :path
|
2418
|
+
extend ::DatawireQuarkCore::Static
|
2419
|
+
|
2420
|
+
static quark_URL_ref: -> { nil }
|
2421
|
+
|
2422
|
+
|
2423
|
+
|
2424
|
+
def initialize()
|
2425
|
+
self.__init_fields__
|
2426
|
+
|
2427
|
+
nil
|
2428
|
+
end
|
2429
|
+
|
2430
|
+
|
2431
|
+
|
2432
|
+
|
2433
|
+
def self.parse(url)
|
2434
|
+
|
2435
|
+
result = ::Quark.quark.URL.new()
|
2436
|
+
if ((url) == (nil))
|
2437
|
+
return ::DatawireQuarkCore.cast(nil) { ::Quark.quark.URL }
|
2438
|
+
end
|
2439
|
+
parts = nil
|
2440
|
+
remaining = nil
|
2441
|
+
idx = ((url).index("://") or -1)
|
2442
|
+
if ((idx) >= (0))
|
2443
|
+
(result).scheme = (url)[(0)...(idx)]
|
2444
|
+
remaining = (url)[((idx) + (3))...((url).size)]
|
2445
|
+
else
|
2446
|
+
remaining = url
|
2447
|
+
end
|
2448
|
+
firstSlash = ((remaining).index("/") or -1)
|
2449
|
+
if ((firstSlash) == (0))
|
2450
|
+
(result).path = remaining
|
2451
|
+
return result
|
2452
|
+
end
|
2453
|
+
if ((firstSlash) < (0))
|
2454
|
+
firstSlash = (remaining).size
|
2455
|
+
else
|
2456
|
+
(result).path = (remaining)[(firstSlash)...((remaining).size)]
|
2457
|
+
end
|
2458
|
+
idx = ((remaining).index(":") or -1)
|
2459
|
+
if ((idx) > (firstSlash))
|
2460
|
+
(result).host = (remaining)[(0)...(firstSlash)]
|
2461
|
+
else
|
2462
|
+
if ((idx) >= (0))
|
2463
|
+
(result).host = (remaining)[(0)...(idx)]
|
2464
|
+
(result).port = (remaining)[((idx) + (1))...(firstSlash)]
|
2465
|
+
else
|
2466
|
+
(result).host = (remaining)[(0)...(firstSlash)]
|
2467
|
+
end
|
2468
|
+
end
|
2469
|
+
return result
|
2470
|
+
|
2471
|
+
nil
|
2472
|
+
end
|
2473
|
+
|
2474
|
+
def toString()
|
2475
|
+
|
2476
|
+
result = ""
|
2477
|
+
if ((@scheme) != (nil))
|
2478
|
+
result = (@scheme) + ("://")
|
2479
|
+
end
|
2480
|
+
if ((@host) != (nil))
|
2481
|
+
result = (result) + (@host)
|
2482
|
+
end
|
2483
|
+
if ((@port) != (nil))
|
2484
|
+
result = ((result) + (":")) + (@port)
|
2485
|
+
end
|
2486
|
+
if ((@path) != (nil))
|
2487
|
+
result = (result) + (@path)
|
2488
|
+
end
|
2489
|
+
return result
|
2490
|
+
|
2491
|
+
nil
|
2492
|
+
end
|
2493
|
+
|
2494
|
+
def _getClass()
|
2495
|
+
|
2496
|
+
return "quark.URL"
|
2497
|
+
|
2498
|
+
nil
|
2499
|
+
end
|
2500
|
+
|
2501
|
+
def _getField(name)
|
2502
|
+
|
2503
|
+
if ((name) == ("scheme"))
|
2504
|
+
return (self).scheme
|
2505
|
+
end
|
2506
|
+
if ((name) == ("host"))
|
2507
|
+
return (self).host
|
2508
|
+
end
|
2509
|
+
if ((name) == ("port"))
|
2510
|
+
return (self).port
|
2511
|
+
end
|
2512
|
+
if ((name) == ("path"))
|
2513
|
+
return (self).path
|
2514
|
+
end
|
2515
|
+
return nil
|
2516
|
+
|
2517
|
+
nil
|
2518
|
+
end
|
2519
|
+
|
2520
|
+
def _setField(name, value)
|
2521
|
+
|
2522
|
+
if ((name) == ("scheme"))
|
2523
|
+
(self).scheme = ::DatawireQuarkCore.cast(value) { ::String }
|
2524
|
+
end
|
2525
|
+
if ((name) == ("host"))
|
2526
|
+
(self).host = ::DatawireQuarkCore.cast(value) { ::String }
|
2527
|
+
end
|
2528
|
+
if ((name) == ("port"))
|
2529
|
+
(self).port = ::DatawireQuarkCore.cast(value) { ::String }
|
2530
|
+
end
|
2531
|
+
if ((name) == ("path"))
|
2532
|
+
(self).path = ::DatawireQuarkCore.cast(value) { ::String }
|
2533
|
+
end
|
2534
|
+
|
2535
|
+
nil
|
2536
|
+
end
|
2537
|
+
|
2538
|
+
def __init_fields__()
|
2539
|
+
|
2540
|
+
self.scheme = nil
|
2541
|
+
self.host = nil
|
2542
|
+
self.port = nil
|
2543
|
+
self.path = nil
|
2544
|
+
|
2545
|
+
nil
|
2546
|
+
end
|
2547
|
+
|
2548
|
+
|
2549
|
+
end
|
2550
|
+
URL.unlazy_statics
|
2551
|
+
|
2552
|
+
|
2553
|
+
|
2554
|
+
|
2555
|
+
|
2556
|
+
|
2557
|
+
|
2558
|
+
def self._ChainPromise; ChainPromise; end
|
2559
|
+
class ChainPromise < ::DatawireQuarkCore::QuarkObject
|
2560
|
+
attr_accessor :_next
|
2561
|
+
extend ::DatawireQuarkCore::Static
|
2562
|
+
|
2563
|
+
static quark__ChainPromise_ref: -> { nil }
|
2564
|
+
|
2565
|
+
|
2566
|
+
|
2567
|
+
def initialize(next_)
|
2568
|
+
|
2569
|
+
self.__init_fields__
|
2570
|
+
(self)._next = next_
|
2571
|
+
|
2572
|
+
nil
|
2573
|
+
end
|
2574
|
+
|
2575
|
+
|
2576
|
+
|
2577
|
+
|
2578
|
+
def call(arg)
|
2579
|
+
|
2580
|
+
::Quark.quark._CallbackEvent.fullfilPromise((self)._next, arg)
|
2581
|
+
return nil
|
2582
|
+
|
2583
|
+
nil
|
2584
|
+
end
|
2585
|
+
|
2586
|
+
def _getClass()
|
2587
|
+
|
2588
|
+
return "quark._ChainPromise"
|
2589
|
+
|
2590
|
+
nil
|
2591
|
+
end
|
2592
|
+
|
2593
|
+
def _getField(name)
|
2594
|
+
|
2595
|
+
if ((name) == ("_next"))
|
2596
|
+
return (self)._next
|
2597
|
+
end
|
2598
|
+
return nil
|
2599
|
+
|
2600
|
+
nil
|
2601
|
+
end
|
2602
|
+
|
2603
|
+
def _setField(name, value)
|
2604
|
+
|
2605
|
+
if ((name) == ("_next"))
|
2606
|
+
(self)._next = ::DatawireQuarkCore.cast(value) { ::Quark.quark.Promise }
|
2607
|
+
end
|
2608
|
+
|
2609
|
+
nil
|
2610
|
+
end
|
2611
|
+
|
2612
|
+
def __init_fields__()
|
2613
|
+
|
2614
|
+
self._next = nil
|
2615
|
+
|
2616
|
+
nil
|
2617
|
+
end
|
2618
|
+
|
2619
|
+
|
2620
|
+
end
|
2621
|
+
ChainPromise.unlazy_statics
|
2622
|
+
|
2623
|
+
def self._CallbackEvent; CallbackEvent; end
|
2624
|
+
class CallbackEvent < ::DatawireQuarkCore::QuarkObject
|
2625
|
+
attr_accessor :_callable, :_next, :_value, :_callback
|
2626
|
+
extend ::DatawireQuarkCore::Static
|
2627
|
+
|
2628
|
+
static quark__CallbackEvent_ref: -> { nil }
|
2629
|
+
|
2630
|
+
|
2631
|
+
|
2632
|
+
def initialize(callable, next_, value, callback)
|
2633
|
+
|
2634
|
+
self.__init_fields__
|
2635
|
+
(self)._callable = callable
|
2636
|
+
(self)._next = next_
|
2637
|
+
(self)._value = value
|
2638
|
+
(self)._callback = callback
|
2639
|
+
|
2640
|
+
nil
|
2641
|
+
end
|
2642
|
+
|
2643
|
+
|
2644
|
+
|
2645
|
+
|
2646
|
+
def getContext()
|
2647
|
+
|
2648
|
+
return (self)._callback
|
2649
|
+
|
2650
|
+
nil
|
2651
|
+
end
|
2652
|
+
|
2653
|
+
def self.fullfilPromise(promise, value)
|
2654
|
+
|
2655
|
+
if (::Quark.quark.reflect.QuarkClass.ERROR.hasInstance(value))
|
2656
|
+
promise._reject(::DatawireQuarkCore.cast(value) { ::Quark.quark.error.Error })
|
2657
|
+
else
|
2658
|
+
promise._resolve(value)
|
2659
|
+
end
|
2660
|
+
|
2661
|
+
nil
|
2662
|
+
end
|
2663
|
+
|
2664
|
+
def fireEvent()
|
2665
|
+
|
2666
|
+
result = ((self)._callable).call((self)._value)
|
2667
|
+
if (::Quark.quark.reflect.QuarkClass.get("quark.Promise").hasInstance(result))
|
2668
|
+
toChain = ::DatawireQuarkCore.cast(result) { ::Quark.quark.Promise }
|
2669
|
+
toChain.andFinally(::Quark.quark._ChainPromise.new((self)._next))
|
2670
|
+
else
|
2671
|
+
::Quark.quark._CallbackEvent.fullfilPromise((self)._next, result)
|
2672
|
+
end
|
2673
|
+
|
2674
|
+
nil
|
2675
|
+
end
|
2676
|
+
|
2677
|
+
def _getClass()
|
2678
|
+
|
2679
|
+
return "quark._CallbackEvent"
|
2680
|
+
|
2681
|
+
nil
|
2682
|
+
end
|
2683
|
+
|
2684
|
+
def _getField(name)
|
2685
|
+
|
2686
|
+
if ((name) == ("_callable"))
|
2687
|
+
return (self)._callable
|
2688
|
+
end
|
2689
|
+
if ((name) == ("_next"))
|
2690
|
+
return (self)._next
|
2691
|
+
end
|
2692
|
+
if ((name) == ("_value"))
|
2693
|
+
return (self)._value
|
2694
|
+
end
|
2695
|
+
if ((name) == ("_callback"))
|
2696
|
+
return (self)._callback
|
2697
|
+
end
|
2698
|
+
return nil
|
2699
|
+
|
2700
|
+
nil
|
2701
|
+
end
|
2702
|
+
|
2703
|
+
def _setField(name, value)
|
2704
|
+
|
2705
|
+
if ((name) == ("_callable"))
|
2706
|
+
(self)._callable = ::DatawireQuarkCore.cast(value) { ::Quark.quark.UnaryCallable }
|
2707
|
+
end
|
2708
|
+
if ((name) == ("_next"))
|
2709
|
+
(self)._next = ::DatawireQuarkCore.cast(value) { ::Quark.quark.Promise }
|
2710
|
+
end
|
2711
|
+
if ((name) == ("_value"))
|
2712
|
+
(self)._value = value
|
2713
|
+
end
|
2714
|
+
if ((name) == ("_callback"))
|
2715
|
+
(self)._callback = ::DatawireQuarkCore.cast(value) { ::Quark.quark._Callback }
|
2716
|
+
end
|
2717
|
+
|
2718
|
+
nil
|
2719
|
+
end
|
2720
|
+
|
2721
|
+
def __init_fields__()
|
2722
|
+
|
2723
|
+
self._callable = nil
|
2724
|
+
self._next = nil
|
2725
|
+
self._value = nil
|
2726
|
+
self._callback = nil
|
2727
|
+
|
2728
|
+
nil
|
2729
|
+
end
|
2730
|
+
|
2731
|
+
|
2732
|
+
end
|
2733
|
+
CallbackEvent.unlazy_statics
|
2734
|
+
|
2735
|
+
def self._Callback; Callback; end
|
2736
|
+
class Callback < ::Quark.quark.concurrent.EventContext
|
2737
|
+
attr_accessor :_callable, :_next
|
2738
|
+
extend ::DatawireQuarkCore::Static
|
2739
|
+
|
2740
|
+
static quark__Callback_ref: -> { nil }
|
2741
|
+
|
2742
|
+
|
2743
|
+
|
2744
|
+
def initialize(callable, next_)
|
2745
|
+
|
2746
|
+
super()
|
2747
|
+
(self)._callable = callable
|
2748
|
+
(self)._next = next_
|
2749
|
+
|
2750
|
+
nil
|
2751
|
+
end
|
2752
|
+
|
2753
|
+
|
2754
|
+
|
2755
|
+
|
2756
|
+
def call(result)
|
2757
|
+
|
2758
|
+
event = ::Quark.quark._CallbackEvent.new((self)._callable, (self)._next, result, self)
|
2759
|
+
(self.getContext()).collector.put(event)
|
2760
|
+
|
2761
|
+
nil
|
2762
|
+
end
|
2763
|
+
|
2764
|
+
def _getClass()
|
2765
|
+
|
2766
|
+
return "quark._Callback"
|
2767
|
+
|
2768
|
+
nil
|
2769
|
+
end
|
2770
|
+
|
2771
|
+
def _getField(name)
|
2772
|
+
|
2773
|
+
if ((name) == ("_context"))
|
2774
|
+
return (self)._context
|
2775
|
+
end
|
2776
|
+
if ((name) == ("_callable"))
|
2777
|
+
return (self)._callable
|
2778
|
+
end
|
2779
|
+
if ((name) == ("_next"))
|
2780
|
+
return (self)._next
|
2781
|
+
end
|
2782
|
+
return nil
|
2783
|
+
|
2784
|
+
nil
|
2785
|
+
end
|
2786
|
+
|
2787
|
+
def _setField(name, value)
|
2788
|
+
|
2789
|
+
if ((name) == ("_context"))
|
2790
|
+
(self)._context = ::DatawireQuarkCore.cast(value) { ::Quark.quark.concurrent.Context }
|
2791
|
+
end
|
2792
|
+
if ((name) == ("_callable"))
|
2793
|
+
(self)._callable = ::DatawireQuarkCore.cast(value) { ::Quark.quark.UnaryCallable }
|
2794
|
+
end
|
2795
|
+
if ((name) == ("_next"))
|
2796
|
+
(self)._next = ::DatawireQuarkCore.cast(value) { ::Quark.quark.Promise }
|
2797
|
+
end
|
2798
|
+
|
2799
|
+
nil
|
2800
|
+
end
|
2801
|
+
|
2802
|
+
def __init_fields__()
|
2803
|
+
|
2804
|
+
super
|
2805
|
+
self._callable = nil
|
2806
|
+
self._next = nil
|
2807
|
+
|
2808
|
+
nil
|
2809
|
+
end
|
2810
|
+
|
2811
|
+
|
2812
|
+
end
|
2813
|
+
Callback.unlazy_statics
|
2814
|
+
|
2815
|
+
def self._Passthrough; Passthrough; end
|
2816
|
+
class Passthrough < ::DatawireQuarkCore::QuarkObject
|
2817
|
+
extend ::DatawireQuarkCore::Static
|
2818
|
+
|
2819
|
+
static quark__Passthrough_ref: -> { nil }
|
2820
|
+
|
2821
|
+
|
2822
|
+
|
2823
|
+
def initialize()
|
2824
|
+
self.__init_fields__
|
2825
|
+
|
2826
|
+
nil
|
2827
|
+
end
|
2828
|
+
|
2829
|
+
|
2830
|
+
|
2831
|
+
|
2832
|
+
def call(arg)
|
2833
|
+
|
2834
|
+
return arg
|
2835
|
+
|
2836
|
+
nil
|
2837
|
+
end
|
2838
|
+
|
2839
|
+
def _getClass()
|
2840
|
+
|
2841
|
+
return "quark._Passthrough"
|
2842
|
+
|
2843
|
+
nil
|
2844
|
+
end
|
2845
|
+
|
2846
|
+
def _getField(name)
|
2847
|
+
|
2848
|
+
return nil
|
2849
|
+
|
2850
|
+
nil
|
2851
|
+
end
|
2852
|
+
|
2853
|
+
def _setField(name, value)
|
2854
|
+
|
2855
|
+
nil
|
2856
|
+
|
2857
|
+
nil
|
2858
|
+
end
|
2859
|
+
|
2860
|
+
def __init_fields__()
|
2861
|
+
|
2862
|
+
|
2863
|
+
nil
|
2864
|
+
end
|
2865
|
+
|
2866
|
+
|
2867
|
+
end
|
2868
|
+
Passthrough.unlazy_statics
|
2869
|
+
|
2870
|
+
def self._CallIfIsInstance; CallIfIsInstance; end
|
2871
|
+
class CallIfIsInstance < ::DatawireQuarkCore::QuarkObject
|
2872
|
+
attr_accessor :_underlying, :_class
|
2873
|
+
extend ::DatawireQuarkCore::Static
|
2874
|
+
|
2875
|
+
static quark__CallIfIsInstance_ref: -> { nil }
|
2876
|
+
|
2877
|
+
|
2878
|
+
|
2879
|
+
def initialize(underlying, klass)
|
2880
|
+
|
2881
|
+
self.__init_fields__
|
2882
|
+
(self)._underlying = underlying
|
2883
|
+
(self)._class = klass
|
2884
|
+
|
2885
|
+
nil
|
2886
|
+
end
|
2887
|
+
|
2888
|
+
|
2889
|
+
|
2890
|
+
|
2891
|
+
def call(arg)
|
2892
|
+
|
2893
|
+
if ((self)._class.hasInstance(arg))
|
2894
|
+
return ((self)._underlying).call(arg)
|
2895
|
+
else
|
2896
|
+
return arg
|
2897
|
+
end
|
2898
|
+
|
2899
|
+
nil
|
2900
|
+
end
|
2901
|
+
|
2902
|
+
def _getClass()
|
2903
|
+
|
2904
|
+
return "quark._CallIfIsInstance"
|
2905
|
+
|
2906
|
+
nil
|
2907
|
+
end
|
2908
|
+
|
2909
|
+
def _getField(name)
|
2910
|
+
|
2911
|
+
if ((name) == ("_underlying"))
|
2912
|
+
return (self)._underlying
|
2913
|
+
end
|
2914
|
+
if ((name) == ("_class"))
|
2915
|
+
return (self)._class
|
2916
|
+
end
|
2917
|
+
return nil
|
2918
|
+
|
2919
|
+
nil
|
2920
|
+
end
|
2921
|
+
|
2922
|
+
def _setField(name, value)
|
2923
|
+
|
2924
|
+
if ((name) == ("_underlying"))
|
2925
|
+
(self)._underlying = ::DatawireQuarkCore.cast(value) { ::Quark.quark.UnaryCallable }
|
2926
|
+
end
|
2927
|
+
if ((name) == ("_class"))
|
2928
|
+
(self)._class = ::DatawireQuarkCore.cast(value) { ::Quark.quark.reflect.QuarkClass }
|
2929
|
+
end
|
2930
|
+
|
2931
|
+
nil
|
2932
|
+
end
|
2933
|
+
|
2934
|
+
def __init_fields__()
|
2935
|
+
|
2936
|
+
self._underlying = nil
|
2937
|
+
self._class = nil
|
2938
|
+
|
2939
|
+
nil
|
2940
|
+
end
|
2941
|
+
|
2942
|
+
|
2943
|
+
end
|
2944
|
+
CallIfIsInstance.unlazy_statics
|
2945
|
+
|
2946
|
+
def self.PromiseValue; PromiseValue; end
|
2947
|
+
##
|
2948
|
+
# Snapshot of the value of a Promise, if it has one.
|
2949
|
+
|
2950
|
+
class PromiseValue < ::DatawireQuarkCore::QuarkObject
|
2951
|
+
attr_accessor :_successResult, :_failureResult, :_hasValue
|
2952
|
+
extend ::DatawireQuarkCore::Static
|
2953
|
+
|
2954
|
+
static quark_PromiseValue_ref: -> { nil }
|
2955
|
+
|
2956
|
+
|
2957
|
+
|
2958
|
+
def initialize(successResult, failureResult, hasValue)
|
2959
|
+
|
2960
|
+
self.__init_fields__
|
2961
|
+
(self)._successResult = successResult
|
2962
|
+
(self)._failureResult = failureResult
|
2963
|
+
(self)._hasValue = hasValue
|
2964
|
+
|
2965
|
+
nil
|
2966
|
+
end
|
2967
|
+
|
2968
|
+
|
2969
|
+
|
2970
|
+
|
2971
|
+
##
|
2972
|
+
# Return true if the Promise had a value at the time this was created.
|
2973
|
+
|
2974
|
+
def hasValue()
|
2975
|
+
|
2976
|
+
return (self)._hasValue
|
2977
|
+
|
2978
|
+
nil
|
2979
|
+
end
|
2980
|
+
|
2981
|
+
##
|
2982
|
+
# Return true if value is error. Result is only valid if hasValue() is true.
|
2983
|
+
|
2984
|
+
def isError()
|
2985
|
+
|
2986
|
+
return ((self)._failureResult) != (nil)
|
2987
|
+
|
2988
|
+
nil
|
2989
|
+
end
|
2990
|
+
|
2991
|
+
##
|
2992
|
+
# Return the value. Result is only valid if hasValue() is true.
|
2993
|
+
|
2994
|
+
def getValue()
|
2995
|
+
|
2996
|
+
if (self.isError())
|
2997
|
+
return (self)._failureResult
|
2998
|
+
else
|
2999
|
+
return (self)._successResult
|
3000
|
+
end
|
3001
|
+
|
3002
|
+
nil
|
3003
|
+
end
|
3004
|
+
|
3005
|
+
def _getClass()
|
3006
|
+
|
3007
|
+
return "quark.PromiseValue"
|
3008
|
+
|
3009
|
+
nil
|
3010
|
+
end
|
3011
|
+
|
3012
|
+
def _getField(name)
|
3013
|
+
|
3014
|
+
if ((name) == ("_successResult"))
|
3015
|
+
return (self)._successResult
|
3016
|
+
end
|
3017
|
+
if ((name) == ("_failureResult"))
|
3018
|
+
return (self)._failureResult
|
3019
|
+
end
|
3020
|
+
if ((name) == ("_hasValue"))
|
3021
|
+
return (self)._hasValue
|
3022
|
+
end
|
3023
|
+
return nil
|
3024
|
+
|
3025
|
+
nil
|
3026
|
+
end
|
3027
|
+
|
3028
|
+
def _setField(name, value)
|
3029
|
+
|
3030
|
+
if ((name) == ("_successResult"))
|
3031
|
+
(self)._successResult = value
|
3032
|
+
end
|
3033
|
+
if ((name) == ("_failureResult"))
|
3034
|
+
(self)._failureResult = ::DatawireQuarkCore.cast(value) { ::Quark.quark.error.Error }
|
3035
|
+
end
|
3036
|
+
if ((name) == ("_hasValue"))
|
3037
|
+
(self)._hasValue = ::DatawireQuarkCore.cast(value) { ::Object }
|
3038
|
+
end
|
3039
|
+
|
3040
|
+
nil
|
3041
|
+
end
|
3042
|
+
|
3043
|
+
def __init_fields__()
|
3044
|
+
|
3045
|
+
self._successResult = nil
|
3046
|
+
self._failureResult = nil
|
3047
|
+
self._hasValue = nil
|
3048
|
+
|
3049
|
+
nil
|
3050
|
+
end
|
3051
|
+
|
3052
|
+
|
3053
|
+
end
|
3054
|
+
PromiseValue.unlazy_statics
|
3055
|
+
|
3056
|
+
def self.Promise; Promise; end
|
3057
|
+
##
|
3058
|
+
# An object that will eventually have a result.
|
3059
|
+
# Results are passed to callables whose return value is passed
|
3060
|
+
# to resulting Promise. If a return result is a Promise it will
|
3061
|
+
# be chained automatically, i.e. callables will never be called
|
3062
|
+
# with a Promise, only with values.
|
3063
|
+
|
3064
|
+
class Promise < ::DatawireQuarkCore::QuarkObject
|
3065
|
+
attr_accessor :_lock, :_successResult, :_failureResult, :_hasResult, :_successCallbacks, :_failureCallbacks
|
3066
|
+
extend ::DatawireQuarkCore::Static
|
3067
|
+
|
3068
|
+
static quark_List_quark__Callback__ref: -> { nil }
|
3069
|
+
static quark_Promise_ref: -> { nil }
|
3070
|
+
|
3071
|
+
|
3072
|
+
|
3073
|
+
def initialize()
|
3074
|
+
|
3075
|
+
self.__init_fields__
|
3076
|
+
(self)._lock = ::DatawireQuarkCore::Lock.new()
|
3077
|
+
(self)._hasResult = false
|
3078
|
+
(self)._successResult = nil
|
3079
|
+
(self)._failureResult = ::DatawireQuarkCore.cast(nil) { ::Quark.quark.error.Error }
|
3080
|
+
(self)._successCallbacks = ::DatawireQuarkCore::List.new([])
|
3081
|
+
(self)._failureCallbacks = ::DatawireQuarkCore::List.new([])
|
3082
|
+
|
3083
|
+
nil
|
3084
|
+
end
|
3085
|
+
|
3086
|
+
|
3087
|
+
|
3088
|
+
|
3089
|
+
def _maybeRunCallbacks()
|
3090
|
+
|
3091
|
+
(self)._lock.acquire()
|
3092
|
+
if (!((self)._hasResult))
|
3093
|
+
(self)._lock.release()
|
3094
|
+
return
|
3095
|
+
end
|
3096
|
+
callbacks = (self)._successCallbacks
|
3097
|
+
value = (self)._successResult
|
3098
|
+
if (((self)._failureResult) != (nil))
|
3099
|
+
callbacks = (self)._failureCallbacks
|
3100
|
+
value = (self)._failureResult
|
3101
|
+
end
|
3102
|
+
(self)._failureCallbacks = ::DatawireQuarkCore::List.new([])
|
3103
|
+
(self)._successCallbacks = ::DatawireQuarkCore::List.new([])
|
3104
|
+
(self)._lock.release()
|
3105
|
+
idx = 0
|
3106
|
+
while ((idx) < ((callbacks).size)) do
|
3107
|
+
(callbacks)[idx].call(value)
|
3108
|
+
idx = (idx) + (1)
|
3109
|
+
end
|
3110
|
+
|
3111
|
+
nil
|
3112
|
+
end
|
3113
|
+
|
3114
|
+
def _resolve(result)
|
3115
|
+
|
3116
|
+
if (::Quark.quark.reflect.QuarkClass.ERROR.hasInstance(result))
|
3117
|
+
self._reject(::DatawireQuarkCore.cast(result) { ::Quark.quark.error.Error })
|
3118
|
+
return
|
3119
|
+
end
|
3120
|
+
(self)._lock.acquire()
|
3121
|
+
if ((self)._hasResult)
|
3122
|
+
::DatawireQuarkCore.print("BUG: Resolved Promise that already has a value.")
|
3123
|
+
(self)._lock.release()
|
3124
|
+
return
|
3125
|
+
end
|
3126
|
+
(self)._hasResult = true
|
3127
|
+
(self)._successResult = result
|
3128
|
+
(self)._lock.release()
|
3129
|
+
self._maybeRunCallbacks()
|
3130
|
+
|
3131
|
+
nil
|
3132
|
+
end
|
3133
|
+
|
3134
|
+
def _reject(err)
|
3135
|
+
|
3136
|
+
(self)._lock.acquire()
|
3137
|
+
if ((self)._hasResult)
|
3138
|
+
::DatawireQuarkCore.print("BUG: Rejected Promise that already has a value.")
|
3139
|
+
(self)._lock.release()
|
3140
|
+
return
|
3141
|
+
end
|
3142
|
+
(self)._hasResult = true
|
3143
|
+
(self)._failureResult = err
|
3144
|
+
(self)._lock.release()
|
3145
|
+
self._maybeRunCallbacks()
|
3146
|
+
|
3147
|
+
nil
|
3148
|
+
end
|
3149
|
+
|
3150
|
+
##
|
3151
|
+
# Add callback that will be called on non-Error values.
|
3152
|
+
# Its result will become the value of the returned Promise.
|
3153
|
+
|
3154
|
+
def andThen(callable)
|
3155
|
+
|
3156
|
+
result = ::Quark.quark.Promise.new()
|
3157
|
+
(self)._lock.acquire()
|
3158
|
+
((self)._successCallbacks) << (::Quark.quark._Callback.new(callable, result))
|
3159
|
+
((self)._failureCallbacks) << (::Quark.quark._Callback.new(::Quark.quark._Passthrough.new(), result))
|
3160
|
+
(self)._lock.release()
|
3161
|
+
self._maybeRunCallbacks()
|
3162
|
+
return result
|
3163
|
+
|
3164
|
+
nil
|
3165
|
+
end
|
3166
|
+
|
3167
|
+
##
|
3168
|
+
# Add callback that will be called on Error values.
|
3169
|
+
# Its result will become the value of the returned Promise.
|
3170
|
+
|
3171
|
+
def andCatch(errorClass, callable)
|
3172
|
+
|
3173
|
+
result = ::Quark.quark.Promise.new()
|
3174
|
+
callback = ::Quark.quark._Callback.new(::Quark.quark._CallIfIsInstance.new(callable, errorClass), result)
|
3175
|
+
(self)._lock.acquire()
|
3176
|
+
((self)._failureCallbacks) << (callback)
|
3177
|
+
((self)._successCallbacks) << (::Quark.quark._Callback.new(::Quark.quark._Passthrough.new(), result))
|
3178
|
+
(self)._lock.release()
|
3179
|
+
self._maybeRunCallbacks()
|
3180
|
+
return result
|
3181
|
+
|
3182
|
+
nil
|
3183
|
+
end
|
3184
|
+
|
3185
|
+
##
|
3186
|
+
# Two callbacks, one for success and one for error results.
|
3187
|
+
|
3188
|
+
def andEither(success, failure)
|
3189
|
+
|
3190
|
+
result = ::Quark.quark.Promise.new()
|
3191
|
+
(self)._lock.acquire()
|
3192
|
+
((self)._successCallbacks) << (::Quark.quark._Callback.new(success, result))
|
3193
|
+
((self)._failureCallbacks) << (::Quark.quark._Callback.new(failure, result))
|
3194
|
+
(self)._lock.release()
|
3195
|
+
self._maybeRunCallbacks()
|
3196
|
+
return result
|
3197
|
+
|
3198
|
+
nil
|
3199
|
+
end
|
3200
|
+
|
3201
|
+
##
|
3202
|
+
# Callback that will be called for both success and error results.
|
3203
|
+
|
3204
|
+
def andFinally(callable)
|
3205
|
+
|
3206
|
+
return self.andEither(callable, callable)
|
3207
|
+
|
3208
|
+
nil
|
3209
|
+
end
|
3210
|
+
|
3211
|
+
##
|
3212
|
+
# Synchronous extraction of the promise's current value, if it has any.
|
3213
|
+
# Its result will become the value of the returned Promise.
|
3214
|
+
|
3215
|
+
def value()
|
3216
|
+
|
3217
|
+
(self)._lock.acquire()
|
3218
|
+
result = ::Quark.quark.PromiseValue.new((self)._successResult, (self)._failureResult, (self)._hasResult)
|
3219
|
+
(self)._lock.release()
|
3220
|
+
return result
|
3221
|
+
|
3222
|
+
nil
|
3223
|
+
end
|
3224
|
+
|
3225
|
+
def _getClass()
|
3226
|
+
|
3227
|
+
return "quark.Promise"
|
3228
|
+
|
3229
|
+
nil
|
3230
|
+
end
|
3231
|
+
|
3232
|
+
def _getField(name)
|
3233
|
+
|
3234
|
+
if ((name) == ("_lock"))
|
3235
|
+
return (self)._lock
|
3236
|
+
end
|
3237
|
+
if ((name) == ("_successResult"))
|
3238
|
+
return (self)._successResult
|
3239
|
+
end
|
3240
|
+
if ((name) == ("_failureResult"))
|
3241
|
+
return (self)._failureResult
|
3242
|
+
end
|
3243
|
+
if ((name) == ("_hasResult"))
|
3244
|
+
return (self)._hasResult
|
3245
|
+
end
|
3246
|
+
if ((name) == ("_successCallbacks"))
|
3247
|
+
return (self)._successCallbacks
|
3248
|
+
end
|
3249
|
+
if ((name) == ("_failureCallbacks"))
|
3250
|
+
return (self)._failureCallbacks
|
3251
|
+
end
|
3252
|
+
return nil
|
3253
|
+
|
3254
|
+
nil
|
3255
|
+
end
|
3256
|
+
|
3257
|
+
def _setField(name, value)
|
3258
|
+
|
3259
|
+
if ((name) == ("_lock"))
|
3260
|
+
(self)._lock = ::DatawireQuarkCore.cast(value) { ::DatawireQuarkCore::Lock }
|
3261
|
+
end
|
3262
|
+
if ((name) == ("_successResult"))
|
3263
|
+
(self)._successResult = value
|
3264
|
+
end
|
3265
|
+
if ((name) == ("_failureResult"))
|
3266
|
+
(self)._failureResult = ::DatawireQuarkCore.cast(value) { ::Quark.quark.error.Error }
|
3267
|
+
end
|
3268
|
+
if ((name) == ("_hasResult"))
|
3269
|
+
(self)._hasResult = ::DatawireQuarkCore.cast(value) { ::Object }
|
3270
|
+
end
|
3271
|
+
if ((name) == ("_successCallbacks"))
|
3272
|
+
(self)._successCallbacks = ::DatawireQuarkCore.cast(value) { ::DatawireQuarkCore::List }
|
3273
|
+
end
|
3274
|
+
if ((name) == ("_failureCallbacks"))
|
3275
|
+
(self)._failureCallbacks = ::DatawireQuarkCore.cast(value) { ::DatawireQuarkCore::List }
|
3276
|
+
end
|
3277
|
+
|
3278
|
+
nil
|
3279
|
+
end
|
3280
|
+
|
3281
|
+
def __init_fields__()
|
3282
|
+
|
3283
|
+
self._lock = nil
|
3284
|
+
self._successResult = nil
|
3285
|
+
self._failureResult = nil
|
3286
|
+
self._hasResult = nil
|
3287
|
+
self._successCallbacks = nil
|
3288
|
+
self._failureCallbacks = nil
|
3289
|
+
|
3290
|
+
nil
|
3291
|
+
end
|
3292
|
+
|
3293
|
+
|
3294
|
+
end
|
3295
|
+
Promise.unlazy_statics
|
3296
|
+
|
3297
|
+
def self.PromiseFactory; PromiseFactory; end
|
3298
|
+
##
|
3299
|
+
# Create Promises and input their initial value. Should typically only be used by Quark standard library.
|
3300
|
+
|
3301
|
+
class PromiseFactory < ::DatawireQuarkCore::QuarkObject
|
3302
|
+
attr_accessor :promise
|
3303
|
+
extend ::DatawireQuarkCore::Static
|
3304
|
+
|
3305
|
+
static quark_PromiseFactory_ref: -> { nil }
|
3306
|
+
|
3307
|
+
|
3308
|
+
|
3309
|
+
def initialize()
|
3310
|
+
|
3311
|
+
self.__init_fields__
|
3312
|
+
(self).promise = ::Quark.quark.Promise.new()
|
3313
|
+
|
3314
|
+
nil
|
3315
|
+
end
|
3316
|
+
|
3317
|
+
|
3318
|
+
|
3319
|
+
|
3320
|
+
##
|
3321
|
+
# Set the attached Promise's initial value.
|
3322
|
+
|
3323
|
+
def resolve(result)
|
3324
|
+
|
3325
|
+
(self).promise._resolve(result)
|
3326
|
+
|
3327
|
+
nil
|
3328
|
+
end
|
3329
|
+
|
3330
|
+
##
|
3331
|
+
# Set the attached Promise's initial value to an Error.
|
3332
|
+
|
3333
|
+
def reject(err)
|
3334
|
+
|
3335
|
+
(self).promise._reject(err)
|
3336
|
+
|
3337
|
+
nil
|
3338
|
+
end
|
3339
|
+
|
3340
|
+
def _getClass()
|
3341
|
+
|
3342
|
+
return "quark.PromiseFactory"
|
3343
|
+
|
3344
|
+
nil
|
3345
|
+
end
|
3346
|
+
|
3347
|
+
def _getField(name)
|
3348
|
+
|
3349
|
+
if ((name) == ("promise"))
|
3350
|
+
return (self).promise
|
3351
|
+
end
|
3352
|
+
return nil
|
3353
|
+
|
3354
|
+
nil
|
3355
|
+
end
|
3356
|
+
|
3357
|
+
def _setField(name, value)
|
3358
|
+
|
3359
|
+
if ((name) == ("promise"))
|
3360
|
+
(self).promise = ::DatawireQuarkCore.cast(value) { ::Quark.quark.Promise }
|
3361
|
+
end
|
3362
|
+
|
3363
|
+
nil
|
3364
|
+
end
|
3365
|
+
|
3366
|
+
def __init_fields__()
|
3367
|
+
|
3368
|
+
self.promise = nil
|
3369
|
+
|
3370
|
+
nil
|
3371
|
+
end
|
3372
|
+
|
3373
|
+
|
3374
|
+
end
|
3375
|
+
PromiseFactory.unlazy_statics
|
3376
|
+
|
3377
|
+
def self._BoundMethod; BoundMethod; end
|
3378
|
+
class BoundMethod < ::DatawireQuarkCore::QuarkObject
|
3379
|
+
attr_accessor :target, :method, :additionalArgs
|
3380
|
+
extend ::DatawireQuarkCore::Static
|
3381
|
+
|
3382
|
+
static quark__BoundMethod_ref: -> { nil }
|
3383
|
+
|
3384
|
+
|
3385
|
+
|
3386
|
+
def initialize(target, methodName, additionalArgs)
|
3387
|
+
|
3388
|
+
self.__init_fields__
|
3389
|
+
(self).target = target
|
3390
|
+
(self).method = ::Quark.quark.reflect.QuarkClass.get(::DatawireQuarkCore._getClass(target)).getMethod(methodName)
|
3391
|
+
(self).additionalArgs = additionalArgs
|
3392
|
+
|
3393
|
+
nil
|
3394
|
+
end
|
3395
|
+
|
3396
|
+
|
3397
|
+
|
3398
|
+
|
3399
|
+
def call(arg)
|
3400
|
+
|
3401
|
+
args = ::Quark.quark.ListUtil.new().slice(@additionalArgs, 0, (@additionalArgs).size)
|
3402
|
+
(args).insert((0), (arg))
|
3403
|
+
return (self).method.invoke((self).target, args)
|
3404
|
+
|
3405
|
+
nil
|
3406
|
+
end
|
3407
|
+
|
3408
|
+
def _getClass()
|
3409
|
+
|
3410
|
+
return "quark._BoundMethod"
|
3411
|
+
|
3412
|
+
nil
|
3413
|
+
end
|
3414
|
+
|
3415
|
+
def _getField(name)
|
3416
|
+
|
3417
|
+
if ((name) == ("target"))
|
3418
|
+
return (self).target
|
3419
|
+
end
|
3420
|
+
if ((name) == ("method"))
|
3421
|
+
return (self).method
|
3422
|
+
end
|
3423
|
+
if ((name) == ("additionalArgs"))
|
3424
|
+
return (self).additionalArgs
|
3425
|
+
end
|
3426
|
+
return nil
|
3427
|
+
|
3428
|
+
nil
|
3429
|
+
end
|
3430
|
+
|
3431
|
+
def _setField(name, value)
|
3432
|
+
|
3433
|
+
if ((name) == ("target"))
|
3434
|
+
(self).target = value
|
3435
|
+
end
|
3436
|
+
if ((name) == ("method"))
|
3437
|
+
(self).method = ::DatawireQuarkCore.cast(value) { ::Quark.quark.reflect.Method }
|
3438
|
+
end
|
3439
|
+
if ((name) == ("additionalArgs"))
|
3440
|
+
(self).additionalArgs = ::DatawireQuarkCore.cast(value) { ::DatawireQuarkCore::List }
|
3441
|
+
end
|
3442
|
+
|
3443
|
+
nil
|
3444
|
+
end
|
3445
|
+
|
3446
|
+
def __init_fields__()
|
3447
|
+
|
3448
|
+
self.target = nil
|
3449
|
+
self.method = nil
|
3450
|
+
self.additionalArgs = nil
|
3451
|
+
|
3452
|
+
nil
|
3453
|
+
end
|
3454
|
+
|
3455
|
+
|
3456
|
+
end
|
3457
|
+
BoundMethod.unlazy_statics
|
3458
|
+
|
3459
|
+
|
3460
|
+
def self._IOScheduleTask; IOScheduleTask; end
|
3461
|
+
class IOScheduleTask < ::DatawireQuarkCore::QuarkObject
|
3462
|
+
attr_accessor :factory
|
3463
|
+
extend ::DatawireQuarkCore::Static
|
3464
|
+
|
3465
|
+
static quark__IOScheduleTask_ref: -> { nil }
|
3466
|
+
|
3467
|
+
|
3468
|
+
|
3469
|
+
def initialize(factory)
|
3470
|
+
|
3471
|
+
self.__init_fields__
|
3472
|
+
(self).factory = factory
|
3473
|
+
|
3474
|
+
nil
|
3475
|
+
end
|
3476
|
+
|
3477
|
+
|
3478
|
+
|
3479
|
+
|
3480
|
+
def onExecute(runtime)
|
3481
|
+
|
3482
|
+
(self).factory.resolve(true)
|
3483
|
+
|
3484
|
+
nil
|
3485
|
+
end
|
3486
|
+
|
3487
|
+
def _getClass()
|
3488
|
+
|
3489
|
+
return "quark._IOScheduleTask"
|
3490
|
+
|
3491
|
+
nil
|
3492
|
+
end
|
3493
|
+
|
3494
|
+
def _getField(name)
|
3495
|
+
|
3496
|
+
if ((name) == ("factory"))
|
3497
|
+
return (self).factory
|
3498
|
+
end
|
3499
|
+
return nil
|
3500
|
+
|
3501
|
+
nil
|
3502
|
+
end
|
3503
|
+
|
3504
|
+
def _setField(name, value)
|
3505
|
+
|
3506
|
+
if ((name) == ("factory"))
|
3507
|
+
(self).factory = ::DatawireQuarkCore.cast(value) { ::Quark.quark.PromiseFactory }
|
3508
|
+
end
|
3509
|
+
|
3510
|
+
nil
|
3511
|
+
end
|
3512
|
+
|
3513
|
+
def __init_fields__()
|
3514
|
+
|
3515
|
+
self.factory = nil
|
3516
|
+
|
3517
|
+
nil
|
3518
|
+
end
|
3519
|
+
|
3520
|
+
|
3521
|
+
end
|
3522
|
+
IOScheduleTask.unlazy_statics
|
3523
|
+
|
3524
|
+
def self._IOHTTPHandler; IOHTTPHandler; end
|
3525
|
+
class IOHTTPHandler < ::DatawireQuarkCore::QuarkObject
|
3526
|
+
attr_accessor :factory
|
3527
|
+
extend ::DatawireQuarkCore::Static
|
3528
|
+
|
3529
|
+
static quark__IOHTTPHandler_ref: -> { nil }
|
3530
|
+
|
3531
|
+
|
3532
|
+
|
3533
|
+
def initialize(factory)
|
3534
|
+
|
3535
|
+
self.__init_fields__
|
3536
|
+
(self).factory = factory
|
3537
|
+
|
3538
|
+
nil
|
3539
|
+
end
|
3540
|
+
|
3541
|
+
|
3542
|
+
|
3543
|
+
|
3544
|
+
def onHTTPInit(request)
|
3545
|
+
|
3546
|
+
nil
|
3547
|
+
|
3548
|
+
nil
|
3549
|
+
end
|
3550
|
+
|
3551
|
+
def onHTTPFinal(request)
|
3552
|
+
|
3553
|
+
nil
|
3554
|
+
|
3555
|
+
nil
|
3556
|
+
end
|
3557
|
+
|
3558
|
+
def onHTTPResponse(request, response)
|
3559
|
+
|
3560
|
+
(self).factory.resolve(response)
|
3561
|
+
|
3562
|
+
nil
|
3563
|
+
end
|
3564
|
+
|
3565
|
+
def onHTTPError(request, message)
|
3566
|
+
|
3567
|
+
(self).factory.reject(message)
|
3568
|
+
|
3569
|
+
nil
|
3570
|
+
end
|
3571
|
+
|
3572
|
+
def _getClass()
|
3573
|
+
|
3574
|
+
return "quark._IOHTTPHandler"
|
3575
|
+
|
3576
|
+
nil
|
3577
|
+
end
|
3578
|
+
|
3579
|
+
def _getField(name)
|
3580
|
+
|
3581
|
+
if ((name) == ("factory"))
|
3582
|
+
return (self).factory
|
3583
|
+
end
|
3584
|
+
return nil
|
3585
|
+
|
3586
|
+
nil
|
3587
|
+
end
|
3588
|
+
|
3589
|
+
def _setField(name, value)
|
3590
|
+
|
3591
|
+
if ((name) == ("factory"))
|
3592
|
+
(self).factory = ::DatawireQuarkCore.cast(value) { ::Quark.quark.PromiseFactory }
|
3593
|
+
end
|
3594
|
+
|
3595
|
+
nil
|
3596
|
+
end
|
3597
|
+
|
3598
|
+
def __init_fields__()
|
3599
|
+
|
3600
|
+
self.factory = nil
|
3601
|
+
|
3602
|
+
nil
|
3603
|
+
end
|
3604
|
+
|
3605
|
+
|
3606
|
+
end
|
3607
|
+
IOHTTPHandler.unlazy_statics
|
3608
|
+
|
3609
|
+
def self.IO; IO; end
|
3610
|
+
##
|
3611
|
+
# Promise-based I/O and scheduling APIs.
|
3612
|
+
|
3613
|
+
class IO < ::DatawireQuarkCore::QuarkObject
|
3614
|
+
extend ::DatawireQuarkCore::Static
|
3615
|
+
|
3616
|
+
static quark_IO_ref: -> { nil }
|
3617
|
+
|
3618
|
+
|
3619
|
+
|
3620
|
+
def initialize()
|
3621
|
+
self.__init_fields__
|
3622
|
+
|
3623
|
+
nil
|
3624
|
+
end
|
3625
|
+
|
3626
|
+
|
3627
|
+
|
3628
|
+
|
3629
|
+
##
|
3630
|
+
# Send a HTTP request, get back Promise that gets HTTPResponse or HTTPError result.
|
3631
|
+
|
3632
|
+
def self.httpRequest(request)
|
3633
|
+
|
3634
|
+
factory = ::Quark.quark.PromiseFactory.new()
|
3635
|
+
::Quark.quark.concurrent.Context.runtime().request(request, ::Quark.quark._IOHTTPHandler.new(factory))
|
3636
|
+
return (factory).promise
|
3637
|
+
|
3638
|
+
nil
|
3639
|
+
end
|
3640
|
+
|
3641
|
+
##
|
3642
|
+
# Schedule a callable to run in the future, return Promise with null result.
|
3643
|
+
|
3644
|
+
def self.schedule(delayInSeconds)
|
3645
|
+
|
3646
|
+
factory = ::Quark.quark.PromiseFactory.new()
|
3647
|
+
::Quark.quark.concurrent.Context.runtime().schedule(::Quark.quark._IOScheduleTask.new(factory), delayInSeconds)
|
3648
|
+
return (factory).promise
|
3649
|
+
|
3650
|
+
nil
|
3651
|
+
end
|
3652
|
+
|
3653
|
+
def _getClass()
|
3654
|
+
|
3655
|
+
return "quark.IO"
|
3656
|
+
|
3657
|
+
nil
|
3658
|
+
end
|
3659
|
+
|
3660
|
+
def _getField(name)
|
3661
|
+
|
3662
|
+
return nil
|
3663
|
+
|
3664
|
+
nil
|
3665
|
+
end
|
3666
|
+
|
3667
|
+
def _setField(name, value)
|
3668
|
+
|
3669
|
+
nil
|
3670
|
+
|
3671
|
+
nil
|
3672
|
+
end
|
3673
|
+
|
3674
|
+
def __init_fields__()
|
3675
|
+
|
3676
|
+
|
3677
|
+
nil
|
3678
|
+
end
|
3679
|
+
|
3680
|
+
|
3681
|
+
end
|
3682
|
+
IO.unlazy_statics
|
3683
|
+
end # module Quark
|
3684
|
+
end # module Quark
|