Class: Biryani::Frame::Goaway

Inherits:
Object
  • Object
show all
Defined in:
lib/biryani/frame/goaway.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(last_stream_id, error_code, debug) ⇒ Goaway

Returns a new instance of Goaway.

Parameters:

  • last_stream_id (Integer)
  • error_code (Integer)
  • debug (String)


9
10
11
12
13
14
15
# File 'lib/biryani/frame/goaway.rb', line 9

def initialize(last_stream_id, error_code, debug)
  @f_type = FrameType::GOAWAY
  @stream_id = 0
  @last_stream_id = last_stream_id
  @error_code = error_code
  @debug = debug
end

Instance Attribute Details

#debugObject (readonly)

Returns the value of attribute debug.



4
5
6
# File 'lib/biryani/frame/goaway.rb', line 4

def debug
  @debug
end

#error_codeObject (readonly)

Returns the value of attribute error_code.



4
5
6
# File 'lib/biryani/frame/goaway.rb', line 4

def error_code
  @error_code
end

#f_typeObject (readonly)

Returns the value of attribute f_type.



4
5
6
# File 'lib/biryani/frame/goaway.rb', line 4

def f_type
  @f_type
end

#last_stream_idObject (readonly)

Returns the value of attribute last_stream_id.



4
5
6
# File 'lib/biryani/frame/goaway.rb', line 4

def last_stream_id
  @last_stream_id
end

#stream_idObject (readonly)

Returns the value of attribute stream_id.



4
5
6
# File 'lib/biryani/frame/goaway.rb', line 4

def stream_id
  @stream_id
end

Class Method Details

.read(s, _flags, stream_id) ⇒ Goaway

Parameters:

  • s (String)
  • _flags (Integer)
  • stream_id (Integer)

Returns:



35
36
37
38
39
40
41
42
43
# File 'lib/biryani/frame/goaway.rb', line 35

def self.read(s, _flags, stream_id)
  return ConnectionError.new(ErrorCode::PROTOCOL_ERROR, 'invalid frame') unless stream_id.zero?

  io = IO::Buffer.for(s)
  last_stream_id, error_code = io.get_values(%i[U32 U32], 0)
  debug = io.get_string(8)

  Goaway.new(last_stream_id, error_code, debug)
end

Instance Method Details

#lengthInteger

Returns:

  • (Integer)


18
19
20
# File 'lib/biryani/frame/goaway.rb', line 18

def length
  @debug.bytesize + 8
end

#to_binary_sString

Returns:

  • (String)


23
24
25
26
27
28
# File 'lib/biryani/frame/goaway.rb', line 23

def to_binary_s
  payload_length = length
  flags = 0x00

  Frame.to_binary_s_header(payload_length, @f_type, flags, @stream_id) + [@last_stream_id, @error_code].pack('NN') + @debug
end