lowloop 0.8.11 → 0.8.13

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: 5ffb1c5bb791c44bf3ca01a0fec6a356c671b63706682b41ab7c18233341e154
4
+ data.tar.gz: 7d37915fb7732da3e86f4396fc0b327c493ddae854fa4ccbbc621ccb3f31e64f
5
5
  SHA512:
6
- metadata.gz: 77ede7d33f4f405614ded0e87c481ba0ee6a495b88d3b8298982a1fcac58db2daed643dc39c516f34ec1d6d97cc05ff2752fb22c8c800d7c8a6a38890d83bcc1
7
- data.tar.gz: 24ecd76e384df5a0d575720799f606b4e3ea7e0cceaf641829e24c4af754b3f0ef0ebda2be809ceeb7e16fcb3ae9e05121037c9d3a9a969ce8624ff81bada135
6
+ metadata.gz: 535bcfe5f4c88a1e02336a65548c67951f2bba40a6fbb9dd00d92b8be98d29977ca297d6456a4013985e4b6524f2f1e6f6dba3106a0680049c38fbeb765517c4
7
+ data.tar.gz: 1b77236c066df2d84c0f6f562357ac1de332bfe24663779c984df9d76919abfbe5337919490c0db3dbcf4aff222979893da664f1faafd69f07c50aa266e35edc
@@ -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
@@ -22,6 +22,13 @@ module Low
22
22
  new(seconds: UNITS[unit] * count, at_hour:)
23
23
  end
24
24
 
25
+ # Nodes observe an interval like "Interval[every_minute: 1]" rather than this class so they're who observes it.
26
+ def self.observers(key = nil)
27
+ return super if key
28
+
29
+ Observers.of_keys { |each_key| each_key.is_a?(Interval) }
30
+ end
31
+
25
32
  # The interval is its own key, so its observers are the ones observing the same schedule.
26
33
  def initialize(seconds:, at_hour: nil)
27
34
  super(key: self, action: :tick)
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.13'
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.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - maedi
@@ -99,14 +99,14 @@ dependencies:
99
99
  requirements:
100
100
  - - ">="
101
101
  - !ruby/object:Gem::Version
102
- version: '0'
102
+ version: 0.8.5
103
103
  type: :runtime
104
104
  prerelease: false
105
105
  version_requirements: !ruby/object:Gem::Requirement
106
106
  requirements:
107
107
  - - ">="
108
108
  - !ruby/object:Gem::Version
109
- version: '0'
109
+ version: 0.8.5
110
110
  - !ruby/object:Gem::Dependency
111
111
  name: lowtype
112
112
  requirement: !ruby/object:Gem::Requirement