lowloop 0.8.11 → 0.8.12

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 18c405026e9ac9963370fe8160d332a281556316ed45eefb348d527b3850f252
4
- data.tar.gz: 9443d33e68f4d9b60202112bb0c54bfcf8baab10d0c60cb0c1fefa0226d3cab9
3
+ metadata.gz: 6b0bd2b3e783808038db19c6939be1a9a5bed9613c3a4ffed8eb68826a09c01b
4
+ data.tar.gz: d6a444d20f63010a16592955f07d25ab3a98253ab7e5e19af656ea81a9a3832c
5
5
  SHA512:
6
- metadata.gz: 77ede7d33f4f405614ded0e87c481ba0ee6a495b88d3b8298982a1fcac58db2daed643dc39c516f34ec1d6d97cc05ff2752fb22c8c800d7c8a6a38890d83bcc1
7
- data.tar.gz: 24ecd76e384df5a0d575720799f606b4e3ea7e0cceaf641829e24c4af754b3f0ef0ebda2be809ceeb7e16fcb3ae9e05121037c9d3a9a969ce8624ff81bada135
6
+ metadata.gz: 52176738f1f151968d630f49949c846c9a44b54a0094392cee18f3fd0f4e1cff83533996a65c95b08b0025b46403be6d0fe2f04376420f233d79625eca99aa42
7
+ data.tar.gz: 5421f9843ecb0b284bcb0fdd8fcc15a238c8eaecb53b04f67fe67f98b6a9e1da30b50339f7c77a652d16384ddae725280a8f78291c8af284b6f2dc51bdb21679
@@ -11,13 +11,38 @@ module Low
11
11
  DEFAULT_KEEP_ALIVE_TIMEOUT = 30
12
12
  DEFAULT_REQUEST_TIMEOUT = 10
13
13
 
14
+ class << self
15
+ # The connections open now. Each is a client like a browser or a proxy such as Caddy, which keeps a few open for
16
+ # its requests. They're all handled on the event loop's thread, so the count needs no lock.
17
+ def open_count
18
+ @open_count ||= 0
19
+ end
20
+
21
+ def opened
22
+ @open_count = open_count + 1
23
+ end
24
+
25
+ def closed
26
+ @open_count = open_count - 1
27
+ end
28
+ end
29
+
14
30
  # on_error is called with an error raised while responding to a request, before responding with a 500.
15
31
  def initialize(config:, on_error: nil)
16
32
  @config = config
17
33
  @on_error = on_error
18
34
  end
19
35
 
36
+ # Counts the connection as open while its requests are served.
20
37
  def handle_connection(socket:)
38
+ self.class.opened
39
+ serve_requests(socket:)
40
+ ensure
41
+ self.class.closed
42
+ end
43
+
44
+ # Answers each request on a connection until the client closes it or stops sending.
45
+ def serve_requests(socket:)
21
46
  stream = RequestParser.create_stream(socket:)
22
47
  keep_alive = true
23
48
  version = nil
data/lib/version.rb CHANGED
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Low
4
4
  module Loop
5
- VERSION = '0.8.11'
5
+ VERSION = '0.8.12'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lowloop
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.11
4
+ version: 0.8.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - maedi