falcon 0.46.1 → 0.47.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/falcon/command/supervisor.rb +7 -9
- data/lib/falcon/environment/application.rb +1 -1
- data/lib/falcon/environment/proxy.rb +1 -1
- data/lib/falcon/environment/rack.rb +1 -1
- data/lib/falcon/environment/rackup.rb +1 -1
- data/lib/falcon/environment/server.rb +1 -1
- data/lib/falcon/environment/supervisor.rb +2 -2
- data/lib/falcon/proxy_endpoint.rb +5 -5
- data/lib/falcon/rackup/handler.rb +78 -0
- data/lib/falcon/service/server.rb +2 -2
- data/lib/falcon/service/supervisor.rb +1 -3
- data/lib/falcon/service/virtual.rb +1 -1
- data/lib/falcon/version.rb +1 -1
- data/lib/rack/handler/falcon.rb +3 -72
- data/lib/rackup/handler/falcon.rb +2 -70
- data.tar.gz.sig +0 -0
- metadata +14 -6
- 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: afae07cb03f2c1966050a313f8a5be2cd26fde0ad9d3d1ab1ff3eb091271f29d
|
4
|
+
data.tar.gz: 53b781ad1cd3f49414eca991ac09efb281c96c7daa55d708c429d036e911d349
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '088b7b78b93930ab04c21e978050f46830ee38931773f91ff8635b74f5c5fb9a7cdd7892c107f3540baa6d3bbf1ea93b21dd9931c6cf9e2835184a4ebc3dc4fe'
|
7
|
+
data.tar.gz: 99199297af5faf6cd5c7dcc3bb4f081781a4876f6c45ec8370596ca3e6d614ac79c56a3fd297df109434102baaea489711472e023c35e18f276cee8648df896d
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
@@ -1,14 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
|
-
# Copyright, 2019-
|
4
|
+
# Copyright, 2019-2024, by Samuel Williams.
|
5
5
|
|
6
6
|
require 'samovar'
|
7
7
|
require 'async'
|
8
8
|
require 'json'
|
9
9
|
|
10
|
-
require '
|
11
|
-
require '
|
10
|
+
require 'io/endpoint/unix_endpoint'
|
11
|
+
require 'io/stream'
|
12
12
|
|
13
13
|
module Falcon
|
14
14
|
module Command
|
@@ -43,7 +43,7 @@ module Falcon
|
|
43
43
|
stream.puts({please: 'metrics'}.to_json, separator: "\0")
|
44
44
|
response = JSON.parse(stream.gets("\0"), symbolize_names: true)
|
45
45
|
|
46
|
-
|
46
|
+
$stdout.puts response
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
@@ -57,16 +57,14 @@ module Falcon
|
|
57
57
|
|
58
58
|
# The endpoint the supervisor is bound to.
|
59
59
|
def endpoint
|
60
|
-
|
60
|
+
::IO::Endpoint.unix(@options[:path])
|
61
61
|
end
|
62
62
|
|
63
63
|
# Connect to the supervisor and execute the requested command.
|
64
64
|
def call
|
65
|
-
|
65
|
+
Sync do
|
66
66
|
endpoint.connect do |socket|
|
67
|
-
|
68
|
-
|
69
|
-
@command.call(stream)
|
67
|
+
@command.call(IO::Stream(socket))
|
70
68
|
end
|
71
69
|
end
|
72
70
|
end
|
@@ -41,7 +41,7 @@ module Falcon
|
|
41
41
|
end
|
42
42
|
|
43
43
|
# The endpoint that will be used for communicating with the application server.
|
44
|
-
# @returns [
|
44
|
+
# @returns [::Falcon::ProxyEndpoint]
|
45
45
|
def endpoint
|
46
46
|
::Falcon::ProxyEndpoint.unix(ipc_path,
|
47
47
|
protocol: protocol,
|
@@ -23,9 +23,9 @@ module Falcon
|
|
23
23
|
end
|
24
24
|
|
25
25
|
# The endpoint the supervisor will bind to.
|
26
|
-
# @returns [
|
26
|
+
# @returns [::IO::Endpoint::Generic]
|
27
27
|
def endpoint
|
28
|
-
|
28
|
+
::IO::Endpoint.unix(ipc_path)
|
29
29
|
end
|
30
30
|
|
31
31
|
# The service class to use for the supervisor.
|
@@ -3,13 +3,13 @@
|
|
3
3
|
# Released under the MIT License.
|
4
4
|
# Copyright, 2019-2023, by Samuel Williams.
|
5
5
|
|
6
|
-
require '
|
6
|
+
require 'io/endpoint/unix_endpoint'
|
7
7
|
|
8
8
|
module Falcon
|
9
9
|
# An endpoint suitable for proxing requests, typically via a unix pipe.
|
10
|
-
class ProxyEndpoint <
|
10
|
+
class ProxyEndpoint < ::IO::Endpoint::Generic
|
11
11
|
# Initialize the proxy endpoint.
|
12
|
-
# @parameter endpoint [
|
12
|
+
# @parameter endpoint [::IO::Endpoint::Generic] The endpoint which will be used for connecting/binding.
|
13
13
|
def initialize(endpoint, **options)
|
14
14
|
super(**options)
|
15
15
|
|
@@ -21,7 +21,7 @@ module Falcon
|
|
21
21
|
end
|
22
22
|
|
23
23
|
# The actual endpoint for I/O.
|
24
|
-
# @attribute [
|
24
|
+
# @attribute [::IO::Endpoint::Generic]
|
25
25
|
attr :endpoint
|
26
26
|
|
27
27
|
# The protocol to use for this connection.
|
@@ -69,7 +69,7 @@ module Falcon
|
|
69
69
|
# Create a proxy unix endpoint with the specific path.
|
70
70
|
# @returns [ProxyEndpoint]
|
71
71
|
def self.unix(path, **options)
|
72
|
-
self.new(::
|
72
|
+
self.new(::IO::Endpoint.unix(path), **options)
|
73
73
|
end
|
74
74
|
end
|
75
75
|
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2023, by Samuel Williams.
|
5
|
+
|
6
|
+
require 'rackup/handler'
|
7
|
+
|
8
|
+
require_relative '../../falcon'
|
9
|
+
|
10
|
+
require 'kernel/sync'
|
11
|
+
require 'io/endpoint/host_endpoint'
|
12
|
+
|
13
|
+
module Falcon
|
14
|
+
module Rackup
|
15
|
+
# The falcon adaptor for the `rackup` executable.
|
16
|
+
class Handler
|
17
|
+
# The default scheme.
|
18
|
+
SCHEME = "http"
|
19
|
+
|
20
|
+
# Generate an endpoint for the given `rackup` options.
|
21
|
+
# @returns [::IO::Endpoint::HostEndpoint]
|
22
|
+
def self.endpoint_for(**options)
|
23
|
+
host = options[:Host] || 'localhost'
|
24
|
+
port = Integer(options[:Port] || 9292)
|
25
|
+
|
26
|
+
return ::IO::Endpoint.tcp(host, port)
|
27
|
+
end
|
28
|
+
|
29
|
+
# Run the specified app using the given options:
|
30
|
+
# @parameter app [Object] The rack middleware.
|
31
|
+
def self.run(app, **options)
|
32
|
+
app = ::Protocol::Rack::Adapter.new(app)
|
33
|
+
|
34
|
+
Sync do |task|
|
35
|
+
endpoint = endpoint_for(**options)
|
36
|
+
server = ::Falcon::Server.new(app, endpoint, protocol: Async::HTTP::Protocol::HTTP1, scheme: SCHEME)
|
37
|
+
|
38
|
+
server_task = server.run
|
39
|
+
|
40
|
+
wrapper = self.new(server, task)
|
41
|
+
|
42
|
+
yield wrapper if block_given?
|
43
|
+
|
44
|
+
server_task.wait
|
45
|
+
ensure
|
46
|
+
server_task.stop
|
47
|
+
wrapper.close
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def initialize(server, task)
|
52
|
+
@server = server
|
53
|
+
@task = task
|
54
|
+
|
55
|
+
@notification = Thread::Queue.new
|
56
|
+
|
57
|
+
@waiter = @task.async(transient: true) do
|
58
|
+
@notification.pop
|
59
|
+
|
60
|
+
@task&.stop
|
61
|
+
@task = nil
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def stop
|
66
|
+
@notification&.push(true)
|
67
|
+
end
|
68
|
+
|
69
|
+
def close
|
70
|
+
@notification&.close
|
71
|
+
@notification = nil
|
72
|
+
|
73
|
+
@waiter&.stop
|
74
|
+
@waiter = nil
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
|
-
# Copyright,
|
5
|
-
# Copyright, 2020, by
|
4
|
+
# Copyright, 2019-2024, by Samuel Williams.
|
5
|
+
# Copyright, 2020, by Daniel Evans.
|
6
6
|
|
7
7
|
require 'async/service/generic'
|
8
8
|
require 'async/http/endpoint'
|
@@ -6,8 +6,6 @@
|
|
6
6
|
require 'process/metrics'
|
7
7
|
require 'json'
|
8
8
|
|
9
|
-
require 'async/io/endpoint'
|
10
|
-
require 'async/io/shared_endpoint'
|
11
9
|
require 'async/service/generic'
|
12
10
|
|
13
11
|
module Falcon
|
@@ -71,7 +69,7 @@ module Falcon
|
|
71
69
|
container.run(name: self.name, restart: true, count: 1) do |instance|
|
72
70
|
Async do
|
73
71
|
@bound_endpoint.accept do |peer|
|
74
|
-
stream =
|
72
|
+
stream = ::IO::Stream.new(peer)
|
75
73
|
|
76
74
|
while message = stream.gets("\0")
|
77
75
|
response = handle(JSON.parse(message, symbolize_names: true))
|
data/lib/falcon/version.rb
CHANGED
data/lib/rack/handler/falcon.rb
CHANGED
@@ -1,84 +1,15 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Released under the MIT License.
|
4
|
-
# Copyright,
|
5
|
-
# Copyright, 2019, by Bryan Powell.
|
4
|
+
# Copyright, 2023, by Samuel Williams.
|
6
5
|
|
7
6
|
require 'rack/handler'
|
8
7
|
|
9
|
-
require_relative '../../falcon'
|
10
|
-
|
11
|
-
require 'kernel/sync'
|
12
|
-
require 'async/io/host_endpoint'
|
13
|
-
require 'async/io/notification'
|
8
|
+
require_relative '../../falcon/rackup/handler'
|
14
9
|
|
15
10
|
module Rack
|
16
11
|
module Handler
|
17
|
-
|
18
|
-
class Falcon
|
19
|
-
# The default scheme.
|
20
|
-
SCHEME = "http"
|
21
|
-
|
22
|
-
# Generate an endpoint for the given `rackup` options.
|
23
|
-
# @returns [Async::IO::Endpoint]
|
24
|
-
def self.endpoint_for(**options)
|
25
|
-
host = options[:Host] || 'localhost'
|
26
|
-
port = Integer(options[:Port] || 9292)
|
27
|
-
|
28
|
-
return Async::IO::Endpoint.tcp(host, port)
|
29
|
-
end
|
30
|
-
|
31
|
-
# Run the specified app using the given options:
|
32
|
-
# @parameter app [Object] The rack middleware.
|
33
|
-
def self.run(app, **options)
|
34
|
-
app = ::Protocol::Rack::Adapter.new(app)
|
35
|
-
|
36
|
-
Sync do |task|
|
37
|
-
endpoint = endpoint_for(**options)
|
38
|
-
server = ::Falcon::Server.new(app, endpoint, protocol: Async::HTTP::Protocol::HTTP1, scheme: SCHEME)
|
39
|
-
|
40
|
-
server_task = task.async do
|
41
|
-
server.run.each(&:wait)
|
42
|
-
end
|
43
|
-
|
44
|
-
wrapper = self.new(server, task)
|
45
|
-
|
46
|
-
yield wrapper if block_given?
|
47
|
-
|
48
|
-
server_task.wait
|
49
|
-
ensure
|
50
|
-
server_task.stop
|
51
|
-
wrapper.close
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
def initialize(server, task)
|
56
|
-
@server = server
|
57
|
-
@task = task
|
58
|
-
|
59
|
-
@notification = Async::IO::Notification.new
|
60
|
-
|
61
|
-
@waiter = @task.async(transient: true) do
|
62
|
-
@notification.wait
|
63
|
-
|
64
|
-
@task&.stop
|
65
|
-
@task = nil
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
def stop
|
70
|
-
@notification&.signal
|
71
|
-
end
|
72
|
-
|
73
|
-
def close
|
74
|
-
@notification&.close
|
75
|
-
@notification = nil
|
76
|
-
|
77
|
-
@waiter&.stop
|
78
|
-
@waiter = nil
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
12
|
+
Falcon = ::Falcon::Rackup::Handler
|
82
13
|
register :falcon, Falcon
|
83
14
|
end
|
84
15
|
end
|
@@ -5,79 +5,11 @@
|
|
5
5
|
|
6
6
|
require 'rackup/handler'
|
7
7
|
|
8
|
-
require_relative '../../falcon'
|
9
|
-
|
10
|
-
require 'kernel/sync'
|
11
|
-
require 'async/io/host_endpoint'
|
12
|
-
require 'async/io/notification'
|
8
|
+
require_relative '../../falcon/rackup/handler'
|
13
9
|
|
14
10
|
module Rackup
|
15
11
|
module Handler
|
16
|
-
|
17
|
-
class Falcon
|
18
|
-
# The default scheme.
|
19
|
-
SCHEME = "http"
|
20
|
-
|
21
|
-
# Generate an endpoint for the given `rackup` options.
|
22
|
-
# @returns [Async::IO::Endpoint]
|
23
|
-
def self.endpoint_for(**options)
|
24
|
-
host = options[:Host] || 'localhost'
|
25
|
-
port = Integer(options[:Port] || 9292)
|
26
|
-
|
27
|
-
return Async::IO::Endpoint.tcp(host, port)
|
28
|
-
end
|
29
|
-
|
30
|
-
# Run the specified app using the given options:
|
31
|
-
# @parameter app [Object] The rack middleware.
|
32
|
-
def self.run(app, **options)
|
33
|
-
app = ::Protocol::Rack::Adapter.new(app)
|
34
|
-
|
35
|
-
Sync do |task|
|
36
|
-
endpoint = endpoint_for(**options)
|
37
|
-
server = ::Falcon::Server.new(app, endpoint, protocol: Async::HTTP::Protocol::HTTP1, scheme: SCHEME)
|
38
|
-
|
39
|
-
server_task = task.async do
|
40
|
-
server.run.each(&:wait)
|
41
|
-
end
|
42
|
-
|
43
|
-
wrapper = self.new(server, task)
|
44
|
-
|
45
|
-
yield wrapper if block_given?
|
46
|
-
|
47
|
-
server_task.wait
|
48
|
-
ensure
|
49
|
-
server_task.stop
|
50
|
-
wrapper.close
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
def initialize(server, task)
|
55
|
-
@server = server
|
56
|
-
@task = task
|
57
|
-
|
58
|
-
@notification = Async::IO::Notification.new
|
59
|
-
|
60
|
-
@waiter = @task.async(transient: true) do
|
61
|
-
@notification.wait
|
62
|
-
|
63
|
-
@task&.stop
|
64
|
-
@task = nil
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
def stop
|
69
|
-
@notification&.signal
|
70
|
-
end
|
71
|
-
|
72
|
-
def close
|
73
|
-
@notification&.close
|
74
|
-
@notification = nil
|
75
|
-
|
76
|
-
@waiter&.stop
|
77
|
-
@waiter = nil
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
12
|
+
Falcon = ::Falcon::Rackup::Handler
|
81
13
|
register :falcon, Falcon
|
82
14
|
end
|
83
15
|
end
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: falcon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.47.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
8
|
- Janko Marohnić
|
9
9
|
- Bryan Powell
|
10
|
+
- Trevor Turk
|
10
11
|
- Claudiu Garba
|
11
12
|
- Kyle Tam
|
12
13
|
- Mitsutaka Mimura
|
13
14
|
- Sho Ito
|
14
|
-
- Trevor Turk
|
15
15
|
- Colby Swandale
|
16
16
|
- Daniel Evans
|
17
17
|
- Kent Gruber
|
@@ -57,7 +57,7 @@ cert_chain:
|
|
57
57
|
Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
|
58
58
|
voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
|
59
59
|
-----END CERTIFICATE-----
|
60
|
-
date: 2024-04-
|
60
|
+
date: 2024-04-30 00:00:00.000000000 Z
|
61
61
|
dependencies:
|
62
62
|
- !ruby/object:Gem::Dependency
|
63
63
|
name: async
|
@@ -93,14 +93,20 @@ dependencies:
|
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '0.
|
96
|
+
version: '0.66'
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: 0.66.2
|
97
100
|
type: :runtime
|
98
101
|
prerelease: false
|
99
102
|
version_requirements: !ruby/object:Gem::Requirement
|
100
103
|
requirements:
|
101
104
|
- - "~>"
|
102
105
|
- !ruby/object:Gem::Version
|
103
|
-
version: '0.
|
106
|
+
version: '0.66'
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: 0.66.2
|
104
110
|
- !ruby/object:Gem::Dependency
|
105
111
|
name: async-http-cache
|
106
112
|
requirement: !ruby/object:Gem::Requirement
|
@@ -252,6 +258,7 @@ files:
|
|
252
258
|
- lib/falcon/middleware/redirect.rb
|
253
259
|
- lib/falcon/middleware/verbose.rb
|
254
260
|
- lib/falcon/proxy_endpoint.rb
|
261
|
+
- lib/falcon/rackup/handler.rb
|
255
262
|
- lib/falcon/railtie.rb
|
256
263
|
- lib/falcon/server.rb
|
257
264
|
- lib/falcon/service/server.rb
|
@@ -268,6 +275,7 @@ licenses:
|
|
268
275
|
- MIT
|
269
276
|
metadata:
|
270
277
|
documentation_uri: https://socketry.github.io/falcon/
|
278
|
+
source_code_uri: https://github.com/socketry/falcon.git
|
271
279
|
post_install_message:
|
272
280
|
rdoc_options: []
|
273
281
|
require_paths:
|
@@ -276,7 +284,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
276
284
|
requirements:
|
277
285
|
- - ">="
|
278
286
|
- !ruby/object:Gem::Version
|
279
|
-
version: '3.
|
287
|
+
version: '3.1'
|
280
288
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
281
289
|
requirements:
|
282
290
|
- - ">="
|
metadata.gz.sig
CHANGED
Binary file
|