protocol-http2 0.9.7 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/protocol/http2/connection.rb +14 -2
- data/lib/protocol/http2/flow_control.rb +1 -0
- data/lib/protocol/http2/stream.rb +15 -1
- data/lib/protocol/http2/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 65e32ccd867aeb59ecc2f549fd376faf912662e9dc13013fb96631e0f1a818e9
|
4
|
+
data.tar.gz: d5cea11e3665707f1e1e187c2d38661615d5731bbf37253c1ff020b581364c8d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d54116953f0ecab132997502fdc8a53f0df18865372773bf1edc5db393a922c60c49b7a46c0deaff3702a6bf57e244316396424081d15efa0350421fa8cd55c9
|
7
|
+
data.tar.gz: e45da44d211b8ff2b37c094fb5674e3fb508681a897931b1786db96413665bc6182140986c289f6a6dd0ab38225348f5ab6adb0a2c0c0bd403d95bfc7a5d3173
|
@@ -35,6 +35,8 @@ module Protocol
|
|
35
35
|
@streams = {}
|
36
36
|
@children = {}
|
37
37
|
|
38
|
+
@active = 0
|
39
|
+
|
38
40
|
@framer = framer
|
39
41
|
@local_stream_id = local_stream_id
|
40
42
|
@remote_stream_id = 0
|
@@ -97,9 +99,19 @@ module Protocol
|
|
97
99
|
@state == :closed
|
98
100
|
end
|
99
101
|
|
102
|
+
# The stream has become active (i.e. not idle or closed).
|
103
|
+
def activate(stream)
|
104
|
+
@active += 1
|
105
|
+
end
|
106
|
+
|
107
|
+
# The stream is no longer active (i.e. has become closed).
|
108
|
+
def deactivate(stream)
|
109
|
+
@active -= 1
|
110
|
+
end
|
111
|
+
|
112
|
+
# The number of active streams.
|
100
113
|
def active_streams
|
101
|
-
|
102
|
-
@streams.each_value.select(&:active?)
|
114
|
+
@active
|
103
115
|
end
|
104
116
|
|
105
117
|
# Close the underlying framer and all streams.
|
@@ -103,6 +103,7 @@ module Protocol
|
|
103
103
|
end
|
104
104
|
|
105
105
|
# Traverse active streams in order of priority and allow them to consume the available flow-control window.
|
106
|
+
# @todo This function can get slow when there are a lot of children [INEFFICIENT].
|
106
107
|
# @param amount [Integer] the amount of data to write. Defaults to the current window capacity.
|
107
108
|
def consume_window(size = self.available_size)
|
108
109
|
# Don't consume more than the available window size:
|
@@ -120,6 +120,10 @@ module Protocol
|
|
120
120
|
|
121
121
|
@state = state
|
122
122
|
|
123
|
+
if active?
|
124
|
+
connnection.active(self)
|
125
|
+
end
|
126
|
+
|
123
127
|
# Stream priority:
|
124
128
|
@dependent_id = dependent_id
|
125
129
|
@weight = weight
|
@@ -309,7 +313,12 @@ module Protocol
|
|
309
313
|
end
|
310
314
|
|
311
315
|
def open!
|
312
|
-
@state
|
316
|
+
if @state == :idle
|
317
|
+
@state = :open
|
318
|
+
@connection.activate(self)
|
319
|
+
else
|
320
|
+
raise ProtocolError, "Cannot open stream in state: #{@state}"
|
321
|
+
end
|
313
322
|
|
314
323
|
return self
|
315
324
|
end
|
@@ -319,6 +328,9 @@ module Protocol
|
|
319
328
|
def close!(error_code = nil)
|
320
329
|
@state = :closed
|
321
330
|
|
331
|
+
@connection.deactivate(self)
|
332
|
+
self.parent&.remove_child(self)
|
333
|
+
|
322
334
|
if error_code
|
323
335
|
error = StreamError.new("Stream closed!", error_code)
|
324
336
|
end
|
@@ -481,6 +493,7 @@ module Protocol
|
|
481
493
|
def reserved_local!
|
482
494
|
if @state == :idle
|
483
495
|
@state = :reserved_local
|
496
|
+
@connection.activate(self)
|
484
497
|
else
|
485
498
|
raise ProtocolError, "Cannot reserve stream in state: #{@state}"
|
486
499
|
end
|
@@ -489,6 +502,7 @@ module Protocol
|
|
489
502
|
def reserved_remote!
|
490
503
|
if @state == :idle
|
491
504
|
@state = :reserved_remote
|
505
|
+
@connection.activate(self)
|
492
506
|
else
|
493
507
|
raise ProtocolError, "Cannot reserve stream in state: #{@state}"
|
494
508
|
end
|