Class: TgMq::OutputShaper
- Inherits:
-
Object
- Object
- TgMq::OutputShaper
- Defined in:
- lib/tg_mq/output_shaper.rb
Instance Attribute Summary collapse
-
#chunk_size ⇒ Object
readonly
Returns the value of attribute chunk_size.
Instance Method Summary collapse
- #deq(*args, **kwargs) ⇒ Object
- #enqueue_data(data, &callback) ⇒ Object
-
#initialize(chunk_size: 110) ⇒ OutputShaper
constructor
A new instance of OutputShaper.
Constructor Details
#initialize(chunk_size: 110) ⇒ OutputShaper
Returns a new instance of OutputShaper.
5 6 7 8 9 |
# File 'lib/tg_mq/output_shaper.rb', line 5 def initialize(chunk_size: 110) @chunk_size = chunk_size @seq = 0 @queue = SizedQueue.new(10) end |
Instance Attribute Details
#chunk_size ⇒ Object (readonly)
Returns the value of attribute chunk_size.
3 4 5 |
# File 'lib/tg_mq/output_shaper.rb', line 3 def chunk_size @chunk_size end |
Instance Method Details
#deq(*args, **kwargs) ⇒ Object
19 20 21 |
# File 'lib/tg_mq/output_shaper.rb', line 19 def deq(*args, **kwargs) @queue.deq(*args, **kwargs) end |
#enqueue_data(data, &callback) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/tg_mq/output_shaper.rb', line 11 def enqueue_data(data, &callback) frames = split_to_frames(next_seq!, data).to_a frames.last&.set_callback(&callback) frames.each do |frame| @queue << frame end end |