kino 0.1.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 +7 -0
- data/.yardopts +14 -0
- data/CHANGELOG.md +54 -0
- data/Cargo.lock +993 -0
- data/Cargo.toml +15 -0
- data/LICENSE.txt +21 -0
- data/README.md +384 -0
- data/doc/README.md +6 -0
- data/doc/architecture.md +161 -0
- data/doc/benchmarks.md +321 -0
- data/doc/rails-on-ractors.md +50 -0
- data/doc/why-kino.md +91 -0
- data/exe/kino +26 -0
- data/ext/kino/Cargo.toml +49 -0
- data/ext/kino/build.rs +5 -0
- data/ext/kino/extconf.rb +6 -0
- data/ext/kino/src/env_strings.rs +318 -0
- data/ext/kino/src/gvl.rs +103 -0
- data/ext/kino/src/lib.rs +90 -0
- data/ext/kino/src/logsink.rs +155 -0
- data/ext/kino/src/queue.rs +207 -0
- data/ext/kino/src/registry.rs +268 -0
- data/ext/kino/src/request.rs +432 -0
- data/ext/kino/src/response.rs +214 -0
- data/ext/kino/src/server.rs +621 -0
- data/ext/kino/src/style.rs +87 -0
- data/ext/kino/src/test_support.rs +82 -0
- data/ext/kino/src/timer.rs +57 -0
- data/ext/kino/src/tls.rs +96 -0
- data/lib/kino/check.rb +199 -0
- data/lib/kino/cli.rb +254 -0
- data/lib/kino/configuration.rb +190 -0
- data/lib/kino/errors_stream.rb +25 -0
- data/lib/kino/input.rb +77 -0
- data/lib/kino/logger.rb +56 -0
- data/lib/kino/null_input.rb +37 -0
- data/lib/kino/ractor_supervisor.rb +103 -0
- data/lib/kino/server.rb +271 -0
- data/lib/kino/stream.rb +61 -0
- data/lib/kino/templates/kino.rb.tt +141 -0
- data/lib/kino/version.rb +6 -0
- data/lib/kino/worker.rb +124 -0
- data/lib/kino.rb +53 -0
- data/sig/kino.rbs +178 -0
- metadata +219 -0
data/sig/kino.rbs
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
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.
|
|
5
|
+
module Kino
|
|
6
|
+
VERSION: String
|
|
7
|
+
|
|
8
|
+
# Any Rack 3 application: responds to #call(env) with [status, headers, body].
|
|
9
|
+
type rack_app = untyped
|
|
10
|
+
|
|
11
|
+
type stats_hash = Hash[Symbol, untyped]
|
|
12
|
+
|
|
13
|
+
class Error < StandardError
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# Raised when mode: :ractor is forced but the app is not Ractor-shareable.
|
|
17
|
+
class UnshareableAppError < Error
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# High-resolution sleep on the OS clock with the GVL released.
|
|
21
|
+
def self.sleep: (Numeric seconds) -> nil
|
|
22
|
+
|
|
23
|
+
class Server
|
|
24
|
+
attr_reader port: Integer?
|
|
25
|
+
attr_reader mode: Symbol
|
|
26
|
+
attr_reader bind: String
|
|
27
|
+
|
|
28
|
+
def tls?: () -> bool
|
|
29
|
+
|
|
30
|
+
# Settings precedence: explicit kwargs > config_file DSL > defaults.
|
|
31
|
+
def initialize: (rack_app app, ?config_file: String?, **untyped options) -> void
|
|
32
|
+
|
|
33
|
+
def start: () -> self
|
|
34
|
+
|
|
35
|
+
# Graceful shutdown: drain to the deadline, then abort stragglers.
|
|
36
|
+
def shutdown: (?timeout: Numeric?) -> nil
|
|
37
|
+
|
|
38
|
+
def wait: () -> untyped
|
|
39
|
+
|
|
40
|
+
# Live snapshot: config echo plus native counters (queued, in_flight,
|
|
41
|
+
# served, rejected, timeouts, respawns, lane_depths when lanes are on).
|
|
42
|
+
def stats: () -> stats_hash
|
|
43
|
+
|
|
44
|
+
# Production entry point: start, banner, signal traps, block until done.
|
|
45
|
+
def self.run: (rack_app app, **untyped opts) -> Server
|
|
46
|
+
|
|
47
|
+
# INT/TERM drain gracefully (second signal force-exits); USR1 prints stats.
|
|
48
|
+
def self.trap_signals: (Server server) -> void
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
class Configuration
|
|
52
|
+
DEFAULTS: Hash[Symbol, untyped]
|
|
53
|
+
SETTINGS: Array[Symbol]
|
|
54
|
+
SAMPLE_TEMPLATE: String
|
|
55
|
+
|
|
56
|
+
# The fully commented sample config (see `kino --init`).
|
|
57
|
+
def self.sample: () -> String
|
|
58
|
+
|
|
59
|
+
# Write the sample config to path; raises Kino::Error if it exists
|
|
60
|
+
# unless force. Returns the path.
|
|
61
|
+
def self.write_sample: (String path, ?force: bool) -> String
|
|
62
|
+
|
|
63
|
+
def initialize: () -> void
|
|
64
|
+
|
|
65
|
+
def []: (Symbol key) -> untyped
|
|
66
|
+
|
|
67
|
+
# Raises ArgumentError for keys outside DEFAULTS.
|
|
68
|
+
def set: (Symbol key, untyped value) -> untyped
|
|
69
|
+
|
|
70
|
+
def set?: (Symbol key) -> bool
|
|
71
|
+
|
|
72
|
+
# Evaluate a Puma-style Ruby DSL config file into this configuration.
|
|
73
|
+
def load_file: (String path) -> self
|
|
74
|
+
|
|
75
|
+
def merge!: (Hash[Symbol, untyped] options) -> self
|
|
76
|
+
|
|
77
|
+
def to_h: () -> Hash[Symbol, untyped]
|
|
78
|
+
|
|
79
|
+
# to_h minus the CLI-only keys (:rackup, :environment); what Server.new
|
|
80
|
+
# accepts.
|
|
81
|
+
def server_options: () -> Hash[Symbol, untyped]
|
|
82
|
+
|
|
83
|
+
# The config-file DSL: one method per directive.
|
|
84
|
+
class DSL
|
|
85
|
+
def initialize: (Configuration config) -> void
|
|
86
|
+
|
|
87
|
+
def bind: (String host) -> untyped
|
|
88
|
+
def port: (int port) -> untyped
|
|
89
|
+
def workers: (int count) -> untyped
|
|
90
|
+
def threads: (int count) -> untyped
|
|
91
|
+
def mode: (Symbol | String mode) -> untyped
|
|
92
|
+
def queue_depth: (int depth) -> untyped
|
|
93
|
+
def queue_timeout: (Numeric seconds) -> untyped
|
|
94
|
+
def request_timeout: (Numeric? seconds) -> untyped
|
|
95
|
+
def batch: (int count) -> untyped
|
|
96
|
+
def lanes: (boolish enabled) -> untyped
|
|
97
|
+
def log_requests: (boolish enabled) -> untyped
|
|
98
|
+
def shutdown_timeout: (Numeric seconds) -> untyped
|
|
99
|
+
def tokio_threads: (int count) -> untyped
|
|
100
|
+
def tls: (cert: String, key: String) -> untyped
|
|
101
|
+
def environment: (String | Symbol env) -> untyped
|
|
102
|
+
def pidfile: (String path) -> untyped
|
|
103
|
+
def rackup: (String path) -> untyped
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
# The `kino` executable plus startup presentation shared with Server.run.
|
|
108
|
+
module CLI
|
|
109
|
+
MOTD: String
|
|
110
|
+
|
|
111
|
+
# Parse argv, then init/check/serve. Returns the process exit status
|
|
112
|
+
# (-v and -h print and exit in place per optparse convention).
|
|
113
|
+
def self.start: (Array[String] argv) -> Integer
|
|
114
|
+
|
|
115
|
+
# True when output to io may use ANSI styling.
|
|
116
|
+
def self.color?: (?IO io) -> bool
|
|
117
|
+
|
|
118
|
+
# Wrap text in an SGR code, resetting at the end; plain on non-color io.
|
|
119
|
+
def self.paint: (String code, String text, ?io: IO) -> String
|
|
120
|
+
|
|
121
|
+
def self.dim: (String text, ?io: IO) -> String
|
|
122
|
+
|
|
123
|
+
def self.bold: (String text, ?io: IO) -> String
|
|
124
|
+
|
|
125
|
+
def self.red: (String text, ?io: IO) -> String
|
|
126
|
+
|
|
127
|
+
# The banner with a vertical grayscale gradient.
|
|
128
|
+
def self.motd: (?color: bool) -> String
|
|
129
|
+
|
|
130
|
+
# One-line stats dump (the SIGUSR1 handler's output).
|
|
131
|
+
def self.stats_line: (stats_hash stats) -> String
|
|
132
|
+
|
|
133
|
+
# The two banner halves around Server#start.
|
|
134
|
+
def self.opening_credits: () -> void
|
|
135
|
+
def self.action!: (Server server) -> void
|
|
136
|
+
|
|
137
|
+
# Print a bold "Fin." when the process ends (idempotent).
|
|
138
|
+
def self.fin_at_exit: () -> void
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
# The shareability doctor behind `kino --check`.
|
|
142
|
+
module Check
|
|
143
|
+
MAX_FINDINGS: Integer
|
|
144
|
+
MAX_NODES: Integer
|
|
145
|
+
|
|
146
|
+
class Finding < ::Struct[untyped]
|
|
147
|
+
attr_accessor path: String
|
|
148
|
+
attr_accessor message: String
|
|
149
|
+
|
|
150
|
+
def to_s: () -> String
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
def self.report: (rack_app app) -> { shareable: bool, findings: Array[Finding] }
|
|
154
|
+
|
|
155
|
+
# Pretty-printed report; true when the app is ractor-ready.
|
|
156
|
+
def self.print_report: (rack_app app, ?io: IO) -> bool
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
# A ::Logger writing through the native async sink.
|
|
160
|
+
class Logger < ::Logger
|
|
161
|
+
# path: a file (created/appended) or nil for stdout.
|
|
162
|
+
def initialize: (?String? path, **untyped options) -> void
|
|
163
|
+
|
|
164
|
+
# The raw IO-like device: frozen and Ractor-shareable, one device can
|
|
165
|
+
# serve every worker.
|
|
166
|
+
class Device
|
|
167
|
+
def initialize: (?String? path) -> void
|
|
168
|
+
|
|
169
|
+
def write: (untyped message) -> void
|
|
170
|
+
|
|
171
|
+
alias << write
|
|
172
|
+
|
|
173
|
+
def close: () -> void
|
|
174
|
+
|
|
175
|
+
def reopen: (*untyped) -> self
|
|
176
|
+
end
|
|
177
|
+
end
|
|
178
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: kino
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Yaroslav Markin
|
|
8
|
+
bindir: exe
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies:
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: logger
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
- - ">="
|
|
17
|
+
- !ruby/object:Gem::Version
|
|
18
|
+
version: '1.6'
|
|
19
|
+
type: :runtime
|
|
20
|
+
prerelease: false
|
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
22
|
+
requirements:
|
|
23
|
+
- - ">="
|
|
24
|
+
- !ruby/object:Gem::Version
|
|
25
|
+
version: '1.6'
|
|
26
|
+
- !ruby/object:Gem::Dependency
|
|
27
|
+
name: rack
|
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
|
29
|
+
requirements:
|
|
30
|
+
- - ">="
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '3.1'
|
|
33
|
+
type: :runtime
|
|
34
|
+
prerelease: false
|
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
36
|
+
requirements:
|
|
37
|
+
- - ">="
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
version: '3.1'
|
|
40
|
+
- !ruby/object:Gem::Dependency
|
|
41
|
+
name: rb_sys
|
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
|
43
|
+
requirements:
|
|
44
|
+
- - "~>"
|
|
45
|
+
- !ruby/object:Gem::Version
|
|
46
|
+
version: 0.9.128
|
|
47
|
+
type: :runtime
|
|
48
|
+
prerelease: false
|
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
50
|
+
requirements:
|
|
51
|
+
- - "~>"
|
|
52
|
+
- !ruby/object:Gem::Version
|
|
53
|
+
version: 0.9.128
|
|
54
|
+
- !ruby/object:Gem::Dependency
|
|
55
|
+
name: rake
|
|
56
|
+
requirement: !ruby/object:Gem::Requirement
|
|
57
|
+
requirements:
|
|
58
|
+
- - "~>"
|
|
59
|
+
- !ruby/object:Gem::Version
|
|
60
|
+
version: '13.0'
|
|
61
|
+
type: :development
|
|
62
|
+
prerelease: false
|
|
63
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
64
|
+
requirements:
|
|
65
|
+
- - "~>"
|
|
66
|
+
- !ruby/object:Gem::Version
|
|
67
|
+
version: '13.0'
|
|
68
|
+
- !ruby/object:Gem::Dependency
|
|
69
|
+
name: rake-compiler
|
|
70
|
+
requirement: !ruby/object:Gem::Requirement
|
|
71
|
+
requirements:
|
|
72
|
+
- - ">="
|
|
73
|
+
- !ruby/object:Gem::Version
|
|
74
|
+
version: '0'
|
|
75
|
+
type: :development
|
|
76
|
+
prerelease: false
|
|
77
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
78
|
+
requirements:
|
|
79
|
+
- - ">="
|
|
80
|
+
- !ruby/object:Gem::Version
|
|
81
|
+
version: '0'
|
|
82
|
+
- !ruby/object:Gem::Dependency
|
|
83
|
+
name: rbs
|
|
84
|
+
requirement: !ruby/object:Gem::Requirement
|
|
85
|
+
requirements:
|
|
86
|
+
- - "~>"
|
|
87
|
+
- !ruby/object:Gem::Version
|
|
88
|
+
version: '4.0'
|
|
89
|
+
type: :development
|
|
90
|
+
prerelease: false
|
|
91
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
92
|
+
requirements:
|
|
93
|
+
- - "~>"
|
|
94
|
+
- !ruby/object:Gem::Version
|
|
95
|
+
version: '4.0'
|
|
96
|
+
- !ruby/object:Gem::Dependency
|
|
97
|
+
name: rspec
|
|
98
|
+
requirement: !ruby/object:Gem::Requirement
|
|
99
|
+
requirements:
|
|
100
|
+
- - "~>"
|
|
101
|
+
- !ruby/object:Gem::Version
|
|
102
|
+
version: '3.0'
|
|
103
|
+
type: :development
|
|
104
|
+
prerelease: false
|
|
105
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
106
|
+
requirements:
|
|
107
|
+
- - "~>"
|
|
108
|
+
- !ruby/object:Gem::Version
|
|
109
|
+
version: '3.0'
|
|
110
|
+
- !ruby/object:Gem::Dependency
|
|
111
|
+
name: standard
|
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
|
113
|
+
requirements:
|
|
114
|
+
- - "~>"
|
|
115
|
+
- !ruby/object:Gem::Version
|
|
116
|
+
version: '1.50'
|
|
117
|
+
type: :development
|
|
118
|
+
prerelease: false
|
|
119
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
120
|
+
requirements:
|
|
121
|
+
- - "~>"
|
|
122
|
+
- !ruby/object:Gem::Version
|
|
123
|
+
version: '1.50'
|
|
124
|
+
- !ruby/object:Gem::Dependency
|
|
125
|
+
name: yard
|
|
126
|
+
requirement: !ruby/object:Gem::Requirement
|
|
127
|
+
requirements:
|
|
128
|
+
- - "~>"
|
|
129
|
+
- !ruby/object:Gem::Version
|
|
130
|
+
version: '0.9'
|
|
131
|
+
type: :development
|
|
132
|
+
prerelease: false
|
|
133
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
134
|
+
requirements:
|
|
135
|
+
- - "~>"
|
|
136
|
+
- !ruby/object:Gem::Version
|
|
137
|
+
version: '0.9'
|
|
138
|
+
description: 'A high-performance Ractor web server for Ruby 4.0+: Rack 3-based, with
|
|
139
|
+
a Rust tokio/hyper front-end and Ractor-parallel Ruby workers and threaded fallback
|
|
140
|
+
mode.'
|
|
141
|
+
email:
|
|
142
|
+
- yaroslav@markin.net
|
|
143
|
+
executables:
|
|
144
|
+
- kino
|
|
145
|
+
extensions:
|
|
146
|
+
- ext/kino/extconf.rb
|
|
147
|
+
extra_rdoc_files: []
|
|
148
|
+
files:
|
|
149
|
+
- ".yardopts"
|
|
150
|
+
- CHANGELOG.md
|
|
151
|
+
- Cargo.lock
|
|
152
|
+
- Cargo.toml
|
|
153
|
+
- LICENSE.txt
|
|
154
|
+
- README.md
|
|
155
|
+
- doc/README.md
|
|
156
|
+
- doc/architecture.md
|
|
157
|
+
- doc/benchmarks.md
|
|
158
|
+
- doc/rails-on-ractors.md
|
|
159
|
+
- doc/why-kino.md
|
|
160
|
+
- exe/kino
|
|
161
|
+
- ext/kino/Cargo.toml
|
|
162
|
+
- ext/kino/build.rs
|
|
163
|
+
- ext/kino/extconf.rb
|
|
164
|
+
- ext/kino/src/env_strings.rs
|
|
165
|
+
- ext/kino/src/gvl.rs
|
|
166
|
+
- ext/kino/src/lib.rs
|
|
167
|
+
- ext/kino/src/logsink.rs
|
|
168
|
+
- ext/kino/src/queue.rs
|
|
169
|
+
- ext/kino/src/registry.rs
|
|
170
|
+
- ext/kino/src/request.rs
|
|
171
|
+
- ext/kino/src/response.rs
|
|
172
|
+
- ext/kino/src/server.rs
|
|
173
|
+
- ext/kino/src/style.rs
|
|
174
|
+
- ext/kino/src/test_support.rs
|
|
175
|
+
- ext/kino/src/timer.rs
|
|
176
|
+
- ext/kino/src/tls.rs
|
|
177
|
+
- lib/kino.rb
|
|
178
|
+
- lib/kino/check.rb
|
|
179
|
+
- lib/kino/cli.rb
|
|
180
|
+
- lib/kino/configuration.rb
|
|
181
|
+
- lib/kino/errors_stream.rb
|
|
182
|
+
- lib/kino/input.rb
|
|
183
|
+
- lib/kino/logger.rb
|
|
184
|
+
- lib/kino/null_input.rb
|
|
185
|
+
- lib/kino/ractor_supervisor.rb
|
|
186
|
+
- lib/kino/server.rb
|
|
187
|
+
- lib/kino/stream.rb
|
|
188
|
+
- lib/kino/templates/kino.rb.tt
|
|
189
|
+
- lib/kino/version.rb
|
|
190
|
+
- lib/kino/worker.rb
|
|
191
|
+
- sig/kino.rbs
|
|
192
|
+
homepage: https://github.com/yaroslav/kino
|
|
193
|
+
licenses:
|
|
194
|
+
- MIT
|
|
195
|
+
metadata:
|
|
196
|
+
allowed_push_host: https://rubygems.org
|
|
197
|
+
homepage_uri: https://github.com/yaroslav/kino
|
|
198
|
+
source_code_uri: https://github.com/yaroslav/kino
|
|
199
|
+
changelog_uri: https://github.com/yaroslav/kino/blob/main/CHANGELOG.md
|
|
200
|
+
documentation_uri: https://rubydoc.info/gems/kino
|
|
201
|
+
rubygems_mfa_required: 'true'
|
|
202
|
+
rdoc_options: []
|
|
203
|
+
require_paths:
|
|
204
|
+
- lib
|
|
205
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
206
|
+
requirements:
|
|
207
|
+
- - ">="
|
|
208
|
+
- !ruby/object:Gem::Version
|
|
209
|
+
version: '4.0'
|
|
210
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
211
|
+
requirements:
|
|
212
|
+
- - ">="
|
|
213
|
+
- !ruby/object:Gem::Version
|
|
214
|
+
version: '0'
|
|
215
|
+
requirements: []
|
|
216
|
+
rubygems_version: 4.0.10
|
|
217
|
+
specification_version: 4
|
|
218
|
+
summary: High-performance Ractor web server for Ruby.
|
|
219
|
+
test_files: []
|