Class: Connect::Transport
- Inherits:
-
Object
- Object
- Connect::Transport
- Defined in:
- lib/connect/transport.rb
Instance Attribute Summary collapse
-
#accept_compression ⇒ Object
readonly
Returns the value of attribute accept_compression.
-
#base_url ⇒ Object
readonly
Returns the value of attribute base_url.
-
#compress_min_bytes ⇒ Object
readonly
Returns the value of attribute compress_min_bytes.
-
#read_max_bytes ⇒ Object
readonly
Returns the value of attribute read_max_bytes.
-
#send_compression ⇒ Object
readonly
Returns the value of attribute send_compression.
-
#write_max_bytes ⇒ Object
readonly
Returns the value of attribute write_max_bytes.
Instance Method Summary collapse
-
#initialize(base_url:, accept_compression: [Compression::Gzip], send_compression: Compression::Gzip, compress_min_bytes: 1024, read_max_bytes: 0xffffffff, write_max_bytes: 0xffffffff) ⇒ Transport
constructor
A new instance of Transport.
- #stream(service:, method:, input:, header:, trailer:) ⇒ Object
- #unary(service:, method:, input:, header:, trailer:) ⇒ Object
Constructor Details
#initialize(base_url:, accept_compression: [Compression::Gzip], send_compression: Compression::Gzip, compress_min_bytes: 1024, read_max_bytes: 0xffffffff, write_max_bytes: 0xffffffff) ⇒ Transport
Returns a new instance of Transport.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/connect/transport.rb', line 12 def initialize( base_url:, accept_compression: [Compression::Gzip], send_compression: Compression::Gzip, compress_min_bytes: 1024, read_max_bytes: 0xffffffff, write_max_bytes: 0xffffffff ) @base_url = base_url @accept_compression = accept_compression @send_compression = send_compression @compress_min_bytes = compress_min_bytes @read_max_bytes = read_max_bytes @write_max_bytes = write_max_bytes end |
Instance Attribute Details
#accept_compression ⇒ Object (readonly)
Returns the value of attribute accept_compression.
5 6 7 |
# File 'lib/connect/transport.rb', line 5 def accept_compression @accept_compression end |
#base_url ⇒ Object (readonly)
Returns the value of attribute base_url.
5 6 7 |
# File 'lib/connect/transport.rb', line 5 def base_url @base_url end |
#compress_min_bytes ⇒ Object (readonly)
Returns the value of attribute compress_min_bytes.
5 6 7 |
# File 'lib/connect/transport.rb', line 5 def compress_min_bytes @compress_min_bytes end |
#read_max_bytes ⇒ Object (readonly)
Returns the value of attribute read_max_bytes.
5 6 7 |
# File 'lib/connect/transport.rb', line 5 def read_max_bytes @read_max_bytes end |
#send_compression ⇒ Object (readonly)
Returns the value of attribute send_compression.
5 6 7 |
# File 'lib/connect/transport.rb', line 5 def send_compression @send_compression end |
#write_max_bytes ⇒ Object (readonly)
Returns the value of attribute write_max_bytes.
5 6 7 |
# File 'lib/connect/transport.rb', line 5 def write_max_bytes @write_max_bytes end |
Instance Method Details
#stream(service:, method:, input:, header:, trailer:) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/connect/transport.rb', line 44 def stream(service:, method:, input:, header:, trailer:) raise NotImplementedError, "Bidi streaming is not supported with HTTP/1.1" if method.bidi_stream? uri = build_uri(service: service, method: method) response = do_response( uri: uri, request: build_stream_request(uri: uri, method: method, input: input, header: header, trailer: trailer), ) case response.code when "200" parse_stream_response(response: response, method: method) else raise Connect::Error.new( code: Code.for_http_code(response.code), message: "Unexpected HTTP status code: #{response.code}", ) end end |
#unary(service:, method:, input:, header:, trailer:) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/connect/transport.rb', line 28 def unary(service:, method:, input:, header:, trailer:) uri = build_uri(service: service, method: method) response = do_response( uri: uri, request: build_unary_request(uri: uri, method: method, input: input, header: header, trailer: trailer), ) case response.code when "200" parse_unary_response(response: response, method: method) else raise parse_unary_error(response: response) end end |