Skip to content

Commit 5952685

Browse files
Expose cluster listener protocol names.
1 parent 921b033 commit 5952685

5 files changed

Lines changed: 13 additions & 12 deletions

File tree

examples/cluster/readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ This example shows how to run Falcon cluster workers on independently bound Unix
44

55
Each worker lazily constructs an `IO::Endpoint.unix` endpoint using its process ID and current thread object ID. Consequently, process, threaded, and hybrid workers never compete for the same socket path, and the socket directory reflects every independently bound worker.
66

7-
After binding, Falcon describes each worker using a `Falcon::Service::Cluster::Listener`. The listener exposes its logical name, scheme, protocol, bound endpoint, and all concrete socket addresses. Service discovery integrations can use `prepare_worker!(instance, listener:)` to register exactly what the worker bound.
7+
After binding, Falcon describes each worker using a `Falcon::Service::Cluster::Listener`. The listener exposes its logical name, scheme, supported protocol names, bound endpoint, and all concrete socket addresses. Service discovery integrations can use `prepare_worker!(instance, listener:)` to register exactly what the worker bound.
88

99
## Usage
1010

falcon.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Gem::Specification.new do |spec|
2828

2929
spec.add_dependency "async"
3030
spec.add_dependency "async-container", "~> 0.20"
31-
spec.add_dependency "async-http", "~> 0.75"
31+
spec.add_dependency "async-http", "~> 0.97"
3232
spec.add_dependency "async-http-cache", "~> 0.4"
3333
spec.add_dependency "async-service", "~> 0.19"
3434
spec.add_dependency "async-utilization", "~> 0.3"

gems.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
# gem "fiber-profiler"
2727

28-
gem "async-service-supervisor"
28+
gem "async-service-supervisor", "~> 0.18"
2929

3030
group :maintenance, optional: true do
3131
gem "bake-modernize"

lib/falcon/service/cluster.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ class Listener
1515
# Initialize a bound listener.
1616
# @parameter name [String] The logical listener name.
1717
# @parameter scheme [String] The application protocol scheme.
18-
# @parameter protocol [Object] The application protocol implementation.
18+
# @parameter protocols [Array(String)] The supported application protocol names.
1919
# @parameter endpoint [IO::Endpoint::BoundEndpoint] The endpoint bound by the worker.
20-
def initialize(name:, scheme:, protocol:, endpoint:)
20+
def initialize(name:, scheme:, protocols:, endpoint:)
2121
@name = name
2222
@scheme = scheme
23-
@protocol = protocol
23+
@protocols = protocols.map(&:to_s).freeze
2424
@endpoint = endpoint
2525
@addresses = endpoint.sockets.map{|socket| socket.to_io.local_address}.freeze
2626
freeze
@@ -32,8 +32,8 @@ def initialize(name:, scheme:, protocol:, endpoint:)
3232
# @attribute [String] The application protocol scheme.
3333
attr_reader :scheme
3434

35-
# @attribute [Object] The application protocol implementation.
36-
attr_reader :protocol
35+
# @attribute [Array(String)] The supported application protocol names.
36+
attr_reader :protocols
3737

3838
# @attribute [IO::Endpoint::BoundEndpoint] The endpoint bound by the worker.
3939
attr_reader :endpoint
@@ -74,7 +74,7 @@ def setup(container)
7474
listener = Listener.new(
7575
name: evaluator.name,
7676
scheme: endpoint.scheme,
77-
protocol: endpoint.protocol,
77+
protocols: endpoint.protocol.names,
7878
endpoint: bound_endpoint,
7979
)
8080

test/falcon/service/cluster.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@
1414
describe Falcon::Service::Cluster do
1515
let(:ports_path) {File.expand_path(".cluster/ports.txt", __dir__)}
1616

17-
def make_listener(*addresses, name: "hello", scheme: "http", protocol: Async::HTTP::Protocol::HTTP1)
17+
def make_listener(*addresses, name: "hello", scheme: "http", protocols: ["http/1.1", "http/1.0"])
1818
sockets = addresses.map do |address|
1919
io = Struct.new(:local_address).new(address)
2020
Struct.new(:to_io).new(io)
2121
end
2222

2323
endpoint = Struct.new(:sockets).new(sockets)
24-
subject::Listener.new(name: name, scheme: scheme, protocol: protocol, endpoint: endpoint)
24+
subject::Listener.new(name: name, scheme: scheme, protocols: protocols, endpoint: endpoint)
2525
end
2626

2727
it "describes the bound listener" do
@@ -32,11 +32,12 @@ def make_listener(*addresses, name: "hello", scheme: "http", protocol: Async::HT
3232
expect(listener).to have_attributes(
3333
name: be == "hello",
3434
scheme: be == "http",
35-
protocol: be == Async::HTTP::Protocol::HTTP1,
35+
protocols: be == ["http/1.1", "http/1.0"],
3636
addresses: be == [ip_address, unix_address],
3737
frozen?: be == true,
3838
)
3939
expect(listener.addresses.frozen?).to be == true
40+
expect(listener.protocols.frozen?).to be == true
4041
end
4142

4243
let(:recorder) do

0 commit comments

Comments
 (0)