Class: Baykit::BayServer::Docker::SendFile::WaitFileShip
- Inherits:
-
Common::ReadOnlyShip
- Object
- Ships::Ship
- Common::ReadOnlyShip
- Baykit::BayServer::Docker::SendFile::WaitFileShip
- Defined in:
- lib/baykit/bayserver/docker/send_file/wait_file_ship.rb
Constant Summary
Constants inherited from Ships::Ship
Ships::Ship::INVALID_SHIP_ID, Ships::Ship::SHIP_ID_NOCHECK
Instance Attribute Summary collapse
-
#file_content ⇒ Object
readonly
Returns the value of attribute file_content.
-
#handler ⇒ Object
readonly
Returns the value of attribute handler.
-
#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, handler) ⇒ Object
-
#initialize ⇒ WaitFileShip
constructor
A new instance of WaitFileShip.
- #notify_close ⇒ Object
- #notify_eof ⇒ Object
- #notify_error(e) ⇒ Object
-
#notify_read(buf) ⇒ Object
Implements ReadOnlyShip.
-
#reset ⇒ Object
Implements Reusable.
- #to_s ⇒ Object
Methods inherited from Common::ReadOnlyShip
#notify_connect, #notify_handshake_done, #notify_protocol_error
Methods inherited from Ships::Ship
#check_ship_id, #id, #notify_connect, #notify_handshake_done, #notify_protocol_error, #post_close, #resume_read
Constructor Details
#initialize ⇒ WaitFileShip
Returns a new instance of WaitFileShip.
18 19 20 21 |
# File 'lib/baykit/bayserver/docker/send_file/wait_file_ship.rb', line 18 def initialize() @file_content = nil @handler = nil end |
Instance Attribute Details
#file_content ⇒ Object (readonly)
Returns the value of attribute file_content.
13 14 15 |
# File 'lib/baykit/bayserver/docker/send_file/wait_file_ship.rb', line 13 def file_content @file_content end |
#handler ⇒ Object (readonly)
Returns the value of attribute handler.
14 15 16 |
# File 'lib/baykit/bayserver/docker/send_file/wait_file_ship.rb', line 14 def handler @handler end |
#tour ⇒ Object (readonly)
Returns the value of attribute tour.
16 17 18 |
# File 'lib/baykit/bayserver/docker/send_file/wait_file_ship.rb', line 16 def tour @tour end |
#tour_id ⇒ Object (readonly)
Returns the value of attribute tour_id.
17 18 19 |
# File 'lib/baykit/bayserver/docker/send_file/wait_file_ship.rb', line 17 def tour_id @tour_id end |
Instance Method Details
#check_timeout(duration_sec) ⇒ Object
84 85 86 |
# File 'lib/baykit/bayserver/docker/send_file/wait_file_ship.rb', line 84 def check_timeout(duration_sec) return false end |
#init(rd, tp, tur, file_content, handler) ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/baykit/bayserver/docker/send_file/wait_file_ship.rb', line 23 def init(rd, tp, tur, file_content, handler) super(tur.ship.agent_id, rd, tp) @tour = tur @tour_id = tur.tour_id @file_content = file_content @handler = handler end |
#notify_close ⇒ Object
81 82 |
# File 'lib/baykit/bayserver/docker/send_file/wait_file_ship.rb', line 81 def notify_close end |
#notify_eof ⇒ Object
77 78 79 |
# File 'lib/baykit/bayserver/docker/send_file/wait_file_ship.rb', line 77 def notify_eof() raise Sink.new end |
#notify_error(e) ⇒ Object
68 69 70 71 72 73 74 75 |
# File 'lib/baykit/bayserver/docker/send_file/wait_file_ship.rb', line 68 def notify_error(e) BayLog.debug_e(e, "%s Error notified", self) begin @tour.res.send_error(@tour_id, HttpStatus.INTERNAL_SERVER_ERROR, null, e) rescue IOError => ex BayLog.debug_e(ex) end end |
#notify_read(buf) ⇒ Object
Implements ReadOnlyShip
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/baykit/bayserver/docker/send_file/wait_file_ship.rb', line 50 def notify_read(buf) BayLog.debug("%s file read completed", self) begin @handler.send_file_from_cache rescue HttpException => e begin @tour.res.send_error(Tour::TOUR_ID_NOCHECK, e.status, e.) rescue IOError => ex notify_error(ex) return NextSocketAction::CLOSE end end return NextSocketAction::CONTINUE end |
#reset ⇒ Object
Implements Reusable
39 40 41 42 43 44 |
# File 'lib/baykit/bayserver/docker/send_file/wait_file_ship.rb', line 39 def reset super @file_content = nil @tour_id = 0 @tour = nil end |
#to_s ⇒ Object
31 32 33 |
# File 'lib/baykit/bayserver/docker/send_file/wait_file_ship.rb', line 31 def to_s return "agt#" + @agent_id.to_s + " wait_file#" + @ship_id.to_s + "/" + @object_id.to_s end |