Class: Baykit::BayServer::Docker::SendFile::SendFileShip
- Inherits:
-
Common::ReadOnlyShip
- Object
- Ships::Ship
- Common::ReadOnlyShip
- Baykit::BayServer::Docker::SendFile::SendFileShip
- Includes:
- Agent, Agent::Multiplexer, Rudders, Tours, Tours::ReqContentHandler
- Defined in:
- lib/baykit/bayserver/docker/send_file/send_file_ship.rb
Constant Summary
Constants included from Tours::ReqContentHandler
Tours::ReqContentHandler::DEV_NULL
Constants inherited from Ships::Ship
Ships::Ship::INVALID_SHIP_ID, Ships::Ship::SHIP_ID_NOCHECK
Instance Attribute Summary collapse
-
#abortable ⇒ Object
readonly
Returns the value of attribute abortable.
-
#file_content ⇒ Object
readonly
Returns the value of attribute file_content.
-
#file_wrote_len ⇒ Object
readonly
Returns the value of attribute file_wrote_len.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#tour ⇒ Object
readonly
Returns the value of attribute tour.
-
#tour_id ⇒ Object
readonly
Returns the value of attribute tour_id.
Attributes inherited from Ships::Ship
#agent_id, #initialized, #keeping, #object_id, #rudder, #ship_id, #transporter
Instance Method Summary collapse
- #check_timeout(duration_sec) ⇒ Object
- #init(rd, tp, tur, file_content) ⇒ Object
- #notify_close ⇒ Object
- #notify_eof ⇒ Object
- #notify_error(e) ⇒ Object
-
#notify_read(buf) ⇒ Object
Implements ReqContentHandler.
-
#reset ⇒ Object
Implements Reusable.
Methods included from Tours::ReqContentHandler
#on_abort_req, #on_end_req_content, #on_read_req_content
Methods inherited from Common::ReadOnlyShip
#notify_connect, #notify_handshake_done, #notify_protocol_error
Methods inherited from Ships::Ship
#check_ship_id, #id, #initialize, #notify_connect, #notify_handshake_done, #notify_protocol_error, #post_close, #resume_read
Constructor Details
This class inherits a constructor from Baykit::BayServer::Ships::Ship
Instance Attribute Details
#abortable ⇒ Object (readonly)
Returns the value of attribute abortable.
22 23 24 |
# File 'lib/baykit/bayserver/docker/send_file/send_file_ship.rb', line 22 def abortable @abortable end |
#file_content ⇒ Object (readonly)
Returns the value of attribute file_content.
12 13 14 |
# File 'lib/baykit/bayserver/docker/send_file/send_file_ship.rb', line 12 def file_content @file_content end |
#file_wrote_len ⇒ Object (readonly)
Returns the value of attribute file_wrote_len.
10 11 12 |
# File 'lib/baykit/bayserver/docker/send_file/send_file_ship.rb', line 10 def file_wrote_len @file_wrote_len end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
21 22 23 |
# File 'lib/baykit/bayserver/docker/send_file/send_file_ship.rb', line 21 def path @path end |
#tour ⇒ Object (readonly)
Returns the value of attribute tour.
13 14 15 |
# File 'lib/baykit/bayserver/docker/send_file/send_file_ship.rb', line 13 def tour @tour end |
#tour_id ⇒ Object (readonly)
Returns the value of attribute tour_id.
14 15 16 |
# File 'lib/baykit/bayserver/docker/send_file/send_file_ship.rb', line 14 def tour_id @tour_id end |
Instance Method Details
#check_timeout(duration_sec) ⇒ Object
94 95 96 |
# File 'lib/baykit/bayserver/docker/send_file/send_file_ship.rb', line 94 def check_timeout(duration_sec) return false end |
#init(rd, tp, tur, file_content) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/baykit/bayserver/docker/send_file/send_file_ship.rb', line 24 def init(rd, tp, tur, file_content) super(tur.ship.agent_id, rd, tp) @file_wrote_len = 0 @tour = tur @tour_id = tur.tour_id @file_content = file_content end |
#notify_close ⇒ Object
90 91 92 |
# File 'lib/baykit/bayserver/docker/send_file/send_file_ship.rb', line 90 def notify_close BayLog.debug("%s Close", self) end |
#notify_eof ⇒ Object
80 81 82 83 84 85 86 87 88 |
# File 'lib/baykit/bayserver/docker/send_file/send_file_ship.rb', line 80 def notify_eof BayLog.debug("%s EOF", self) begin @tour.res.end_res_content(@tour_id) rescue IOError => e BayLog.debug_e(e) end return NextSocketAction::CLOSE end |
#notify_error(e) ⇒ Object
71 72 73 74 75 76 77 78 |
# File 'lib/baykit/bayserver/docker/send_file/send_file_ship.rb', line 71 def notify_error(e) BayLog.debug_e(e, "%s Error notified", self) begin @tour.res.send_error(@tour_id, HttpStatus::INTERNAL_SERVER_ERROR, nil, e) rescue IOError => ex BayLog.debug_e(ex) end end |
#notify_read(buf) ⇒ Object
Implements ReqContentHandler
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/baykit/bayserver/docker/send_file/send_file_ship.rb', line 47 def notify_read(buf) @file_wrote_len += buf.length BayLog.debug("%s read file %d bytes: total=%d", self, buf.length, @file_wrote_len) begin available = @tour.res.send_res_content(@tour_id, buf, 0, buf.length) if @file_content != nil #BayLog.debug("buf=%s target=%s", buf, @file_content.content) @file_content.content << buf @file_content.bytes_loaded += buf.length end if available return NextSocketAction::CONTINUE else return NextSocketAction::SUSPEND end rescue IOError => e notify_error(e) return NextSocketAction::CLOSE end end |
#reset ⇒ Object
Implements Reusable
36 37 38 39 40 41 |
# File 'lib/baykit/bayserver/docker/send_file/send_file_ship.rb', line 36 def reset super @file_wrote_len = 0 @tour_id = 0 @tour = nil end |