falcon 0.53.1 → 0.54.1
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
- checksums.yaml.gz.sig +0 -0
- data/lib/falcon/composite_server.rb +77 -0
- data/lib/falcon/service/server.rb +1 -1
- data/lib/falcon/version.rb +1 -1
- data/lib/falcon.rb +1 -0
- data/readme.md +8 -27
- data/releases.md +8 -0
- data.tar.gz.sig +0 -0
- metadata +2 -1
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz: '
|
|
3
|
+
metadata.gz: 2c3f4297ca318c67cd039cce9c7db0c6714751b0e476abdbc28b49882fbfe1a1
|
|
4
|
+
data.tar.gz: '02898c19485399ae53e9e85f741af7026ea70c3a28b9942fe6ab4f793cf780ca'
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 39d37d7b59904727e9f33e8d18a8dd76bd971689cc67803ab601c06d56b62c34d2598f94902feee787066b48d99da914f8d5e7d61864cf1e27cfd96e4ed1d72a
|
|
7
|
+
data.tar.gz: e83c1d9d0431df6a71820662605f75fbc5143397f7deee487096646925a210c183a980e4f6a88194abf2d819d51e8572a03ee3fe1bbc69b422eb459771170ef5
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Released under the MIT License.
|
|
4
|
+
# Copyright, 2025, by Samuel Williams.
|
|
5
|
+
|
|
6
|
+
require "async"
|
|
7
|
+
|
|
8
|
+
module Falcon
|
|
9
|
+
# A composite server that manages multiple {Server} instances.
|
|
10
|
+
#
|
|
11
|
+
# This class coordinates running multiple server instances concurrently, allowing you to:
|
|
12
|
+
# - Serve different applications on different endpoints.
|
|
13
|
+
# - Use different configurations per server.
|
|
14
|
+
# - Access statistics for each named server.
|
|
15
|
+
# - Control all servers as a single unit.
|
|
16
|
+
#
|
|
17
|
+
# @example Create and run several applications.
|
|
18
|
+
# require 'falcon/composite_server'
|
|
19
|
+
# require 'falcon/server'
|
|
20
|
+
#
|
|
21
|
+
# # Create individual servers
|
|
22
|
+
# servers = {
|
|
23
|
+
# "http" => Falcon::Server.new(app1, endpoint1),
|
|
24
|
+
# "https" => Falcon::Server.new(app2, endpoint2)
|
|
25
|
+
# }
|
|
26
|
+
#
|
|
27
|
+
# # Create the composite server
|
|
28
|
+
# composite = Falcon::CompositeServer.new(servers)
|
|
29
|
+
#
|
|
30
|
+
# # Run all servers
|
|
31
|
+
# composite.run
|
|
32
|
+
class CompositeServer
|
|
33
|
+
# Initialize a composite server with the given server instances.
|
|
34
|
+
#
|
|
35
|
+
# @parameter servers [Hash(String, Falcon::Server)] A hash mapping server names to server instances.
|
|
36
|
+
def initialize(servers)
|
|
37
|
+
@servers = servers
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# The individual server instances mapped by name.
|
|
41
|
+
# @attribute [Hash(String, Falcon::Server)]
|
|
42
|
+
attr :servers
|
|
43
|
+
|
|
44
|
+
# Run the composite server, starting all individual servers.
|
|
45
|
+
#
|
|
46
|
+
# This method should be called within an Async context. It will run all server instances concurrently.
|
|
47
|
+
#
|
|
48
|
+
# @returns [Async::Task] The task running the servers. Call `stop` on the returned task to stop all servers.
|
|
49
|
+
def run
|
|
50
|
+
Async do |task|
|
|
51
|
+
# Run each server - server.run creates its own Async block internally
|
|
52
|
+
@servers.each do |name, server|
|
|
53
|
+
server.run
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# Wait for all child tasks to complete
|
|
57
|
+
task.children.each(&:wait)
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# Generates a human-readable string representing statistics for all servers.
|
|
62
|
+
#
|
|
63
|
+
# @returns [String] A string representing the current statistics for each server.
|
|
64
|
+
def statistics_string
|
|
65
|
+
@servers.map do |name, server|
|
|
66
|
+
"#{name}: #{server.statistics_string}"
|
|
67
|
+
end.join(", ")
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
# Get detailed statistics for each server.
|
|
71
|
+
#
|
|
72
|
+
# @returns [Hash(String, String)] A hash mapping server names to their statistics strings.
|
|
73
|
+
def detailed_statistics
|
|
74
|
+
@servers.transform_values(&:statistics_string)
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
end
|
|
@@ -38,7 +38,7 @@ module Falcon
|
|
|
38
38
|
# @parameter evaluator [Environment::Evaluator] The environment evaluator.
|
|
39
39
|
# @returns [Falcon::Server] The server instance.
|
|
40
40
|
def run(instance, evaluator)
|
|
41
|
-
if evaluator.
|
|
41
|
+
if evaluator.respond_to?(:make_supervised_worker)
|
|
42
42
|
Console.warn(self, "Async::Container::Supervisor is replaced by Async::Services::Supervisor, please update your service definition.")
|
|
43
43
|
|
|
44
44
|
evaluator.make_supervised_worker(instance).run
|
data/lib/falcon/version.rb
CHANGED
data/lib/falcon.rb
CHANGED
data/readme.md
CHANGED
|
@@ -47,6 +47,14 @@ Please see the [project documentation](https://socketry.github.io/falcon/) for m
|
|
|
47
47
|
|
|
48
48
|
Please see the [project releases](https://socketry.github.io/falcon/releases/index) for all releases.
|
|
49
49
|
|
|
50
|
+
### v0.54.1
|
|
51
|
+
|
|
52
|
+
- Fix handling of old style supervisors from `Async::Container::Supervisor`.
|
|
53
|
+
|
|
54
|
+
### v0.54.0
|
|
55
|
+
|
|
56
|
+
- Introduce `Falcon::CompositeServer` for hosting multiple server instances in a single worker.
|
|
57
|
+
|
|
50
58
|
### v0.52.4
|
|
51
59
|
|
|
52
60
|
- Relax dependency on `async-container-supervisor` to allow `~> 0.6`.
|
|
@@ -87,33 +95,6 @@ During the `v0.44.0` release cycle, the workflows for testing older rack release
|
|
|
87
95
|
|
|
88
96
|
Specifically, `protocol-rack` now provides `Protocol::Rack::Adapter.parse_file` to load Rack applications. Rack 2's `Rack::Builder.parse_file` returns both the application and a set of options (multi-value return). Rack 3 changed this to only return the application, as the prior multi-value return was confusing at best. This change allows `protocol-rack` to work with both versions of rack, and `falcon` adopts that interface.
|
|
89
97
|
|
|
90
|
-
### Falcon Serve Options
|
|
91
|
-
|
|
92
|
-
In addition, `falcon serve` provides two new options:
|
|
93
|
-
|
|
94
|
-
1. `--[no]-restart` which controls what happens when `async-container` instances crash. By default, `falcon serve` will restart the container when it crashes. This can be disabled with `--no-restart`.
|
|
95
|
-
|
|
96
|
-
2. `--graceful-stop [timeout]` which allows you to specify a timeout for graceful shutdown. This is useful when you want to stop the server, but allow existing connections to finish processing before the server stops. This feature is highly experimental and doesn't work correctly in all cases yet, but we are aiming to improve it.
|
|
97
|
-
|
|
98
|
-
### Falcon Host
|
|
99
|
-
|
|
100
|
-
`async-service` is a new gem that exposes a generic service interface on top of `async-container`. Previously, `falcon host` used `async-container` directly and `build-environment` for configuration. In order to allow for more generic service definitions and configuration, `async-service` now provides a similar interface to `build-environment` and exposes this in a way that can be used for services other tha falcon. This makes it simpler to integrate multiple services into a single application.
|
|
101
|
-
|
|
102
|
-
The current configuration format uses definitions like this:
|
|
103
|
-
|
|
104
|
-
``` ruby
|
|
105
|
-
rack "hello.localhost", :self_signed_tls
|
|
106
|
-
```
|
|
107
|
-
|
|
108
|
-
This changes to:
|
|
109
|
-
|
|
110
|
-
``` ruby
|
|
111
|
-
service "hello.localhost" do
|
|
112
|
-
include Falcon::Environment::Rack
|
|
113
|
-
include Falcon::Environment::SelfSignedTLS
|
|
114
|
-
end
|
|
115
|
-
```
|
|
116
|
-
|
|
117
98
|
## Contributing
|
|
118
99
|
|
|
119
100
|
We welcome contributions to this project.
|
data/releases.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Releases
|
|
2
2
|
|
|
3
|
+
## v0.54.1
|
|
4
|
+
|
|
5
|
+
- Fix handling of old style supervisors from `Async::Container::Supervisor`.
|
|
6
|
+
|
|
7
|
+
## v0.54.0
|
|
8
|
+
|
|
9
|
+
- Introduce `Falcon::CompositeServer` for hosting multiple server instances in a single worker.
|
|
10
|
+
|
|
3
11
|
## v0.52.4
|
|
4
12
|
|
|
5
13
|
- Relax dependency on `async-container-supervisor` to allow `~> 0.6`.
|
data.tar.gz.sig
CHANGED
|
Binary file
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: falcon
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.54.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Samuel Williams
|
|
@@ -261,6 +261,7 @@ files:
|
|
|
261
261
|
- lib/falcon/command/serve.rb
|
|
262
262
|
- lib/falcon/command/top.rb
|
|
263
263
|
- lib/falcon/command/virtual.rb
|
|
264
|
+
- lib/falcon/composite_server.rb
|
|
264
265
|
- lib/falcon/configuration.rb
|
|
265
266
|
- lib/falcon/endpoint.rb
|
|
266
267
|
- lib/falcon/environment.rb
|
metadata.gz.sig
CHANGED
|
Binary file
|