falcon 0.35.4 → 0.35.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/bin/falcon +4 -0
- data/examples/hello/config.ru +2 -2
- data/examples/sinatra/Gemfile.lock +1 -1
- data/falcon.gemspec +2 -1
- data/lib/falcon/command/serve.rb +20 -8
- data/lib/falcon/command/top.rb +21 -8
- data/lib/falcon/configuration/rack.rb +7 -2
- data/lib/falcon/controller/serve.rb +2 -6
- data/lib/falcon/server.rb +7 -1
- data/lib/falcon/version.rb +1 -1
- metadata +18 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e83bfe3390b43efac4ff13076a198647d1b0e4da68c9341fb6253a70f03c65d3
|
4
|
+
data.tar.gz: 0c915210a960b159ced61e91f807c63ffae9f3b22313e1f1b806ffa83422a529
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f97f776a63c1541874af780652096e5dee4e197ccaf04a1c3e2b5c4d6b72a508b29527281f5d5e6e6c64ec40fdc3c6e16a66e69dd44cafb407326c77977a503c
|
7
|
+
data.tar.gz: c4aae4c9610fb77e017e5f91bab938855b24662d80a5188b199397e98c41d42c6fc84db5ad377ec13cfb01610a2819a23c9c431092d67d39cfb9f06be73d4c54
|
data/README.md
CHANGED
@@ -273,7 +273,7 @@ Falcon can be an important part of your business or project, both improving perf
|
|
273
273
|
- Priority consideration of feature requests and bug reports.
|
274
274
|
- Private support and assistance via direct email.
|
275
275
|
|
276
|
-
The standard price for business support is $120.00 USD / year / production instance (including reserve instances). Please [contact us](mailto:
|
276
|
+
The standard price for business support is $120.00 USD / year / production instance (including reserve instances). Please [contact us](mailto:contact@oriontransfer.net?subject=Falcon%20Business%20Support) for more details.
|
277
277
|
|
278
278
|
### "Stretch" Goals
|
279
279
|
|
data/bin/falcon
CHANGED
data/examples/hello/config.ru
CHANGED
@@ -17,6 +17,6 @@ class RequestLogger
|
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
-
use RequestLogger
|
20
|
+
# use RequestLogger
|
21
21
|
|
22
|
-
run lambda {|env|
|
22
|
+
run lambda {|env| [200, {'cache-control' => 'max-age=10, public'}, ["Hello World"]]}
|
data/falcon.gemspec
CHANGED
@@ -21,7 +21,8 @@ Gem::Specification.new do |spec|
|
|
21
21
|
|
22
22
|
spec.add_dependency "async", "~> 1.13"
|
23
23
|
spec.add_dependency "async-io", "~> 1.22"
|
24
|
-
spec.add_dependency "async-http", "~> 0.50.
|
24
|
+
spec.add_dependency "async-http", "~> 0.50.4"
|
25
|
+
spec.add_dependency "async-http-cache", "~> 0.1.0"
|
25
26
|
spec.add_dependency "async-container", "~> 0.16.0"
|
26
27
|
|
27
28
|
spec.add_dependency "rack", ">= 1.0"
|
data/lib/falcon/command/serve.rb
CHANGED
@@ -41,7 +41,7 @@ require 'bundler'
|
|
41
41
|
module Falcon
|
42
42
|
module Command
|
43
43
|
class Serve < Samovar::Command
|
44
|
-
self.description = "Run an HTTP server."
|
44
|
+
self.description = "Run an HTTP server for development purposes."
|
45
45
|
|
46
46
|
options do
|
47
47
|
option '-b/--bind <address>', "Bind to the given hostname/address.", default: "https://localhost:9292"
|
@@ -51,7 +51,9 @@ module Falcon
|
|
51
51
|
option '-t/--timeout <duration>', "Specify the maximum time to wait for non-blocking operations.", type: Float, default: nil
|
52
52
|
|
53
53
|
option '-c/--config <path>', "Rackup configuration file to load.", default: 'config.ru'
|
54
|
-
option '--preload', "Preload the
|
54
|
+
option '--preload <path>', "Preload the specified path before creating containers."
|
55
|
+
|
56
|
+
option '--cache', "Enable the response cache."
|
55
57
|
|
56
58
|
option '--forked | --threaded | --hybrid', "Select a specific parallelism model.", key: :container, default: :forked
|
57
59
|
|
@@ -76,10 +78,14 @@ module Falcon
|
|
76
78
|
@parent&.verbose?
|
77
79
|
end
|
78
80
|
|
79
|
-
def
|
80
|
-
|
81
|
+
def cache?
|
82
|
+
@options[:cache]
|
83
|
+
end
|
84
|
+
|
85
|
+
def load_app
|
86
|
+
rack_app, _ = Rack::Builder.parse_file(@options[:config])
|
81
87
|
|
82
|
-
return Server.middleware(rack_app, verbose: verbose)
|
88
|
+
return Server.middleware(rack_app, verbose: self.verbose?, cache: self.cache?)
|
83
89
|
end
|
84
90
|
|
85
91
|
def slice_options(*keys)
|
@@ -120,14 +126,20 @@ module Falcon
|
|
120
126
|
end
|
121
127
|
|
122
128
|
def call
|
123
|
-
Async.logger.info(self
|
129
|
+
Async.logger.info(self) do |buffer|
|
124
130
|
buffer.puts "Falcon v#{VERSION} taking flight! Using #{self.container_class} #{self.container_options}."
|
131
|
+
buffer.puts "- Binding to: #{self.endpoint}"
|
125
132
|
buffer.puts "- To terminate: Ctrl-C or kill #{Process.pid}"
|
126
133
|
buffer.puts "- To reload configuration: kill -HUP #{Process.pid}"
|
127
134
|
end
|
128
135
|
|
129
|
-
if @options[:preload]
|
130
|
-
|
136
|
+
if path = @options[:preload]
|
137
|
+
full_path = File.expand_path(path)
|
138
|
+
load(full_path)
|
139
|
+
end
|
140
|
+
|
141
|
+
if GC.respond_to?(:compact)
|
142
|
+
GC.compact
|
131
143
|
end
|
132
144
|
|
133
145
|
self.controller.run
|
data/lib/falcon/command/top.rb
CHANGED
@@ -40,6 +40,7 @@ module Falcon
|
|
40
40
|
option '--verbose | --quiet', "Verbosity of output for debugging.", key: :logging
|
41
41
|
option '-h/--help', "Print out help information."
|
42
42
|
option '-v/--version', "Print out the application version."
|
43
|
+
option '-e/--encoding', "Specify the default external encoding of the server.", default: "UTF-8"
|
43
44
|
end
|
44
45
|
|
45
46
|
nested :command, {
|
@@ -59,15 +60,27 @@ module Falcon
|
|
59
60
|
@options[:logging] == :quiet
|
60
61
|
end
|
61
62
|
|
63
|
+
# If you don't specify these, it's possible to have issues when encodings mismatch on the server.
|
64
|
+
def update_external_encoding!(encoding = Encoding::UTF_8)
|
65
|
+
if Encoding.default_external != encoding
|
66
|
+
Console.logger.warn(self) {"Updating Encoding.default_external from #{Encoding.default_external} to #{encoding}"}
|
67
|
+
Encoding.default_external = encoding
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def encoding
|
72
|
+
if name = @options[:encoding]
|
73
|
+
Encoding.find(name)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
62
77
|
def call
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
# end
|
70
|
-
#
|
78
|
+
if encoding = self.encoding
|
79
|
+
update_external_encoding!(encoding)
|
80
|
+
else
|
81
|
+
update_external_encoding!
|
82
|
+
end
|
83
|
+
|
71
84
|
if @options[:version]
|
72
85
|
puts "#{self.name} v#{Falcon::VERSION}"
|
73
86
|
elsif @options[:help]
|
@@ -25,9 +25,14 @@ load :application
|
|
25
25
|
add(:rack, :application) do
|
26
26
|
config_path {::File.expand_path("config.ru", root)}
|
27
27
|
|
28
|
+
cache true
|
29
|
+
|
28
30
|
middleware do
|
29
|
-
::
|
30
|
-
|
31
|
+
app, _ = ::Rack::Builder.parse_file(config_path)
|
32
|
+
|
33
|
+
::Falcon::Server.middleware(app,
|
34
|
+
verbose: verbose,
|
35
|
+
cache: cache
|
31
36
|
)
|
32
37
|
end
|
33
38
|
end
|
@@ -69,14 +69,10 @@ module Falcon
|
|
69
69
|
end
|
70
70
|
|
71
71
|
def setup(container)
|
72
|
-
app, _ = self.load_app
|
73
|
-
|
74
|
-
if GC.respond_to?(:compact)
|
75
|
-
GC.compact
|
76
|
-
end
|
77
|
-
|
78
72
|
container.run(name: self.name, restart: true, **@command.container_options) do |instance|
|
79
73
|
Async do |task|
|
74
|
+
app = self.load_app
|
75
|
+
|
80
76
|
task.async do
|
81
77
|
if @debug_trap.install!
|
82
78
|
Async.logger.info(instance) do
|
data/lib/falcon/server.rb
CHANGED
@@ -25,18 +25,24 @@ require 'async/http/server'
|
|
25
25
|
require 'protocol/http/middleware/builder'
|
26
26
|
require 'protocol/http/content_encoding'
|
27
27
|
|
28
|
+
require 'async/http/cache'
|
29
|
+
|
28
30
|
require_relative 'verbose'
|
29
31
|
require_relative 'adapters/rewindable'
|
30
32
|
require_relative 'adapters/rack'
|
31
33
|
|
32
34
|
module Falcon
|
33
35
|
class Server < Async::HTTP::Server
|
34
|
-
def self.middleware(rack_app, verbose: false)
|
36
|
+
def self.middleware(rack_app, verbose: false, cache: true)
|
35
37
|
::Protocol::HTTP::Middleware.build do
|
36
38
|
if verbose
|
37
39
|
use Verbose
|
38
40
|
end
|
39
41
|
|
42
|
+
if cache
|
43
|
+
use Async::HTTP::Cache::General
|
44
|
+
end
|
45
|
+
|
40
46
|
use ::Protocol::HTTP::ContentEncoding
|
41
47
|
use Adapters::Rewindable
|
42
48
|
use Adapters::Rack
|
data/lib/falcon/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: falcon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.35.
|
4
|
+
version: 0.35.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-03-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: async
|
@@ -44,14 +44,28 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0.50.
|
47
|
+
version: 0.50.4
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0.50.
|
54
|
+
version: 0.50.4
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: async-http-cache
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.1.0
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.1.0
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: async-container
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|