Class: NchanTools::Subscriber::Client
- Inherits:
-
Object
- Object
- NchanTools::Subscriber::Client
show all
- Defined in:
- lib/nchan_tools/pubsub.rb
Defined Under Namespace
Classes: ErrorResponse, ParserBundle
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(subscriber, arg = {}) ⇒ Client
Returns a new instance of Client.
392
393
394
395
396
|
# File 'lib/nchan_tools/pubsub.rb', line 392
def initialize(subscriber, arg={})
@notready = 9000
@cooked_ready=Celluloid::Condition.new
@logger = arg[:logger]
end
|
Instance Attribute Details
#concurrency ⇒ Object
Returns the value of attribute concurrency.
251
252
253
|
# File 'lib/nchan_tools/pubsub.rb', line 251
def concurrency
@concurrency
end
|
Class Method Details
.aliases ⇒ Object
281
282
283
|
# File 'lib/nchan_tools/pubsub.rb', line 281
def self.aliases
[]
end
|
.inherited(subclass) ⇒ Object
270
271
272
273
|
# File 'lib/nchan_tools/pubsub.rb', line 270
def self.inherited(subclass)
@@inherited||=[]
@@inherited << subclass
end
|
.lookup(name) ⇒ Object
275
276
277
278
279
280
|
# File 'lib/nchan_tools/pubsub.rb', line 275
def self.lookup(name)
@@inherited.each do |klass|
return klass if klass.aliases.include? name
end
nil
end
|
.unique_aliases ⇒ Object
285
286
287
288
289
290
291
|
# File 'lib/nchan_tools/pubsub.rb', line 285
def self.unique_aliases
uniqs=[]
@@inherited.each do |klass|
uniqs << klass.aliases.first if klass.aliases.length > 0
end
uniqs
end
|
Instance Method Details
#error(code, msg, bundle = nil) ⇒ Object
297
298
299
300
301
|
# File 'lib/nchan_tools/pubsub.rb', line 297
def error(code, msg, bundle=nil)
err=ErrorResponse.new code, msg, bundle, @error_what, @error_failword
err.caller=self
err
end
|
#handle_bundle_error(bundle, msg, err) ⇒ Object
371
372
373
374
375
376
377
378
|
# File 'lib/nchan_tools/pubsub.rb', line 371
def handle_bundle_error(bundle, msg, err)
if err && !(EOFError === err)
msg="<#{msg}>\n#{err.backtrace.join "\n"}"
end
@subscriber.on_failure error(0, msg, bundle)
@subscriber.finished+=1
close bundle
end
|
#poke(what = nil, timeout = nil) ⇒ Object
380
381
382
383
384
385
386
387
388
389
390
|
# File 'lib/nchan_tools/pubsub.rb', line 380
def poke(what=nil, timeout = nil)
begin
if what == :ready
(@notready.nil? || @notready > 0) && @cooked_ready.wait(timeout)
else
@connected > 0 && @cooked.wait(timeout)
end
rescue Celluloid::ConditionError => e
end
end
|
#provides_msgid? ⇒ Boolean
293
294
295
|
# File 'lib/nchan_tools/pubsub.rb', line 293
def provides_msgid?
true
end
|
#run ⇒ Object
398
399
400
|
# File 'lib/nchan_tools/pubsub.rb', line 398
def run
raise SubscriberError, "Not Implemented"
end
|
#stop(msg = "Stopped", src_bundle = nil) ⇒ Object
402
403
404
405
|
# File 'lib/nchan_tools/pubsub.rb', line 402
def stop(msg = "Stopped", src_bundle = nil)
@subscriber.on_failure error(0, msg, src_bundle)
@logger.log :subscriber, :stop if @logger
end
|