falcon 0.53.1 → 0.54.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
- checksums.yaml.gz.sig +0 -0
- data/lib/falcon/composite_server.rb +77 -0
- data/lib/falcon/version.rb +1 -1
- data/lib/falcon.rb +1 -0
- data/readme.md +4 -19
- data/releases.md +4 -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: 6fd837dac48b7cdfe111b4747b6d244bc78c0c2116d2bdc25fd5491c9a6527aa
|
|
4
|
+
data.tar.gz: 5d279dfce1559c6d473de9dbf97a83e2881bec1dad32b6707701a8e9b0386d40
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ae04484955b7e32ef80bdcd6375881193fb08edee5985d9dddd610482c8b45b19bdd25f27ac74d0978dad4049b7014a50d373a3e903e40b6b126c682b7cf41c8
|
|
7
|
+
data.tar.gz: f44774e045e66365a7cb2fc548e6932168c3f2dc9c90c4e8c2c45d29b4836c54c8f68493497f41ff5b3a07c6e24d693ec7e9df9af12a124530a2f7592fa5a9a0
|
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
|
data/lib/falcon/version.rb
CHANGED
data/lib/falcon.rb
CHANGED
data/readme.md
CHANGED
|
@@ -47,6 +47,10 @@ 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.0
|
|
51
|
+
|
|
52
|
+
- Introduce `Falcon::CompositeServer` for hosting multiple server instances in a single worker.
|
|
53
|
+
|
|
50
54
|
### v0.52.4
|
|
51
55
|
|
|
52
56
|
- Relax dependency on `async-container-supervisor` to allow `~> 0.6`.
|
|
@@ -95,25 +99,6 @@ In addition, `falcon serve` provides two new options:
|
|
|
95
99
|
|
|
96
100
|
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
101
|
|
|
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
102
|
## Contributing
|
|
118
103
|
|
|
119
104
|
We welcome contributions to this project.
|
data/releases.md
CHANGED
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.0
|
|
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
|