Skip to content

Commit

Permalink
Cleanups from PR
Browse files Browse the repository at this point in the history
  • Loading branch information
alextwoods committed Jul 29, 2024
1 parent 74ff567 commit d057bac
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ protected void renderEventStreamBuilders() {
.forEach(shape -> {
// Event stream event members MUST target only StructureShapes
writer
.write("")
.openBlock("class $L", symbolProvider.toSymbol(shape).getName())
.call(() -> renderEventBuildMethod(shape.asStructureShape().get()))
.closeBlock("end");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ private Void eventStreamOperation(OperationShape operation) {
writer.writeYardReturn(Hearth.OUTPUT + "", "");
}
})
// TODO: PICK UP HERE. Create new EventStrem specific class for Placehodler and Response generators
.writeYardExample(
"Request syntax with placeholder values",
new PlaceholderExampleGenerator(operation, symbolProvider, model).generate()
Expand Down
52 changes: 27 additions & 25 deletions hearth/lib/hearth/http2/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,40 +97,42 @@ def close

private

# rubocop:disable Metrics
def start_connection_thread
@mutex.synchronize do
@thread = Thread.new do
while !@socket.closed? && !@socket.eof?
begin
data = @socket.read_nonblock(CHUNKSIZE)
@h2_client << data
rescue IO::WaitReadable
begin
if @socket.wait_readable(read_timeout)
# available, retry to start reading
retry
else
log_debug('socket connection read time out')
close
end
rescue StandardError
# error can happen when closing the socket
# while it's waiting for read
close
end
rescue StandardError => e
@errors << e
@thread = Thread.new(&method(:socket_read_loop))
@thread.abort_on_exception = true
end
end

# rubocop:disable Metrics/MethodLength
def socket_read_loop
while !@socket.closed? && !@socket.eof?
begin
data = @socket.read_nonblock(CHUNKSIZE)
@h2_client << data
rescue IO::WaitReadable
begin
if @socket.wait_readable(read_timeout)
# available, retry to start reading
retry
else
log_debug('socket connection read time out')
close
raise e
end
rescue StandardError
# error can happen when closing the socket
# while it's waiting for read
close
end
rescue StandardError => e
@errors << e
close
raise e
end
@thread.abort_on_exception = true
end
close
end
# rubocop:enable Metrics
# rubocop:enable Metrics/MethodLength

def create_tcp_connection(options)
endpoint = options[:endpoint]
Expand Down
4 changes: 1 addition & 3 deletions hearth/lib/hearth/http2/request.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
# frozen_string_literal: true

require_relative '../http/request'

module Hearth
module HTTP2
# Represents an HTTP2 request.
class Request < Hearth::HTTP::Request
class Request < HTTP::Request
# @param [Boolean] keep_open (false) When true the stream is left open
# (end_stream is set to false) after the data from the request body
# is sent.
Expand Down
4 changes: 1 addition & 3 deletions hearth/lib/hearth/http2/response.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
# frozen_string_literal: true

require_relative '../http/response'

module Hearth
module HTTP2
# Represents an HTTP2 Response.
class Response < Hearth::HTTP::Response
class Response < HTTP::Response
# @param (see Hearth::HTTP::Response#initialize)
def initialize(**kwargs)
super(**kwargs)
Expand Down

0 comments on commit d057bac

Please sign in to comment.