zapp 0.1.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 +7 -0
- data/.circleci/config.yml +21 -0
- data/.gitignore +13 -0
- data/.rspec +3 -0
- data/.rubocop.yml +46 -0
- data/.ruby-version +1 -0
- data/Gemfile +13 -0
- data/Gemfile.lock +110 -0
- data/Guardfile +23 -0
- data/LICENSE.txt +21 -0
- data/README.md +91 -0
- data/Rakefile +8 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/bin/zapp +7 -0
- data/examples/rails-app/.browserslistrc +1 -0
- data/examples/rails-app/.gitattributes +10 -0
- data/examples/rails-app/.gitignore +40 -0
- data/examples/rails-app/.ruby-version +1 -0
- data/examples/rails-app/Gemfile +58 -0
- data/examples/rails-app/Gemfile.lock +253 -0
- data/examples/rails-app/Rakefile +8 -0
- data/examples/rails-app/app/assets/config/manifest.js +2 -0
- data/examples/rails-app/app/assets/images/.keep +0 -0
- data/examples/rails-app/app/assets/stylesheets/application.css +15 -0
- data/examples/rails-app/app/channels/application_cable/channel.rb +6 -0
- data/examples/rails-app/app/channels/application_cable/connection.rb +6 -0
- data/examples/rails-app/app/controllers/application_controller.rb +4 -0
- data/examples/rails-app/app/controllers/concerns/.keep +0 -0
- data/examples/rails-app/app/helpers/application_helper.rb +4 -0
- data/examples/rails-app/app/javascript/channels/consumer.js +6 -0
- data/examples/rails-app/app/javascript/channels/index.js +5 -0
- data/examples/rails-app/app/javascript/packs/application.js +13 -0
- data/examples/rails-app/app/jobs/application_job.rb +9 -0
- data/examples/rails-app/app/mailers/application_mailer.rb +6 -0
- data/examples/rails-app/app/models/application_record.rb +5 -0
- data/examples/rails-app/app/models/concerns/.keep +0 -0
- data/examples/rails-app/app/views/layouts/application.html.erb +16 -0
- data/examples/rails-app/app/views/layouts/mailer.html.erb +13 -0
- data/examples/rails-app/app/views/layouts/mailer.text.erb +1 -0
- data/examples/rails-app/babel.config.js +82 -0
- data/examples/rails-app/bin/bundle +118 -0
- data/examples/rails-app/bin/rails +7 -0
- data/examples/rails-app/bin/rake +7 -0
- data/examples/rails-app/bin/setup +38 -0
- data/examples/rails-app/bin/spring +16 -0
- data/examples/rails-app/bin/webpack +21 -0
- data/examples/rails-app/bin/webpack-dev-server +21 -0
- data/examples/rails-app/bin/yarn +19 -0
- data/examples/rails-app/bin/zapp +1 -0
- data/examples/rails-app/config/application.rb +24 -0
- data/examples/rails-app/config/boot.rb +6 -0
- data/examples/rails-app/config/cable.yml +10 -0
- data/examples/rails-app/config/credentials.yml.enc +1 -0
- data/examples/rails-app/config/database.yml +25 -0
- data/examples/rails-app/config/environment.rb +7 -0
- data/examples/rails-app/config/environments/development.rb +78 -0
- data/examples/rails-app/config/environments/production.rb +122 -0
- data/examples/rails-app/config/environments/test.rb +62 -0
- data/examples/rails-app/config/initializers/application_controller_renderer.rb +9 -0
- data/examples/rails-app/config/initializers/assets.rb +16 -0
- data/examples/rails-app/config/initializers/backtrace_silencers.rb +10 -0
- data/examples/rails-app/config/initializers/content_security_policy.rb +31 -0
- data/examples/rails-app/config/initializers/cookies_serializer.rb +7 -0
- data/examples/rails-app/config/initializers/filter_parameter_logging.rb +8 -0
- data/examples/rails-app/config/initializers/inflections.rb +17 -0
- data/examples/rails-app/config/initializers/mime_types.rb +5 -0
- data/examples/rails-app/config/initializers/permissions_policy.rb +12 -0
- data/examples/rails-app/config/initializers/wrap_parameters.rb +16 -0
- data/examples/rails-app/config/locales/en.yml +33 -0
- data/examples/rails-app/config/puma.rb +45 -0
- data/examples/rails-app/config/routes.rb +5 -0
- data/examples/rails-app/config/spring.rb +8 -0
- data/examples/rails-app/config/storage.yml +34 -0
- data/examples/rails-app/config/webpack/development.js +5 -0
- data/examples/rails-app/config/webpack/environment.js +3 -0
- data/examples/rails-app/config/webpack/production.js +5 -0
- data/examples/rails-app/config/webpack/test.js +5 -0
- data/examples/rails-app/config/webpacker.yml +92 -0
- data/examples/rails-app/config/zapp.rb +10 -0
- data/examples/rails-app/config.ru +7 -0
- data/examples/rails-app/db/seeds.rb +8 -0
- data/examples/rails-app/lib/assets/.keep +0 -0
- data/examples/rails-app/lib/tasks/.keep +0 -0
- data/examples/rails-app/log/.keep +0 -0
- data/examples/rails-app/package.json +17 -0
- data/examples/rails-app/postcss.config.js +12 -0
- data/examples/rails-app/public/404.html +67 -0
- data/examples/rails-app/public/422.html +67 -0
- data/examples/rails-app/public/500.html +66 -0
- data/examples/rails-app/public/apple-touch-icon-precomposed.png +0 -0
- data/examples/rails-app/public/apple-touch-icon.png +0 -0
- data/examples/rails-app/public/favicon.ico +0 -0
- data/examples/rails-app/public/robots.txt +1 -0
- data/examples/rails-app/storage/.keep +0 -0
- data/examples/rails-app/test/application_system_test_case.rb +7 -0
- data/examples/rails-app/test/channels/application_cable/connection_test.rb +15 -0
- data/examples/rails-app/test/controllers/.keep +0 -0
- data/examples/rails-app/test/fixtures/files/.keep +0 -0
- data/examples/rails-app/test/helpers/.keep +0 -0
- data/examples/rails-app/test/integration/.keep +0 -0
- data/examples/rails-app/test/mailers/.keep +0 -0
- data/examples/rails-app/test/models/.keep +0 -0
- data/examples/rails-app/test/system/.keep +0 -0
- data/examples/rails-app/test/test_helper.rb +17 -0
- data/examples/rails-app/tmp/.keep +0 -0
- data/examples/rails-app/tmp/pids/.keep +0 -0
- data/examples/rails-app/vendor/.keep +0 -0
- data/examples/rails-app/yarn.lock +6973 -0
- data/lib/rack/handler/zap.rb +16 -0
- data/lib/zapp/cli.rb +45 -0
- data/lib/zapp/configuration.rb +131 -0
- data/lib/zapp/http_context/context.rb +32 -0
- data/lib/zapp/http_context/request.rb +28 -0
- data/lib/zapp/http_context/response.rb +27 -0
- data/lib/zapp/input_stream.rb +51 -0
- data/lib/zapp/logger.rb +63 -0
- data/lib/zapp/parser.rb +14 -0
- data/lib/zapp/server.rb +55 -0
- data/lib/zapp/version.rb +5 -0
- data/lib/zapp/worker.rb +88 -0
- data/lib/zapp/worker_pool.rb +40 -0
- data/lib/zapp.rb +34 -0
- data/zapp.gemspec +42 -0
- metadata +239 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: f666d4681200fdaf226cf78821e61fad6192f61f70bf8db9aa70a6c224a6a1e6
|
|
4
|
+
data.tar.gz: c6c72378e757c93190b5c2e73ec83c87806ba3d13f1bc80670336605be538d7c
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: ce692ed7205e2aa7157bf7180caf8d2c30ed973a394181f340dc456ef220ced24773bfe4cfa2e98a3cd5083e193cefb47b4daa043af9bb682878738e477e8576
|
|
7
|
+
data.tar.gz: 978c754d57a872141d03f8d522c94dab93ee94807cd2a09266cb1b223411b9e6bec0656e92a0750276847375c865755c4fea67547adbd6b1c6c5d16fc16264f5
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
version: 2.1
|
|
2
|
+
|
|
3
|
+
orbs:
|
|
4
|
+
ruby: circleci/ruby@0.1.2
|
|
5
|
+
|
|
6
|
+
jobs:
|
|
7
|
+
test_three_zero_zero:
|
|
8
|
+
docker:
|
|
9
|
+
- image: circleci/ruby:3.0.0
|
|
10
|
+
executor: ruby/default
|
|
11
|
+
steps:
|
|
12
|
+
- checkout
|
|
13
|
+
- ruby/bundle-install
|
|
14
|
+
- run:
|
|
15
|
+
name: RSpec
|
|
16
|
+
command: bundle exec rspec
|
|
17
|
+
|
|
18
|
+
workflows:
|
|
19
|
+
test:
|
|
20
|
+
jobs:
|
|
21
|
+
- test_three_zero_zero
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
AllCops:
|
|
2
|
+
TargetRubyVersion: 3.0.0
|
|
3
|
+
EnabledByDefault: true
|
|
4
|
+
NewCops: enable
|
|
5
|
+
Exclude:
|
|
6
|
+
- examples/**/*
|
|
7
|
+
|
|
8
|
+
Style/DocumentationMethod:
|
|
9
|
+
Enabled: false
|
|
10
|
+
Style/MissingElse:
|
|
11
|
+
Enabled: false
|
|
12
|
+
Style/StringLiterals:
|
|
13
|
+
EnforcedStyle: double_quotes
|
|
14
|
+
Style/Copyright:
|
|
15
|
+
Enabled: false
|
|
16
|
+
Style/ConstantVisibility:
|
|
17
|
+
Enabled: false
|
|
18
|
+
Style/MethodCallWithArgsParentheses:
|
|
19
|
+
IgnoreMacros: false
|
|
20
|
+
Style/MethodCalledOnDoEndBlock:
|
|
21
|
+
Enabled: false
|
|
22
|
+
Style/DisableCopsWithinSourceCodeDirective:
|
|
23
|
+
Enabled: false
|
|
24
|
+
Style/Send:
|
|
25
|
+
Enabled: false
|
|
26
|
+
Style/ClassMethodsDefinitions:
|
|
27
|
+
Enabled: false
|
|
28
|
+
|
|
29
|
+
Lint/ConstantResolution:
|
|
30
|
+
Enabled: false
|
|
31
|
+
|
|
32
|
+
Bundler/GemComment:
|
|
33
|
+
Enabled: false
|
|
34
|
+
|
|
35
|
+
Layout/MultilineAssignmentLayout:
|
|
36
|
+
Enabled: false
|
|
37
|
+
Layout/RedundantLineBreak:
|
|
38
|
+
Enabled: false
|
|
39
|
+
|
|
40
|
+
Metrics/BlockLength:
|
|
41
|
+
Exclude:
|
|
42
|
+
- spec/**/*_spec.rb
|
|
43
|
+
Metrics/MethodLength:
|
|
44
|
+
Max: 25
|
|
45
|
+
Metrics/AbcSize:
|
|
46
|
+
Max: 30
|
data/.ruby-version
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.0.0
|
data/Gemfile
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
source("https://rubygems.org")
|
|
4
|
+
|
|
5
|
+
# Specify your gem's dependencies in zap.gemspec
|
|
6
|
+
gemspec
|
|
7
|
+
|
|
8
|
+
group(:development) do
|
|
9
|
+
gem("guard", "~> 2.18.0")
|
|
10
|
+
gem("guard-rspec", "~> 4.7.3")
|
|
11
|
+
gem("guard-rubocop", "~> 1.5.0")
|
|
12
|
+
gem("simplecov", "~> 0.21.2")
|
|
13
|
+
end
|
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
zapp (0.1.0)
|
|
5
|
+
concurrent-ruby (~> 1.1.9)
|
|
6
|
+
puma (~> 5.5.2)
|
|
7
|
+
rack (~> 2.2.3)
|
|
8
|
+
rake (~> 13.0)
|
|
9
|
+
rspec (~> 3.0)
|
|
10
|
+
|
|
11
|
+
GEM
|
|
12
|
+
remote: https://rubygems.org/
|
|
13
|
+
specs:
|
|
14
|
+
ast (2.4.2)
|
|
15
|
+
coderay (1.1.3)
|
|
16
|
+
concurrent-ruby (1.1.9)
|
|
17
|
+
diff-lcs (1.4.4)
|
|
18
|
+
docile (1.4.0)
|
|
19
|
+
ffi (1.15.4)
|
|
20
|
+
formatador (0.3.0)
|
|
21
|
+
guard (2.18.0)
|
|
22
|
+
formatador (>= 0.2.4)
|
|
23
|
+
listen (>= 2.7, < 4.0)
|
|
24
|
+
lumberjack (>= 1.0.12, < 2.0)
|
|
25
|
+
nenv (~> 0.1)
|
|
26
|
+
notiffany (~> 0.0)
|
|
27
|
+
pry (>= 0.13.0)
|
|
28
|
+
shellany (~> 0.0)
|
|
29
|
+
thor (>= 0.18.1)
|
|
30
|
+
guard-compat (1.2.1)
|
|
31
|
+
guard-rspec (4.7.3)
|
|
32
|
+
guard (~> 2.1)
|
|
33
|
+
guard-compat (~> 1.1)
|
|
34
|
+
rspec (>= 2.99.0, < 4.0)
|
|
35
|
+
guard-rubocop (1.5.0)
|
|
36
|
+
guard (~> 2.0)
|
|
37
|
+
rubocop (< 2.0)
|
|
38
|
+
listen (3.7.0)
|
|
39
|
+
rb-fsevent (~> 0.10, >= 0.10.3)
|
|
40
|
+
rb-inotify (~> 0.9, >= 0.9.10)
|
|
41
|
+
lumberjack (1.2.8)
|
|
42
|
+
method_source (1.0.0)
|
|
43
|
+
nenv (0.3.0)
|
|
44
|
+
nio4r (2.5.8)
|
|
45
|
+
notiffany (0.1.3)
|
|
46
|
+
nenv (~> 0.1)
|
|
47
|
+
shellany (~> 0.0)
|
|
48
|
+
parallel (1.21.0)
|
|
49
|
+
parser (3.0.2.0)
|
|
50
|
+
ast (~> 2.4.1)
|
|
51
|
+
pry (0.14.1)
|
|
52
|
+
coderay (~> 1.1)
|
|
53
|
+
method_source (~> 1.0)
|
|
54
|
+
puma (5.5.2)
|
|
55
|
+
nio4r (~> 2.0)
|
|
56
|
+
rack (2.2.3)
|
|
57
|
+
rainbow (3.0.0)
|
|
58
|
+
rake (13.0.6)
|
|
59
|
+
rb-fsevent (0.11.0)
|
|
60
|
+
rb-inotify (0.10.1)
|
|
61
|
+
ffi (~> 1.0)
|
|
62
|
+
regexp_parser (2.1.1)
|
|
63
|
+
rexml (3.2.5)
|
|
64
|
+
rspec (3.10.0)
|
|
65
|
+
rspec-core (~> 3.10.0)
|
|
66
|
+
rspec-expectations (~> 3.10.0)
|
|
67
|
+
rspec-mocks (~> 3.10.0)
|
|
68
|
+
rspec-core (3.10.1)
|
|
69
|
+
rspec-support (~> 3.10.0)
|
|
70
|
+
rspec-expectations (3.10.1)
|
|
71
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
72
|
+
rspec-support (~> 3.10.0)
|
|
73
|
+
rspec-mocks (3.10.2)
|
|
74
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
75
|
+
rspec-support (~> 3.10.0)
|
|
76
|
+
rspec-support (3.10.3)
|
|
77
|
+
rubocop (1.21.0)
|
|
78
|
+
parallel (~> 1.10)
|
|
79
|
+
parser (>= 3.0.0.0)
|
|
80
|
+
rainbow (>= 2.2.2, < 4.0)
|
|
81
|
+
regexp_parser (>= 1.8, < 3.0)
|
|
82
|
+
rexml
|
|
83
|
+
rubocop-ast (>= 1.9.1, < 2.0)
|
|
84
|
+
ruby-progressbar (~> 1.7)
|
|
85
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
|
86
|
+
rubocop-ast (1.11.0)
|
|
87
|
+
parser (>= 3.0.1.1)
|
|
88
|
+
ruby-progressbar (1.11.0)
|
|
89
|
+
shellany (0.0.1)
|
|
90
|
+
simplecov (0.21.2)
|
|
91
|
+
docile (~> 1.1)
|
|
92
|
+
simplecov-html (~> 0.11)
|
|
93
|
+
simplecov_json_formatter (~> 0.1)
|
|
94
|
+
simplecov-html (0.12.3)
|
|
95
|
+
simplecov_json_formatter (0.1.3)
|
|
96
|
+
thor (1.1.0)
|
|
97
|
+
unicode-display_width (2.1.0)
|
|
98
|
+
|
|
99
|
+
PLATFORMS
|
|
100
|
+
x86_64-linux
|
|
101
|
+
|
|
102
|
+
DEPENDENCIES
|
|
103
|
+
guard (~> 2.18.0)
|
|
104
|
+
guard-rspec (~> 4.7.3)
|
|
105
|
+
guard-rubocop (~> 1.5.0)
|
|
106
|
+
simplecov (~> 0.21.2)
|
|
107
|
+
zapp!
|
|
108
|
+
|
|
109
|
+
BUNDLED WITH
|
|
110
|
+
2.3.0.dev
|
data/Guardfile
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
%w[lib spec].select { |d| Dir.exist?(d) ? d : UI.warning("Directory #{d} does not exist") }
|
|
4
|
+
|
|
5
|
+
guard(:rspec, cmd: "bundle exec rspec --format progress") do
|
|
6
|
+
require("guard/rspec/dsl")
|
|
7
|
+
dsl = Guard::RSpec::Dsl.new(self)
|
|
8
|
+
|
|
9
|
+
# RSpec files
|
|
10
|
+
rspec = dsl.rspec
|
|
11
|
+
watch(rspec.spec_helper) { rspec.spec_dir }
|
|
12
|
+
watch(rspec.spec_support) { rspec.spec_dir }
|
|
13
|
+
watch(rspec.spec_files)
|
|
14
|
+
|
|
15
|
+
# Ruby files
|
|
16
|
+
ruby = dsl.ruby
|
|
17
|
+
dsl.watch_spec_files_for(ruby.lib_files)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
guard(:rubocop) do
|
|
21
|
+
watch(/.+\.rb$/)
|
|
22
|
+
watch(%r{(?:.+/)?\.rubocop(?:_todo)?\.yml$}) { |m| File.dirname(m[0]) }
|
|
23
|
+
end
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 Mathias H Steffensen
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# Zapp
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+
|
|
5
|
+
Zapp is an experimental web server for Rack-based Ruby applications. It is based on the lightning fast [Puma](https://puma.io/) HTTP parser implemented in C,
|
|
6
|
+
and the new parallelism implementation introduced with CRuby 3.0.0, [Ractors](https://github.com/ruby/ruby/blob/master/doc/ractor.md)
|
|
7
|
+
|
|
8
|
+
This is an experimental project as Ractors are very very new and the Ractor API may change at any moment. While I would not recommend using this server in production for that reason,
|
|
9
|
+
if you do decide to do so, pin your ruby version to one of the versions this project is tested against (Currently only version 3.0.0).
|
|
10
|
+
|
|
11
|
+
Why is it named Zapp with 2 p's you may ask? Because Zap with 1 p was taken.
|
|
12
|
+
|
|
13
|
+
Also it's meant to be pretty fast
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
As a stand-alone ruby executable
|
|
18
|
+
```bash
|
|
19
|
+
gem install zapp
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Or using Bundler, add the following to your gemfile
|
|
23
|
+
```ruby
|
|
24
|
+
gem("zapp")
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
And then run
|
|
28
|
+
```bash
|
|
29
|
+
bundle
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Usage
|
|
33
|
+
|
|
34
|
+
The CLI tool is meant to be dead simple, and all configuration should be done through a configuration file.
|
|
35
|
+
By default Zapp will look for a config file located at ./config/zapp.rb from where the command is run.
|
|
36
|
+
To change this you can provide the optional -c flag when running the command.
|
|
37
|
+
|
|
38
|
+
To use a config file at ./configuration/server.rb:
|
|
39
|
+
```bash
|
|
40
|
+
bundle exec zapp -c ./configuration/server.rb
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
An example config file using Zapp's DSL may look like the following
|
|
44
|
+
```ruby
|
|
45
|
+
# frozen_string_literal: true
|
|
46
|
+
|
|
47
|
+
# A simple web server
|
|
48
|
+
class App
|
|
49
|
+
def self.call(_env)
|
|
50
|
+
[200, {}, ["Hello from Zapp"]]
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# Register the app
|
|
55
|
+
app(App)
|
|
56
|
+
|
|
57
|
+
# Launch 2 parallel Zapp workers
|
|
58
|
+
parallelism(2)
|
|
59
|
+
|
|
60
|
+
# Have Zapp be quiet
|
|
61
|
+
# (by default Zapp workers time requests and log when they have been processed)
|
|
62
|
+
log_requests(false)
|
|
63
|
+
|
|
64
|
+
# Let's bind to 0.0.0.0 instead of localhost
|
|
65
|
+
# since we may run the server from a Docker container
|
|
66
|
+
host("0.0.0.0")
|
|
67
|
+
|
|
68
|
+
# Use port 8080 (3000 is the default)
|
|
69
|
+
port(8080)
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Run the app
|
|
73
|
+
```bash
|
|
74
|
+
bundle exec zapp
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Implementation details
|
|
78
|
+
|
|
79
|
+
* Parsing is done in a single thread
|
|
80
|
+
* Puma's HTTP Parser can not be shared between Ractors, and it cannot be copied to a Ractor so parsing can be done in parallel, I have a suspicion this is due to it being a C extension.
|
|
81
|
+
If you have any suggestions for how to implement parallel parsing, please file a PR or an issue.
|
|
82
|
+
* Request processing is done in parallel using the Ractor API
|
|
83
|
+
|
|
84
|
+
## TODO
|
|
85
|
+
|
|
86
|
+
* Add way more tests to all parts of the library
|
|
87
|
+
* Resolve Rails/Ractor compatibility issues
|
|
88
|
+
* Add thread pool per worker
|
|
89
|
+
* Add some benchmarks against Puma, quite interesting to see how Ractors perform
|
|
90
|
+
* PID file support
|
|
91
|
+
* Support for rack_options
|
data/Rakefile
ADDED
data/bin/console
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require("bundler/setup")
|
|
5
|
+
require("zapp")
|
|
6
|
+
|
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
|
9
|
+
|
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
11
|
+
# require "pry"
|
|
12
|
+
# Pry.start
|
|
13
|
+
|
|
14
|
+
require("irb")
|
|
15
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/bin/zapp
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
defaults
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# See https://git-scm.com/docs/gitattributes for more about git attribute files.
|
|
2
|
+
|
|
3
|
+
# Mark the database schema as having been generated.
|
|
4
|
+
db/schema.rb linguist-generated
|
|
5
|
+
|
|
6
|
+
# Mark the yarn lockfile as having been generated.
|
|
7
|
+
yarn.lock linguist-generated
|
|
8
|
+
|
|
9
|
+
# Mark any vendored files as having been vendored.
|
|
10
|
+
vendor/* linguist-vendored
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# See https://help.github.com/articles/ignoring-files for more about ignoring files.
|
|
2
|
+
#
|
|
3
|
+
# If you find yourself ignoring temporary files generated by your text editor
|
|
4
|
+
# or operating system, you probably want to add a global ignore instead:
|
|
5
|
+
# git config --global core.excludesfile '~/.gitignore_global'
|
|
6
|
+
|
|
7
|
+
# Ignore bundler config.
|
|
8
|
+
/.bundle
|
|
9
|
+
|
|
10
|
+
# Ignore the default SQLite database.
|
|
11
|
+
/db/*.sqlite3
|
|
12
|
+
/db/*.sqlite3-*
|
|
13
|
+
|
|
14
|
+
# Ignore all logfiles and tempfiles.
|
|
15
|
+
/log/*
|
|
16
|
+
/tmp/*
|
|
17
|
+
!/log/.keep
|
|
18
|
+
!/tmp/.keep
|
|
19
|
+
|
|
20
|
+
# Ignore pidfiles, but keep the directory.
|
|
21
|
+
/tmp/pids/*
|
|
22
|
+
!/tmp/pids/
|
|
23
|
+
!/tmp/pids/.keep
|
|
24
|
+
|
|
25
|
+
# Ignore uploaded files in development.
|
|
26
|
+
/storage/*
|
|
27
|
+
!/storage/.keep
|
|
28
|
+
|
|
29
|
+
/public/assets
|
|
30
|
+
.byebug_history
|
|
31
|
+
|
|
32
|
+
# Ignore master key for decrypting credentials and more.
|
|
33
|
+
/config/master.key
|
|
34
|
+
|
|
35
|
+
/public/packs
|
|
36
|
+
/public/packs-test
|
|
37
|
+
/node_modules
|
|
38
|
+
/yarn-error.log
|
|
39
|
+
yarn-debug.log*
|
|
40
|
+
.yarn-integrity
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.0.0
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
source("https://rubygems.org")
|
|
4
|
+
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
|
|
5
|
+
|
|
6
|
+
ruby("3.0.0")
|
|
7
|
+
|
|
8
|
+
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails', branch: 'main'
|
|
9
|
+
gem("rails", "~> 6.1.4", ">= 6.1.4.1")
|
|
10
|
+
# Use sqlite3 as the database for Active Record
|
|
11
|
+
gem("sqlite3", "~> 1.4")
|
|
12
|
+
# Use Zapp as the app server
|
|
13
|
+
gem("zapp", path: "../..")
|
|
14
|
+
# Use SCSS for stylesheets
|
|
15
|
+
gem("sass-rails", ">= 6")
|
|
16
|
+
# Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker
|
|
17
|
+
gem("webpacker", "~> 5.0")
|
|
18
|
+
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
|
|
19
|
+
gem("turbolinks", "~> 5")
|
|
20
|
+
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
|
|
21
|
+
gem("jbuilder", "~> 2.7")
|
|
22
|
+
# Use Redis adapter to run Action Cable in production
|
|
23
|
+
# gem 'redis', '~> 4.0'
|
|
24
|
+
# Use Active Model has_secure_password
|
|
25
|
+
# gem 'bcrypt', '~> 3.1.7'
|
|
26
|
+
|
|
27
|
+
# Use Active Storage variant
|
|
28
|
+
# gem 'image_processing', '~> 1.2'
|
|
29
|
+
|
|
30
|
+
# Reduces boot times through caching; required in config/boot.rb
|
|
31
|
+
gem("bootsnap", ">= 1.4.4", require: false)
|
|
32
|
+
|
|
33
|
+
group(:development, :test) do
|
|
34
|
+
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
|
|
35
|
+
gem("byebug", platforms: %i[mri mingw x64_mingw])
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
group(:development) do
|
|
39
|
+
# Access an interactive console on exception pages or by calling 'console' anywhere in the code.
|
|
40
|
+
gem("web-console", ">= 4.1.0")
|
|
41
|
+
# Display performance information such as SQL time and flame graphs for each request in your browser.
|
|
42
|
+
# Can be configured to work on production as well see: https://github.com/MiniProfiler/rack-mini-profiler/blob/master/README.md
|
|
43
|
+
gem("listen", "~> 3.3")
|
|
44
|
+
gem("rack-mini-profiler", "~> 2.0")
|
|
45
|
+
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
|
|
46
|
+
gem("spring")
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
group(:test) do
|
|
50
|
+
# Adds support for Capybara system testing and selenium driver
|
|
51
|
+
gem("capybara", ">= 3.26")
|
|
52
|
+
gem("selenium-webdriver")
|
|
53
|
+
# Easy installation and use of web drivers to run system tests with browsers
|
|
54
|
+
gem("webdrivers")
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
|
|
58
|
+
gem("tzinfo-data", platforms: %i[mingw mswin x64_mingw jruby])
|