raptor 0.25.0 → 0.27.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 +4 -4
- data/.buildkite/pipeline.yml +34 -8
- data/AGENTS.md +25 -0
- data/CHANGELOG.md +35 -25
- data/README.md +82 -67
- data/Rakefile +10 -3
- data/lib/rackup/handler/raptor.rb +19 -12
- data/lib/raptor/binder.rb +17 -5
- data/lib/raptor/cli.rb +32 -2
- data/lib/raptor/cluster.rb +62 -141
- data/lib/raptor/embedded.rb +225 -0
- data/lib/raptor/plugin.rb +1 -0
- data/lib/raptor/reactor.rb +21 -4
- data/lib/raptor/version.rb +1 -1
- data/lib/raptor/worker.rb +200 -0
- data/sig/generated/rackup/handler/raptor.rbs +8 -8
- data/sig/generated/raptor/cli.rbs +5 -0
- data/sig/generated/raptor/cluster.rbs +22 -35
- data/sig/generated/raptor/embedded.rbs +93 -0
- data/sig/generated/raptor/plugin.rbs +1 -0
- data/sig/generated/raptor/worker.rbs +77 -0
- metadata +6 -1
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# Generated from lib/raptor/embedded.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module Raptor
|
|
4
|
+
# Serves an existing Rack application in the caller's process without
|
|
5
|
+
# installing signal handlers or changing process-wide configuration.
|
|
6
|
+
class Embedded
|
|
7
|
+
@worker: Worker?
|
|
8
|
+
|
|
9
|
+
@binder: Binder?
|
|
10
|
+
|
|
11
|
+
@stopped: bool
|
|
12
|
+
|
|
13
|
+
@started: bool
|
|
14
|
+
|
|
15
|
+
@lifecycle_available: AtomicConditionVariable
|
|
16
|
+
|
|
17
|
+
@lifecycle_owner: Atom
|
|
18
|
+
|
|
19
|
+
@log: bool
|
|
20
|
+
|
|
21
|
+
@binds: Array[String]
|
|
22
|
+
|
|
23
|
+
@options: Hash[Symbol, untyped]
|
|
24
|
+
|
|
25
|
+
@app: untyped
|
|
26
|
+
|
|
27
|
+
attr_reader port: Integer
|
|
28
|
+
|
|
29
|
+
attr_reader addresses: Array[String]
|
|
30
|
+
|
|
31
|
+
# Creates an in-process server. A port of zero selects an available port.
|
|
32
|
+
# Thread and protocol options follow the regular server configuration.
|
|
33
|
+
# Set log to report startup information.
|
|
34
|
+
#
|
|
35
|
+
# @rbs (untyped app, ?host: String, ?port: Integer, ?log: bool, **untyped options) -> void
|
|
36
|
+
def initialize: (untyped app, ?host: String, ?port: Integer, ?log: bool, **untyped options) -> void
|
|
37
|
+
|
|
38
|
+
# Starts serving and returns once the request-handling stack is ready.
|
|
39
|
+
# Startup errors are raised in the calling thread.
|
|
40
|
+
#
|
|
41
|
+
# @rbs () -> Embedded
|
|
42
|
+
def start: () -> Embedded
|
|
43
|
+
|
|
44
|
+
# Starts serving and waits until shutdown.
|
|
45
|
+
#
|
|
46
|
+
# @rbs () -> void
|
|
47
|
+
def run: () -> void
|
|
48
|
+
|
|
49
|
+
# Drains serving work while retaining the bound listeners for resume.
|
|
50
|
+
# Connections may queue, but requests are not served while paused.
|
|
51
|
+
# Existing keep-alive connections close. Repeated pauses have no effect.
|
|
52
|
+
#
|
|
53
|
+
# Pause before master forks and resume in the parent. Close the inherited
|
|
54
|
+
# instance before other worker boot hooks, and shut down when the plugin stops.
|
|
55
|
+
#
|
|
56
|
+
# @example From a plugin's start callback
|
|
57
|
+
# @server = Raptor::Embedded.new(app, port: 9293).start
|
|
58
|
+
# cluster.options[:before_fork] << proc { @server.pause }
|
|
59
|
+
# cluster.options[:after_fork] << proc { @server.resume }
|
|
60
|
+
# cluster.options[:before_worker_boot].unshift(proc { @server.shutdown })
|
|
61
|
+
#
|
|
62
|
+
# @rbs () -> Embedded
|
|
63
|
+
def pause: () -> Embedded
|
|
64
|
+
|
|
65
|
+
# Resumes serving on the retained listeners. Has no effect while running.
|
|
66
|
+
# Shutdown remains terminal. Startup failures release the listeners and propagate.
|
|
67
|
+
#
|
|
68
|
+
# @rbs () -> Embedded
|
|
69
|
+
def resume: () -> Embedded
|
|
70
|
+
|
|
71
|
+
# Drains requests and closes the server's sockets, threads, and Ractors.
|
|
72
|
+
# Calling shutdown more than once has no effect.
|
|
73
|
+
#
|
|
74
|
+
# @rbs () -> void
|
|
75
|
+
def shutdown: () -> void
|
|
76
|
+
|
|
77
|
+
# Waits across pauses until termination and propagates serving failures.
|
|
78
|
+
#
|
|
79
|
+
# @rbs () -> void
|
|
80
|
+
def join: () -> void
|
|
81
|
+
|
|
82
|
+
private
|
|
83
|
+
|
|
84
|
+
# @rbs () -> void
|
|
85
|
+
def start_worker: () -> void
|
|
86
|
+
|
|
87
|
+
# @rbs () -> void
|
|
88
|
+
def log_initialization: () -> void
|
|
89
|
+
|
|
90
|
+
# @rbs () { () -> untyped } -> untyped
|
|
91
|
+
def with_lifecycle: () { () -> untyped } -> untyped
|
|
92
|
+
end
|
|
93
|
+
end
|
|
@@ -28,6 +28,7 @@ module Raptor
|
|
|
28
28
|
|
|
29
29
|
# Starts in the master before workers fork. Override to open resources
|
|
30
30
|
# and append callbacks to the cluster's lifecycle hook arrays.
|
|
31
|
+
# See {Cluster#initialize} for hooks and {Embedded#pause} for fork-safe Rack listeners.
|
|
31
32
|
#
|
|
32
33
|
# @rbs (Cluster cluster) -> void
|
|
33
34
|
def start: (Cluster cluster) -> void
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# Generated from lib/raptor/worker.rb with RBS::Inline
|
|
2
|
+
|
|
3
|
+
module Raptor
|
|
4
|
+
# Runs the request-handling stack shared by forked and embedded servers.
|
|
5
|
+
class Worker
|
|
6
|
+
@server_thread: Thread?
|
|
7
|
+
|
|
8
|
+
@server: Server?
|
|
9
|
+
|
|
10
|
+
@reactor_thread: Thread?
|
|
11
|
+
|
|
12
|
+
@http2_ractor_pool: RactorPool?
|
|
13
|
+
|
|
14
|
+
@http1_ractor_pool: RactorPool?
|
|
15
|
+
|
|
16
|
+
@http2: Http2?
|
|
17
|
+
|
|
18
|
+
@http1: Http1?
|
|
19
|
+
|
|
20
|
+
@stopped: bool
|
|
21
|
+
|
|
22
|
+
@worker_index: Integer?
|
|
23
|
+
|
|
24
|
+
@access_log_io: IO?
|
|
25
|
+
|
|
26
|
+
@http2_ractors: Integer
|
|
27
|
+
|
|
28
|
+
@http1_ractors: Integer
|
|
29
|
+
|
|
30
|
+
@options: Hash[Symbol, untyped]
|
|
31
|
+
|
|
32
|
+
@port: Integer
|
|
33
|
+
|
|
34
|
+
@listeners: Array[TCPServer | UNIXServer | Binder::SslListener | Binder::H2cListener]
|
|
35
|
+
|
|
36
|
+
@app: untyped
|
|
37
|
+
|
|
38
|
+
attr_reader requests: Integer
|
|
39
|
+
|
|
40
|
+
attr_reader reactor: Reactor?
|
|
41
|
+
|
|
42
|
+
attr_reader thread_pool: AtomicThreadPool?
|
|
43
|
+
|
|
44
|
+
# Creates a serving stack using the supplied listeners and configuration.
|
|
45
|
+
#
|
|
46
|
+
# @rbs (untyped app, listeners: Array[TCPServer | UNIXServer | Binder::SslListener | Binder::H2cListener], port: Integer, options: Hash[Symbol, untyped], http1_ractors: Integer, http2_ractors: Integer, ?access_log_io: IO?, ?worker_index: Integer?) -> void
|
|
47
|
+
def initialize: (untyped app, listeners: Array[TCPServer | UNIXServer | Binder::SslListener | Binder::H2cListener], port: Integer, options: Hash[Symbol, untyped], http1_ractors: Integer, http2_ractors: Integer, ?access_log_io: IO?, ?worker_index: Integer?) -> void
|
|
48
|
+
|
|
49
|
+
# Starts the application pool, protocol parsers, reactor, and acceptor.
|
|
50
|
+
#
|
|
51
|
+
# @rbs () -> void
|
|
52
|
+
def start: () -> void
|
|
53
|
+
|
|
54
|
+
# Returns whether both serving threads are still running.
|
|
55
|
+
#
|
|
56
|
+
# @rbs () -> bool
|
|
57
|
+
def running?: () -> bool
|
|
58
|
+
|
|
59
|
+
# Waits until serving stops, propagating background thread failures.
|
|
60
|
+
#
|
|
61
|
+
# @rbs () -> void
|
|
62
|
+
def join: () -> void
|
|
63
|
+
|
|
64
|
+
# Drains requests and releases the serving threads and parser Ractors.
|
|
65
|
+
# A seed keeps its listeners open for the cluster to manage.
|
|
66
|
+
#
|
|
67
|
+
# @rbs (?close_listeners: bool) -> void
|
|
68
|
+
def shutdown: (?close_listeners: bool) -> void
|
|
69
|
+
|
|
70
|
+
private
|
|
71
|
+
|
|
72
|
+
# Waits for app work to finish within the configured drain timeout.
|
|
73
|
+
#
|
|
74
|
+
# @rbs () -> void
|
|
75
|
+
def drain_thread_pool: () -> void
|
|
76
|
+
end
|
|
77
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: raptor
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.27.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Joshua Young
|
|
@@ -134,6 +134,7 @@ files:
|
|
|
134
134
|
- ".buildkite/pipeline.yml"
|
|
135
135
|
- ".dockerignore"
|
|
136
136
|
- ".mise.toml"
|
|
137
|
+
- AGENTS.md
|
|
137
138
|
- Brewfile
|
|
138
139
|
- CHANGELOG.md
|
|
139
140
|
- CODE_OF_CONDUCT.md
|
|
@@ -161,6 +162,7 @@ files:
|
|
|
161
162
|
- lib/raptor/cluster.rb
|
|
162
163
|
- lib/raptor/control_server.rb
|
|
163
164
|
- lib/raptor/detached_body.rb
|
|
165
|
+
- lib/raptor/embedded.rb
|
|
164
166
|
- lib/raptor/http.rb
|
|
165
167
|
- lib/raptor/http1.rb
|
|
166
168
|
- lib/raptor/http2.rb
|
|
@@ -173,6 +175,7 @@ files:
|
|
|
173
175
|
- lib/raptor/systemd.rb
|
|
174
176
|
- lib/raptor/thread_locals.rb
|
|
175
177
|
- lib/raptor/version.rb
|
|
178
|
+
- lib/raptor/worker.rb
|
|
176
179
|
- sig/generated/rackup/handler/raptor.rbs
|
|
177
180
|
- sig/generated/raptor.rbs
|
|
178
181
|
- sig/generated/raptor/binder.rbs
|
|
@@ -180,6 +183,7 @@ files:
|
|
|
180
183
|
- sig/generated/raptor/cluster.rbs
|
|
181
184
|
- sig/generated/raptor/control_server.rbs
|
|
182
185
|
- sig/generated/raptor/detached_body.rbs
|
|
186
|
+
- sig/generated/raptor/embedded.rbs
|
|
183
187
|
- sig/generated/raptor/http.rbs
|
|
184
188
|
- sig/generated/raptor/http1.rbs
|
|
185
189
|
- sig/generated/raptor/http2.rbs
|
|
@@ -192,6 +196,7 @@ files:
|
|
|
192
196
|
- sig/generated/raptor/systemd.rbs
|
|
193
197
|
- sig/generated/raptor/thread_locals.rbs
|
|
194
198
|
- sig/generated/raptor/version.rbs
|
|
199
|
+
- sig/generated/raptor/worker.rbs
|
|
195
200
|
homepage: https://github.com/joshuay03/raptor
|
|
196
201
|
licenses:
|
|
197
202
|
- MIT
|