Class: Protocol::HTTP::Executor::Body::StreamOutput

Inherits:
Object
  • Object
show all
Defined in:
lib/protocol/http/executor/body/output.rb

Overview

A writable output used while executing a streamable body in the worker.

Instance Method Summary collapse

Constructor Details

#initialize(channel) ⇒ StreamOutput

Initialize a stream output.



135
136
137
138
# File 'lib/protocol/http/executor/body/output.rb', line 135

def initialize(channel)
	@channel = channel
	@closed = false
end

Instance Method Details

#close(error = nil) ⇒ Object

Close the stream output for writing.



160
161
162
# File 'lib/protocol/http/executor/body/output.rb', line 160

def close(error = nil)
	close_write(error)
end

#close_write(error = nil) ⇒ Object

Close the stream output for writing.



155
156
157
# File 'lib/protocol/http/executor/body/output.rb', line 155

def close_write(error = nil)
	@closed = true
end

#closed?Boolean

Returns:

  • (Boolean)


165
166
167
# File 'lib/protocol/http/executor/body/output.rb', line 165

def closed?
	@closed
end

#empty?Boolean

Returns:

  • (Boolean)


170
171
172
# File 'lib/protocol/http/executor/body/output.rb', line 170

def empty?
	true
end

#flushObject

Flush pending output.



151
152
# File 'lib/protocol/http/executor/body/output.rb', line 151

def flush
end

#write(chunk) ⇒ Object Also known as: <<

Write an output chunk.

Raises:

  • (IOError)


141
142
143
144
145
146
# File 'lib/protocol/http/executor/body/output.rb', line 141

def write(chunk)
	raise IOError, "The stream output is closed!" if @closed
	
	@channel.write(:chunk, chunk)
	return chunk.bytesize
end