falcon 0.7.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 649afb10cb1c289a5cfe6d982514364c8390884ff41b82f96c8cd8f704ccd820
4
- data.tar.gz: 98e3e690e776b90df7b41d3ccd1bcc7ca22a4dd1eb019840edded3a215c4da8c
3
+ metadata.gz: f6fcbe05b21493aa8d6d96470a66afa9c4810e4bbc13f2580d89e5cac6cd3146
4
+ data.tar.gz: be058b48b65e5c6310589bfc52a013ebc388f3caa8358a32a7323e676a01a789
5
5
  SHA512:
6
- metadata.gz: 86ec7adc0c04b0bdbd0be2fc73f8def3e523de76188c1a2f2788659c226c34513d325f8e571c493506dad706753201392817c9692d643be61bfefd27f45cccf6
7
- data.tar.gz: 20b36c690afdb98a5d619780fd4a04da43483d3aac31a3bd1265d25c367b894bb157833f505ebc04a063dd15c70bd354cb7c393e43f5ff3a752e17483cdb6e67
6
+ metadata.gz: 3ba4fe3543c5cdd51100c64d38d2d6eee0ca26d9ecf37a9c5acb3da9b74ee7d5eee25dc09d9ed8023df66d2d23caed2756e3397ff763b2819d50297dd6d4e56b
7
+ data.tar.gz: ff7f5dc43ce9cc3b81c48db67cf3c798c55ae4e52aa6643199dca56942a5224e76d7735a6ef6f11e24d1043ef72fb086b9ee9c199acb17cff36833a42a9e3f36
@@ -1,15 +1,14 @@
1
1
  language: ruby
2
- sudo: false
3
- dist: trusty
2
+ sudo: required
3
+ dist: xenial
4
4
  cache: bundler
5
5
 
6
6
  matrix:
7
7
  include:
8
- - rvm: 2.0
9
- - rvm: 2.1
10
8
  - rvm: 2.2
11
9
  - rvm: 2.3
12
10
  - rvm: 2.4
11
+ - rvm: 2.5
13
12
  - rvm: jruby-head
14
13
  env: JRUBY_OPTS="--debug -X+O"
15
14
  - rvm: ruby-head
@@ -16,8 +16,8 @@ Gem::Specification.new do |spec|
16
16
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
17
  spec.require_paths = ["lib"]
18
18
 
19
- spec.add_dependency("async-io", "~> 1.3")
20
- spec.add_dependency("async-http", "~> 0.3")
19
+ spec.add_dependency("async-io", "~> 1.5")
20
+ spec.add_dependency("async-http", "~> 0.8")
21
21
  spec.add_dependency("async-container", "~> 0.1")
22
22
 
23
23
  spec.add_dependency("rack", ">= 1.0")
@@ -18,95 +18,17 @@
18
18
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
19
  # THE SOFTWARE.
20
20
 
21
- require_relative 'server'
22
- require_relative 'verbose'
23
-
24
- require 'async/container'
25
- require 'async/io/trap'
21
+ require_relative 'command/serve'
22
+ require_relative 'version'
26
23
 
27
24
  require 'samovar'
28
- require 'etc'
29
-
30
- require 'rack/builder'
31
- require 'rack/server'
32
25
 
33
26
  module Falcon
34
27
  module Command
35
- def self.default_concurrency
36
- Etc.nprocessors
37
- rescue
38
- 2
39
- end
40
-
41
28
  def self.parse(*args)
42
29
  Top.parse(*args)
43
30
  end
44
31
 
45
- class Serve < Samovar::Command
46
- self.description = "Run an HTTP server."
47
-
48
- options do
49
- option '-c/--config <path>', "Rackup configuration file to load", default: 'config.ru'
50
- option '-n/--concurrency <count>', "Number of processes to start", default: Command.default_concurrency, type: Integer
51
-
52
- option '-b/--bind <address>', "Bind to the given hostname/address", default: "tcp://localhost:9292"
53
-
54
- option '--forked | --threaded', "Select a specific concurrency model", key: :container, default: :threaded
55
- end
56
-
57
- def container_class
58
- case @options[:container]
59
- when :threaded
60
- require 'async/container/threaded'
61
- return Async::Container::Threaded
62
- when :forked
63
- require 'async/container/forked'
64
- return Async::Container::Forked
65
- end
66
- end
67
-
68
- def load_app(verbose)
69
- app, options = Rack::Builder.parse_file(@options[:config])
70
-
71
- if verbose
72
- app = Verbose.new(app)
73
- end
74
-
75
- return app, options
76
- end
77
-
78
- def run(verbose)
79
- app, options = load_app(verbose)
80
-
81
- Async.logger.info "Falcon taking flight! Binding to #{@options[:bind]} [#{container_class} with concurrency: #{@options[:concurrency]}]"
82
-
83
- debug_trap = Async::IO::Trap.new(:USR1)
84
-
85
- container_class.new(concurrency: @options[:concurrency]) do |task|
86
- task.async do
87
- debug_trap.install!
88
- Async.logger.info "Send `kill -USR1 #{Process.pid}` for detailed status :)"
89
-
90
- debug_trap.trap do
91
- task.reactor.print_hierarchy($stderr)
92
- end
93
- end
94
-
95
- server = Falcon::Server.new(app, [
96
- Async::IO::Endpoint.parse(@options[:bind], reuse_port: true)
97
- ])
98
-
99
- server.run
100
- end
101
- end
102
-
103
- def invoke(parent)
104
- container = run(parent.verbose?)
105
-
106
- sleep
107
- end
108
- end
109
-
110
32
  class Top < Samovar::Command
111
33
  self.description = "An asynchronous HTTP client/server toolset."
112
34
 
@@ -0,0 +1,106 @@
1
+ # Copyright, 2017, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ # of this software and associated documentation files (the "Software"), to deal
5
+ # in the Software without restriction, including without limitation the rights
6
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ # copies of the Software, and to permit persons to whom the Software is
8
+ # furnished to do so, subject to the following conditions:
9
+ #
10
+ # The above copyright notice and this permission notice shall be included in
11
+ # all copies or substantial portions of the Software.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ # THE SOFTWARE.
20
+
21
+ require_relative '../server'
22
+ require_relative '../verbose'
23
+
24
+ require 'async/container'
25
+ require 'async/io/trap'
26
+
27
+ require 'samovar'
28
+ require 'etc'
29
+
30
+ require 'rack/builder'
31
+ require 'rack/server'
32
+
33
+ module Falcon
34
+ module Command
35
+ def self.default_concurrency
36
+ Etc.nprocessors
37
+ rescue
38
+ 2
39
+ end
40
+
41
+ class Serve < Samovar::Command
42
+ self.description = "Run an HTTP server."
43
+
44
+ options do
45
+ option '-c/--config <path>', "Rackup configuration file to load", default: 'config.ru'
46
+ option '-n/--concurrency <count>', "Number of processes to start", default: Command.default_concurrency, type: Integer
47
+
48
+ option '-b/--bind <address>', "Bind to the given hostname/address", default: "tcp://localhost:9292"
49
+
50
+ option '--forked | --threaded', "Select a specific concurrency model", key: :container, default: :threaded
51
+ end
52
+
53
+ def container_class
54
+ case @options[:container]
55
+ when :threaded
56
+ require 'async/container/threaded'
57
+ return Async::Container::Threaded
58
+ when :forked
59
+ require 'async/container/forked'
60
+ return Async::Container::Forked
61
+ end
62
+ end
63
+
64
+ def load_app(verbose)
65
+ app, options = Rack::Builder.parse_file(@options[:config])
66
+
67
+ if verbose
68
+ app = Verbose.new(app)
69
+ end
70
+
71
+ return app, options
72
+ end
73
+
74
+ def run(verbose)
75
+ app, options = load_app(verbose)
76
+
77
+ endpoint = Async::IO::Endpoint.parse(@options[:bind], reuse_port: true)
78
+
79
+ Async.logger.info "Falcon taking flight! Binding to #{endpoint} [#{container_class} with concurrency: #{@options[:concurrency]}]"
80
+
81
+ debug_trap = Async::IO::Trap.new(:USR1)
82
+
83
+ container_class.new(concurrency: @options[:concurrency]) do |task|
84
+ task.async do
85
+ debug_trap.install!
86
+ Async.logger.info "Send `kill -USR1 #{Process.pid}` for detailed status :)"
87
+
88
+ debug_trap.trap do
89
+ task.reactor.print_hierarchy($stderr)
90
+ end
91
+ end
92
+
93
+ server = Falcon::Server.new(app, endpoint)
94
+
95
+ server.run
96
+ end
97
+ end
98
+
99
+ def invoke(parent)
100
+ container = run(parent.verbose?)
101
+
102
+ sleep
103
+ end
104
+ end
105
+ end
106
+ end
@@ -19,5 +19,5 @@
19
19
  # THE SOFTWARE.
20
20
 
21
21
  module Falcon
22
- VERSION = "0.7.0"
22
+ VERSION = "0.8.0"
23
23
  end
@@ -6,19 +6,17 @@ require_relative '../../falcon'
6
6
  module Rack
7
7
  module Handler
8
8
  module Falcon
9
- def self.addresses_for(**options)
9
+ def self.endpoint_for(**options)
10
10
  host = options[:Host] || 'localhost'
11
11
  port = Integer(options[:Port] || 9292)
12
12
 
13
- return [
14
- Async::IO::Endpoint.tcp(host, port)
15
- ]
13
+ return Async::IO::Endpoint.tcp(host, port)
16
14
  end
17
15
 
18
16
  def self.run(app, **options)
19
- addresses = addresses_for(**options)
17
+ endpoint = endpoint_for(**options)
20
18
 
21
- server = ::Falcon::Server.new(app, addresses)
19
+ server = ::Falcon::Server.new(app, endpoint)
22
20
 
23
21
  Async::Reactor.run do
24
22
  server.run
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.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-14 00:00:00.000000000 Z
11
+ date: 2018-03-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: async-io
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.3'
19
+ version: '1.5'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.3'
26
+ version: '1.5'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: async-http
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0.3'
33
+ version: '0.8'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0.3'
40
+ version: '0.8'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: async-container
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -157,6 +157,7 @@ files:
157
157
  - falcon.gemspec
158
158
  - lib/falcon.rb
159
159
  - lib/falcon/command.rb
160
+ - lib/falcon/command/serve.rb
160
161
  - lib/falcon/server.rb
161
162
  - lib/falcon/verbose.rb
162
163
  - lib/falcon/version.rb