kino 0.7.1-aarch64-linux → 0.8.0-aarch64-linux

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.
data/sig/kino.rbs CHANGED
@@ -1,7 +1,6 @@
1
- # Public interfaces only. Internals (Kino::Worker, Kino::RactorSupervisor,
2
- # Kino::Input, Kino::NullInput, Kino::ErrorsStream, Kino::Stream,
3
- # Kino::Native) are deliberately unsigned: they are implementation detail
4
- # and may change without notice.
1
+ # Public interfaces only. Internals, everything marked @private and the
2
+ # extension's Kino::Native, are deliberately unsigned: they are
3
+ # implementation detail and may change without notice.
5
4
  module Kino
6
5
  VERSION: String
7
6
 
@@ -17,12 +16,19 @@ module Kino
17
16
  class UnshareableAppError < Error
18
17
  end
19
18
 
19
+ # Raised by a streaming body's write once its client has gone.
20
+ class ClientGone < IOError
21
+ end
22
+
20
23
  # High-resolution sleep on the OS clock with the GVL released.
21
24
  def self.sleep: (Numeric seconds) -> nil
22
25
 
23
26
  # CPUs this process may use (affinity mask and cgroup quota); never below 1.
24
27
  def self.available_parallelism: () -> Integer
25
28
 
29
+ # RUBY_MAX_CPU as Ruby reads it: 8 when unset or not an integer.
30
+ def self.ruby_max_cpu: () -> Integer
31
+
26
32
  class Server
27
33
  attr_reader port: Integer?
28
34
  attr_reader control_port: Integer?
@@ -49,17 +55,19 @@ module Kino
49
55
  # Graceful shutdown: drain to the deadline, then abort stragglers.
50
56
  def shutdown: (?timeout: Numeric?) -> nil
51
57
 
52
- def wait: () -> untyped
58
+ # Block until a shutdown has ended; raises its error if it failed.
59
+ def wait: () -> void
53
60
 
54
61
  # Live snapshot: config echo plus native counters (queued, in_flight,
55
- # served, rejected, timeouts, respawns, lane_depths when lanes are on).
62
+ # served, rejected, timeouts, respawns, ...), in the order /stats lists
63
+ # them; :responses_cut and :websockets cover the whole process.
56
64
  def stats: () -> stats_hash
57
65
 
58
66
  # Production entry point: build the server and #run it.
59
- def self.run: (rack_app app, **untyped opts) -> Server
67
+ def self.run: (rack_app app, ?credits: bool, ?on_ready: (^() -> void)?, **untyped opts) -> Server
60
68
 
61
69
  # Serve until shut down: start, banner, signal traps, block until done.
62
- def run: () -> self
70
+ def run: (?credits: bool, ?on_ready: (^() -> void)?) -> self
63
71
 
64
72
  # INT/TERM drain gracefully (second signal force-exits); USR1 prints stats.
65
73
  def self.trap_signals: (Server server) -> void
@@ -120,16 +128,25 @@ module Kino
120
128
  def max_connections: (int count) -> untyped
121
129
  def max_body_size: (int? bytes) -> untyped
122
130
  def batch: (int count) -> untyped
131
+ # Per-worker lanes (default: on with a worker_loop, else off); native WebSockets and wake
132
+ # hooks need them.
123
133
  def lanes: (boolish enabled) -> untyped
134
+ # Largest message a client may send (default 1 MiB); past it, 1009.
135
+ def websocket_max_message: (int bytes) -> untyped
136
+ # Most native sockets open at once (default nil: no cap of its own).
137
+ def websocket_max: (int? count) -> untyped
138
+ # Seconds of silence before a ping (default 30); nil or 0: no pings.
139
+ def websocket_ping_interval: (Numeric? seconds) -> untyped
124
140
  def log_requests: (boolish enabled) -> untyped
125
141
  def on_error: (?^(Exception, Hash[String, untyped]) -> void handler) ?{ (Exception, Hash[String, untyped]) -> void } -> untyped
126
142
  def after_boot: (?^() -> void handler) ?{ () -> void } -> untyped
127
143
  def after_worker_boot: (?^(Integer) -> void handler) ?{ (Integer) -> void } -> untyped
128
144
  def after_request_complete: (?^(Hash[String, untyped], Integer) -> void handler) ?{ (Hash[String, untyped], Integer) -> void } -> untyped
129
145
  def on_worker_exit: (?^(Integer, Exception?) -> void handler) ?{ (Integer, Exception?) -> void } -> untyped
146
+ def worker_loop: (?^(Worker::Loop) -> void handler) ?{ (Worker::Loop) -> void } -> untyped
130
147
  def shutdown_timeout: (Numeric seconds) -> untyped
131
148
  def io_shards: (?boolish enabled) -> untyped
132
- def io_threads: (int? count) -> untyped
149
+ def io_threads: (int count) -> untyped
133
150
  def tokio_threads: (int count) -> untyped
134
151
  def tls: (cert: String, key: String) -> untyped
135
152
  def http2: (?boolish enabled) -> untyped
@@ -143,6 +160,72 @@ module Kino
143
160
  end
144
161
  end
145
162
 
163
+ # A handle to a native WebSocket, handed to the callbacks of the handler an app sets as
164
+ # env["rack.upgrade"]: frozen, shareable, and usable from any thread or Ractor.
165
+ class WebSocket
166
+ attr_reader id: Integer
167
+
168
+ # The socket with this id; nil once it is gone.
169
+ def self.[]: (Integer id) -> WebSocket?
170
+
171
+ def ==: (untyped other) -> bool
172
+
173
+ def eql?: (untyped other) -> bool
174
+
175
+ def hash: () -> Integer
176
+
177
+ # One text frame.
178
+ def write: (String data) -> bool
179
+
180
+ # One binary frame.
181
+ def write_binary: (String data) -> bool
182
+
183
+ # Bytes that already form complete frames.
184
+ def write_raw: (String frames) -> bool
185
+
186
+ # A close frame after what is queued (5 s to answer); the first close stands, on_close
187
+ # follows. False on a full queue; ArgumentError for a code no endpoint may send.
188
+ def close: (?Integer code) -> bool
189
+
190
+ # Drop the connection now; on_close follows.
191
+ def abort: () -> bool
192
+
193
+ # Data frames queued and not yet written; 0 once the socket is gone.
194
+ def pending: () -> Integer
195
+
196
+ # Receive `topic`'s publishes as `prefix + body + suffix` frames; a full queue drops the
197
+ # socket (:close) or skips the message (:skip). False once gone.
198
+ def subscribe: (String topic, ?prefix: String, ?suffix: String, ?when_full: :close | :skip) -> bool
199
+
200
+ # End every subscription to `topic`, or those made with `prefix`; false if none.
201
+ def unsubscribe: (String topic, ?prefix: String?) -> bool
202
+
203
+ # Queue `body` for `topic`'s subscribers from any Ractor, as text (UTF-8) or binary; false
204
+ # only when the fan-out queue is full.
205
+ def self.publish: (String topic, String body, ?binary: boolish) -> bool
206
+ end
207
+
208
+ # The worker's wake hook: work on the worker's own thread (::on_wake). Needs lanes.
209
+ class Worker
210
+ # Register (or replace) this worker thread's hook; ArgumentError off a worker thread.
211
+ def self.on_wake: () { () -> void } -> Waker
212
+
213
+ # Wakes one worker, from any thread or Ractor (frozen, shareable).
214
+ class Waker
215
+ # The hook runs soon; wakes before it coalesce. False once the worker has exited or is
216
+ # retiring, or without lanes.
217
+ def wake: () -> bool
218
+ end
219
+
220
+ # What a worker_loop gets: Kino's loop, for the app's fiber scheduler to run.
221
+ class Loop
222
+ # Serve the worker's requests as jobs the block starts, at most `concurrency` at a time;
223
+ # each socket's events, and the wakes, run in order on jobs of their own. Returns once the
224
+ # worker is drained. An inline connection runs on its own job, its requests counting too.
225
+ def serve: (concurrency: Integer) { (^() -> void job) -> void } -> nil
226
+ end
227
+ end
228
+
146
229
  # The `kino` executable plus startup presentation shared with Server.run.
147
230
  module CLI
148
231
  MOTD: String
@@ -163,7 +246,7 @@ module Kino
163
246
 
164
247
  def self.red: (String text, ?io: IO) -> String
165
248
 
166
- # The banner with a vertical grayscale gradient.
249
+ # The banner with its three-tone shading.
167
250
  def self.motd: (?color: bool) -> String
168
251
 
169
252
  # One-line stats dump (the SIGUSR1 handler's output).
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kino
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.8.0
5
5
  platform: aarch64-linux
6
6
  authors:
7
7
  - Yaroslav Markin
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-09-24 00:00:00.000000000 Z
11
+ date: 2026-11-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: logger
@@ -167,13 +167,20 @@ files:
167
167
  - doc/README.md
168
168
  - doc/architecture.md
169
169
  - doc/benchmarks.md
170
+ - doc/configuration.md
171
+ - doc/operations.md
170
172
  - doc/rails-on-ractors.md
173
+ - doc/streaming.md
174
+ - doc/websockets.md
171
175
  - doc/why-kino.md
176
+ - doc/worker-loop.md
172
177
  - exe/kino
178
+ - ext/kino/clippy.toml
173
179
  - lib/kino.rb
174
180
  - lib/kino/check.rb
175
181
  - lib/kino/cli.rb
176
182
  - lib/kino/configuration.rb
183
+ - lib/kino/crash_backoff.rb
177
184
  - lib/kino/errors_stream.rb
178
185
  - lib/kino/hook_fire.rb
179
186
  - lib/kino/input.rb
@@ -182,17 +189,22 @@ files:
182
189
  - lib/kino/logger.rb
183
190
  - lib/kino/monitor.rb
184
191
  - lib/kino/null_input.rb
192
+ - lib/kino/pool.rb
185
193
  - lib/kino/pool_scaler.rb
186
194
  - lib/kino/quarantine_monitor.rb
187
195
  - lib/kino/ractor_supervisor.rb
188
196
  - lib/kino/server.rb
189
197
  - lib/kino/slot_bank.rb
190
198
  - lib/kino/stream.rb
199
+ - lib/kino/teardown.rb
191
200
  - lib/kino/templates/kino.rb.tt
192
201
  - lib/kino/threaded_pool.rb
193
202
  - lib/kino/version.rb
203
+ - lib/kino/web_socket.rb
194
204
  - lib/kino/worker.rb
205
+ - lib/kino/worker/loop.rb
195
206
  - lib/kino/worker_hooks.rb
207
+ - lib/kino/worker_row.rb
196
208
  - lib/rackup/handler/kino.rb
197
209
  - sig/kino.rbs
198
210
  homepage: https://github.com/yaroslav/kino