Class: Foam::Otel::PayloadCapture::BodyTee
- Inherits:
-
Object
- Object
- Foam::Otel::PayloadCapture::BodyTee
show all
- Defined in:
- lib/foam/otel/payload_capture.rb
Overview
The delegating response-body tee: observes chunks in flight during
#each (never buffering the stream), preserves #close (flushing the
attributes exactly once — on iteration completion or on close,
whichever comes first), and delegates everything else (to_path for
sendfile servers) with truthful respond_to?.
Instance Method Summary
collapse
Constructor Details
#initialize(body, acc, &on_done) ⇒ BodyTee
Returns a new instance of BodyTee.
592
593
594
595
596
597
|
# File 'lib/foam/otel/payload_capture.rb', line 592
def initialize(body, acc, &on_done)
@body = body
@acc = acc
@on_done = on_done
@flushed = false
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name) ⇒ Object
615
616
617
|
# File 'lib/foam/otel/payload_capture.rb', line 615
def method_missing(name, ...)
@body.__send__(name, ...)
end
|
Instance Method Details
#close ⇒ Object
609
610
611
612
613
|
# File 'lib/foam/otel/payload_capture.rb', line 609
def close
@body.close if @body.respond_to?(:close)
ensure
finish!(false)
end
|
#each(*args, &block) ⇒ Object
599
600
601
602
603
604
605
606
607
|
# File 'lib/foam/otel/payload_capture.rb', line 599
def each(*args, &block)
return enum_for(:each, *args) unless block
@body.each(*args) do |chunk|
@acc.observe(chunk)
yield chunk
end
finish!(true)
end
|
#respond_to_missing?(name, include_private = false) ⇒ Boolean
619
620
621
|
# File 'lib/foam/otel/payload_capture.rb', line 619
def respond_to_missing?(name, include_private = false)
@body.respond_to?(name, include_private)
end
|