lowloop 0.8.10 → 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: c54dbc5bf68ee5357424ba22dcfdb2ef1ebebb2608d5ac9958b51b1f65e0ae8b
4
- data.tar.gz: a1ac0bc1688aa1fc4db65513685f62d4488189c80374bc83dae8cc77a29751b2
3
+ metadata.gz: 6b0bd2b3e783808038db19c6939be1a9a5bed9613c3a4ffed8eb68826a09c01b
4
+ data.tar.gz: d6a444d20f63010a16592955f07d25ab3a98253ab7e5e19af656ea81a9a3832c
5
5
  SHA512:
6
- metadata.gz: 0aaac6f932f6d100d24fa5790b1b628af5582a8e452328a596e5e416aa4c09c85853d44948e9fc6059fecd505f5f040efa2b77db213eb93fc9cede90253d325c
7
- data.tar.gz: 3539918d7bf62a8999ce433d3f4dc8ab2e234fcd3fb325c031d45723e0e702e329838293c3d33965a25d61dd4e35ebc61a0b9db5b981b6d7c9d67b50a34a6006
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
@@ -16,7 +16,8 @@ module Low
16
16
  @content_types = content_types.transform_keys(&:to_s)
17
17
  @cache_control = cache_control
18
18
 
19
- observers(Events::FileEvent) << FileResponse
19
+ # A second file server, like one for a framework's own files, shares the one FileResponse rather than adding another.
20
+ observers(Events::FileEvent) << FileResponse unless responding?
20
21
  end
21
22
 
22
23
  def extension(file_path:)
@@ -48,5 +49,11 @@ module Low
48
49
 
49
50
  Events::FileEvent.take(file:, request: event.request)
50
51
  end
52
+
53
+ private
54
+
55
+ def responding?
56
+ Observers::Keys[Events::FileEvent].observers.any? { |observer| observer.object == FileResponse }
57
+ end
51
58
  end
52
59
  end
data/lib/version.rb CHANGED
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Low
4
4
  module Loop
5
- VERSION = '0.8.10'
5
+ VERSION = '0.8.12'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lowloop
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.10
4
+ version: 0.8.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - maedi
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2026-11-23 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: async
@@ -162,7 +162,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
162
162
  - !ruby/object:Gem::Version
163
163
  version: '0'
164
164
  requirements: []
165
- rubygems_version: 3.6.2
165
+ rubygems_version: 4.0.20
166
166
  specification_version: 4
167
167
  summary: An event-driven event loop
168
168
  test_files: []