zapp 0.1.0 → 0.2.2

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.
Files changed (122) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +5 -0
  3. data/Gemfile.lock +5 -3
  4. data/bin/zapp +1 -2
  5. data/examples/config/app.rb +5 -0
  6. data/examples/config/puma.rb +10 -0
  7. data/examples/config/zapp.rb +13 -0
  8. data/lib/rack/handler/{zap.rb → zapp.rb} +4 -3
  9. data/lib/zapp/cli.rb +5 -0
  10. data/lib/zapp/configuration.rb +10 -2
  11. data/lib/zapp/http_context/context.rb +10 -11
  12. data/lib/zapp/http_context/request.rb +10 -6
  13. data/lib/zapp/http_context/response.rb +10 -5
  14. data/lib/zapp/logger/base.rb +103 -0
  15. data/lib/zapp/logger.rb +21 -47
  16. data/lib/zapp/pipe.rb +14 -0
  17. data/lib/zapp/server.rb +38 -16
  18. data/lib/zapp/socket_pipe/receiver.rb +24 -0
  19. data/lib/zapp/socket_pipe/sender.rb +17 -0
  20. data/lib/zapp/version.rb +1 -1
  21. data/lib/zapp/worker/request_processor.rb +109 -0
  22. data/lib/zapp/worker.rb +18 -69
  23. data/lib/zapp/worker_pool.rb +17 -18
  24. data/lib/zapp.rb +18 -11
  25. data/zapp.gemspec +2 -0
  26. metadata +26 -100
  27. data/bin/console +0 -15
  28. data/bin/setup +0 -8
  29. data/examples/rails-app/.browserslistrc +0 -1
  30. data/examples/rails-app/.gitattributes +0 -10
  31. data/examples/rails-app/.gitignore +0 -40
  32. data/examples/rails-app/.ruby-version +0 -1
  33. data/examples/rails-app/Gemfile +0 -58
  34. data/examples/rails-app/Gemfile.lock +0 -253
  35. data/examples/rails-app/Rakefile +0 -8
  36. data/examples/rails-app/app/assets/config/manifest.js +0 -2
  37. data/examples/rails-app/app/assets/images/.keep +0 -0
  38. data/examples/rails-app/app/assets/stylesheets/application.css +0 -15
  39. data/examples/rails-app/app/channels/application_cable/channel.rb +0 -6
  40. data/examples/rails-app/app/channels/application_cable/connection.rb +0 -6
  41. data/examples/rails-app/app/controllers/application_controller.rb +0 -4
  42. data/examples/rails-app/app/controllers/concerns/.keep +0 -0
  43. data/examples/rails-app/app/helpers/application_helper.rb +0 -4
  44. data/examples/rails-app/app/javascript/channels/consumer.js +0 -6
  45. data/examples/rails-app/app/javascript/channels/index.js +0 -5
  46. data/examples/rails-app/app/javascript/packs/application.js +0 -13
  47. data/examples/rails-app/app/jobs/application_job.rb +0 -9
  48. data/examples/rails-app/app/mailers/application_mailer.rb +0 -6
  49. data/examples/rails-app/app/models/application_record.rb +0 -5
  50. data/examples/rails-app/app/models/concerns/.keep +0 -0
  51. data/examples/rails-app/app/views/layouts/application.html.erb +0 -16
  52. data/examples/rails-app/app/views/layouts/mailer.html.erb +0 -13
  53. data/examples/rails-app/app/views/layouts/mailer.text.erb +0 -1
  54. data/examples/rails-app/babel.config.js +0 -82
  55. data/examples/rails-app/bin/bundle +0 -118
  56. data/examples/rails-app/bin/rails +0 -7
  57. data/examples/rails-app/bin/rake +0 -7
  58. data/examples/rails-app/bin/setup +0 -38
  59. data/examples/rails-app/bin/spring +0 -16
  60. data/examples/rails-app/bin/webpack +0 -21
  61. data/examples/rails-app/bin/webpack-dev-server +0 -21
  62. data/examples/rails-app/bin/yarn +0 -19
  63. data/examples/rails-app/bin/zapp +0 -1
  64. data/examples/rails-app/config/application.rb +0 -24
  65. data/examples/rails-app/config/boot.rb +0 -6
  66. data/examples/rails-app/config/cable.yml +0 -10
  67. data/examples/rails-app/config/credentials.yml.enc +0 -1
  68. data/examples/rails-app/config/database.yml +0 -25
  69. data/examples/rails-app/config/environment.rb +0 -7
  70. data/examples/rails-app/config/environments/development.rb +0 -78
  71. data/examples/rails-app/config/environments/production.rb +0 -122
  72. data/examples/rails-app/config/environments/test.rb +0 -62
  73. data/examples/rails-app/config/initializers/application_controller_renderer.rb +0 -9
  74. data/examples/rails-app/config/initializers/assets.rb +0 -16
  75. data/examples/rails-app/config/initializers/backtrace_silencers.rb +0 -10
  76. data/examples/rails-app/config/initializers/content_security_policy.rb +0 -31
  77. data/examples/rails-app/config/initializers/cookies_serializer.rb +0 -7
  78. data/examples/rails-app/config/initializers/filter_parameter_logging.rb +0 -8
  79. data/examples/rails-app/config/initializers/inflections.rb +0 -17
  80. data/examples/rails-app/config/initializers/mime_types.rb +0 -5
  81. data/examples/rails-app/config/initializers/permissions_policy.rb +0 -12
  82. data/examples/rails-app/config/initializers/wrap_parameters.rb +0 -16
  83. data/examples/rails-app/config/locales/en.yml +0 -33
  84. data/examples/rails-app/config/puma.rb +0 -45
  85. data/examples/rails-app/config/routes.rb +0 -5
  86. data/examples/rails-app/config/spring.rb +0 -8
  87. data/examples/rails-app/config/storage.yml +0 -34
  88. data/examples/rails-app/config/webpack/development.js +0 -5
  89. data/examples/rails-app/config/webpack/environment.js +0 -3
  90. data/examples/rails-app/config/webpack/production.js +0 -5
  91. data/examples/rails-app/config/webpack/test.js +0 -5
  92. data/examples/rails-app/config/webpacker.yml +0 -92
  93. data/examples/rails-app/config/zapp.rb +0 -10
  94. data/examples/rails-app/config.ru +0 -7
  95. data/examples/rails-app/db/seeds.rb +0 -8
  96. data/examples/rails-app/lib/assets/.keep +0 -0
  97. data/examples/rails-app/lib/tasks/.keep +0 -0
  98. data/examples/rails-app/log/.keep +0 -0
  99. data/examples/rails-app/package.json +0 -17
  100. data/examples/rails-app/postcss.config.js +0 -12
  101. data/examples/rails-app/public/404.html +0 -67
  102. data/examples/rails-app/public/422.html +0 -67
  103. data/examples/rails-app/public/500.html +0 -66
  104. data/examples/rails-app/public/apple-touch-icon-precomposed.png +0 -0
  105. data/examples/rails-app/public/apple-touch-icon.png +0 -0
  106. data/examples/rails-app/public/favicon.ico +0 -0
  107. data/examples/rails-app/public/robots.txt +0 -1
  108. data/examples/rails-app/storage/.keep +0 -0
  109. data/examples/rails-app/test/application_system_test_case.rb +0 -7
  110. data/examples/rails-app/test/channels/application_cable/connection_test.rb +0 -15
  111. data/examples/rails-app/test/controllers/.keep +0 -0
  112. data/examples/rails-app/test/fixtures/files/.keep +0 -0
  113. data/examples/rails-app/test/helpers/.keep +0 -0
  114. data/examples/rails-app/test/integration/.keep +0 -0
  115. data/examples/rails-app/test/mailers/.keep +0 -0
  116. data/examples/rails-app/test/models/.keep +0 -0
  117. data/examples/rails-app/test/system/.keep +0 -0
  118. data/examples/rails-app/test/test_helper.rb +0 -17
  119. data/examples/rails-app/tmp/.keep +0 -0
  120. data/examples/rails-app/tmp/pids/.keep +0 -0
  121. data/examples/rails-app/vendor/.keep +0 -0
  122. data/examples/rails-app/yarn.lock +0 -6973
@@ -0,0 +1,109 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Zapp
4
+ class Worker < Ractor
5
+ # Processes HTTP requests
6
+ class RequestProcessor
7
+ attr_reader(:socket_pipe_sender, :context_pipe)
8
+
9
+ def initialize(context_pipe:, socket_pipe:)
10
+ @socket_pipe_sender = Zapp::SocketPipe::Sender.new(pipe: socket_pipe)
11
+ @context_pipe = context_pipe
12
+ end
13
+
14
+ def loop
15
+ while (context = context_pipe.take)
16
+ if context == Zapp::WorkerPool::SIGNALS[:EXIT]
17
+ Zapp::Logger.trace("Received exit signal, shutting down")
18
+ shutdown
19
+ break
20
+ end
21
+
22
+ process = lambda {
23
+ process(context: context)
24
+ }
25
+
26
+ if Zapp.config.log_requests
27
+ log_request_time(context: context, &process)
28
+ else
29
+ process.call
30
+ end
31
+
32
+ # We send sockets that the client hasn't closed yet,
33
+ # back to the main ractor for HTTP request parsing again
34
+ socket_pipe_sender.push(context.socket) unless context.client_closed?
35
+ end
36
+ end
37
+
38
+ private
39
+
40
+ # Processes an HTTP request
41
+ def process(context:)
42
+ env = prepare_env(data: context.req.data, body: context.req.body, env: Zapp.config.env.dup)
43
+
44
+ status, headers, response_body_stream = Zapp.config.app.call(env)
45
+
46
+ response_body = body_stream_to_string(response_body_stream)
47
+
48
+ context.res.write(data: response_body, status: status, headers: headers)
49
+ rescue StandardError => e
50
+ context.res.write(data: "An unexpected error occurred", status: 500, headers: {})
51
+ Zapp::Logger.error("#{e}\n\n#{e.backtrace&.join(",\n")}") if Zapp.config.log_uncaught_errors
52
+ end
53
+
54
+ # Merges HTTP data and body into the env to be passed to the rack app
55
+ def prepare_env(data:, body:, env:)
56
+ data["QUERY_STRING"] = ""
57
+ data["SERVER_NAME"] = data["HTTP_HOST"] || ""
58
+ data["PATH_INFO"] = data["REQUEST_PATH"]
59
+ data["SCRIPT_NAME"] = ""
60
+
61
+ env.update(data)
62
+
63
+ env.update(Rack::RACK_INPUT => body)
64
+
65
+ env
66
+ end
67
+
68
+ def log_request_time(context:)
69
+ start = Time.now.to_f * 1000
70
+
71
+ yield
72
+
73
+ request_time = ((Time.now.to_f * 1000) - start).truncate(2)
74
+ method = context.req.data["REQUEST_METHOD"]
75
+ path = context.req.data["PATH_INFO"]
76
+ status = context.res.status
77
+
78
+ Zapp::Logger.info(
79
+ "#{method} #{path} - Completed in #{request_time}ms with status #{status}"
80
+ )
81
+ end
82
+
83
+ # Loops over a body stream and returns a single string
84
+ def body_stream_to_string(stream)
85
+ response_body = ""
86
+ stream.each do |s|
87
+ response_body += s
88
+ end
89
+
90
+ stream.close if stream.respond_to?(:close)
91
+
92
+ response_body
93
+ end
94
+
95
+ def shutdown
96
+ Zapp::Logger.flush
97
+ thread_pool.shutdown
98
+ end
99
+
100
+ def thread_pool
101
+ @thread_pool ||= Concurrent::ThreadPoolExecutor.new(
102
+ min_threads: Zapp.config.threads_per_worker,
103
+ max_threads: Zapp.config.threads_per_worker,
104
+ max_queue: 1000
105
+ )
106
+ end
107
+ end
108
+ end
109
+ end
data/lib/zapp/worker.rb CHANGED
@@ -1,87 +1,36 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative("worker/request_processor")
4
+
3
5
  module Zapp
4
6
  # One worker processing requests in parallel
5
7
  class Worker < Ractor
6
8
  class << self
7
- def new(pipe_:, app_:, index:)
8
- # Logger with the name as prefix
9
- logger_ = Zapp.config.logger_class.new do |logger|
10
- logger.prefix = name(index)
11
- end
12
-
13
- super(pipe_, app_, logger_, Zapp.config.dup, name: name(index)) do |pipe, app, logger, config|
14
- logger.level = 0
15
- while (context, shutdown = pipe.take)
16
- break if shutdown
17
-
18
- if config.log_requests
19
- Zapp::Worker.log_request_time(logger: logger) do
20
- Zapp::Worker.process(context: context, app: app, logger: logger, config: config)
21
- end
22
- else
23
- Zapp::Worker.process(context: context, app: app, logger: logger, config: config)
24
- end
25
- end
9
+ def new(context_pipe:, socket_pipe:, index:)
10
+ super(
11
+ context_pipe,
12
+ socket_pipe,
13
+ Zapp.config.dup,
14
+ name: name(index)
15
+ ) do |context_pipe, socket_pipe, config|
16
+ Ractor.current[Zapp::RACTOR_CONFIG_KEY] = config
17
+
18
+ processor = Zapp::Worker::RequestProcessor.new(
19
+ socket_pipe: socket_pipe,
20
+ context_pipe: context_pipe
21
+ )
22
+
23
+ processor.loop
26
24
  end
27
25
  end
28
26
 
29
- # Processes an HTTP request
30
- def process(context:, app:, logger:, config:)
31
- prepare_env(data: context.req.data, body: context.req.body, env: config.env)
32
-
33
- status, headers, response_body_stream = app.call(config.env)
34
-
35
- response_body = body_stream_to_string(response_body_stream)
36
-
37
- context.res.write(data: response_body, status: status, headers: headers)
38
- rescue StandardError => e
39
- context.res.write(data: "An unexpected error occurred", status: 500, headers: {})
40
- logger.error("#{e}\n\n#{e.backtrace&.join(",\n")}") if config.log_uncaught_errors
41
- ensure
42
- context.close
43
- end
44
-
45
- def log_request_time(logger:)
46
- start = Time.now.to_f * 1000
47
-
48
- yield
49
- ensure
50
- logger.info("Processed request in #{((Time.now.to_f * 1000) - start).truncate(2)}ms")
51
- end
52
-
53
- # Loops over a body stream and returns a single string
54
- def body_stream_to_string(stream)
55
- response_body = ""
56
- stream.each do |s|
57
- response_body += s
58
- end
59
-
60
- stream.close if stream.respond_to?(:close)
61
-
62
- response_body
63
- end
64
-
65
- # Merges HTTP data and body into the env to be passed to the rack app
66
- def prepare_env(data:, body:, env:)
67
- data["QUERY_STRING"] = ""
68
- data["SERVER_NAME"] = data["HTTP_HOST"] || ""
69
- data["PATH_INFO"] = data["REQUEST_PATH"]
70
- data["SCRIPT_NAME"] = ""
71
-
72
- env.update(data)
73
-
74
- env.update(Rack::RACK_INPUT => body)
75
- end
76
-
77
27
  # Index based name of the worker
78
28
  def name(index)
79
- "zap-http-#{index + 1}"
29
+ "zapp-http-#{index + 1}"
80
30
  end
81
31
  end
82
32
 
83
33
  def terminate
84
- Zapp::Logger.debug("Terminating worker #{name}")
85
34
  take
86
35
  end
87
36
  end
@@ -3,38 +3,37 @@
3
3
  module Zapp
4
4
  # Manages and dispatches work to a pool of Zap::Worker's
5
5
  class WorkerPool
6
- attr_reader(:pipe, :workers, :parallelism)
6
+ attr_reader(:context_pipe, :workers, :parallelism)
7
7
 
8
- def initialize(app:)
9
- @pipe = Ractor.new do
10
- loop do
11
- Ractor.yield(Ractor.receive)
12
- end
13
- end
8
+ SIGNALS = {
9
+ EXIT: :exit
10
+ }.freeze
14
11
 
12
+ def initialize(context_pipe:, socket_pipe:)
13
+ @context_pipe = context_pipe
15
14
  @workers = []
16
15
  Zapp.config.parallelism.times do |i|
17
16
  @workers << Worker.new(
18
- pipe_: pipe,
19
- app_: app,
17
+ context_pipe: context_pipe,
18
+ socket_pipe: socket_pipe,
20
19
  index: i
21
20
  )
22
21
  end
23
22
  end
24
23
 
25
- # Sends data through the pipe to one of our workers,
26
- # sends a tuple of [context, shutdown], if shutdown is true it breaks from its processing loop
27
- # otherwise the worker processes the HTTP context
28
- def process(context:, shutdown: false)
29
- pipe.send([context.dup, shutdown], move: true)
24
+ # Sends a socket to one of our workers
25
+ def process(context:)
26
+ context_pipe.send(context)
30
27
  end
31
28
 
32
29
  # Finishes processing of all requests and shuts down workers
33
30
  def drain
34
- Zapp.config.parallelism.times { process(context: nil, shutdown: true) }
35
- workers.map(&:terminate)
36
- rescue Ractor::RemoteError
37
- # Ignored
31
+ Zapp.config.parallelism.times { process(context: SIGNALS[:EXIT]) }
32
+ workers.map do |w|
33
+ w.terminate
34
+ rescue Ractor::ClosedError
35
+ # Ractor has already exited
36
+ end
38
37
  end
39
38
  end
40
39
  end
data/lib/zapp.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # External dependencies are loaded here
4
+ require("irb")
4
5
  require("socket")
5
6
  require("concurrent")
6
7
  require("puma")
@@ -10,11 +11,14 @@ require("rack")
10
11
  module Zapp
11
12
  class ZappError < StandardError; end
12
13
 
14
+ # The hash key in Ractor.current that stores the global Zapp::Configuration instance
15
+ RACTOR_CONFIG_KEY = "ZAPP_CONFIG"
16
+
13
17
  class << self
14
18
  def config(reset: false)
15
- @config = Zapp::Configuration.new if reset
19
+ Ractor.current[RACTOR_CONFIG_KEY] = Zapp::Configuration.new if reset
16
20
 
17
- @config ||= Zapp::Configuration.new
21
+ Ractor.current[RACTOR_CONFIG_KEY] ||= Zapp::Configuration.new
18
22
  end
19
23
 
20
24
  def configure
@@ -23,12 +27,15 @@ module Zapp
23
27
  end
24
28
  end
25
29
 
26
- require("zapp/version")
27
- require("zapp/logger")
28
- require("zapp/configuration")
29
- require("zapp/input_stream")
30
- require("zapp/http_context/context")
31
- require("zapp/worker")
32
- require("zapp/worker_pool")
33
- require("zapp/server")
34
- require("zapp/cli")
30
+ require_relative("zapp/version")
31
+ require_relative("zapp/logger")
32
+ require_relative("zapp/configuration")
33
+ require_relative("zapp/input_stream")
34
+ require_relative("zapp/http_context/context")
35
+ require_relative("zapp/pipe")
36
+ require_relative("zapp/socket_pipe/sender")
37
+ require_relative("zapp/socket_pipe/receiver")
38
+ require_relative("zapp/worker")
39
+ require_relative("zapp/worker_pool")
40
+ require_relative("zapp/server")
41
+ require_relative("zapp/cli")
data/zapp.gemspec CHANGED
@@ -31,6 +31,8 @@ Gem::Specification.new do |spec|
31
31
  # Use Puma's C-based HttpParser, it's fast as hell
32
32
  spec.add_dependency("puma", "~> 5.5.2")
33
33
 
34
+ spec.add_dependency("webrick")
35
+
34
36
  # Concurrent ruby for managing Thread pools
35
37
  spec.add_dependency("concurrent-ruby", "~> 1.1.9")
36
38
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zapp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mathias H Steffensen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-11-21 00:00:00.000000000 Z
11
+ date: 2022-07-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: 5.5.2
41
+ - !ruby/object:Gem::Dependency
42
+ name: webrick
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: concurrent-ruby
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -98,104 +112,11 @@ files:
98
112
  - LICENSE.txt
99
113
  - README.md
100
114
  - Rakefile
101
- - bin/console
102
- - bin/setup
103
115
  - bin/zapp
104
- - examples/rails-app/.browserslistrc
105
- - examples/rails-app/.gitattributes
106
- - examples/rails-app/.gitignore
107
- - examples/rails-app/.ruby-version
108
- - examples/rails-app/Gemfile
109
- - examples/rails-app/Gemfile.lock
110
- - examples/rails-app/Rakefile
111
- - examples/rails-app/app/assets/config/manifest.js
112
- - examples/rails-app/app/assets/images/.keep
113
- - examples/rails-app/app/assets/stylesheets/application.css
114
- - examples/rails-app/app/channels/application_cable/channel.rb
115
- - examples/rails-app/app/channels/application_cable/connection.rb
116
- - examples/rails-app/app/controllers/application_controller.rb
117
- - examples/rails-app/app/controllers/concerns/.keep
118
- - examples/rails-app/app/helpers/application_helper.rb
119
- - examples/rails-app/app/javascript/channels/consumer.js
120
- - examples/rails-app/app/javascript/channels/index.js
121
- - examples/rails-app/app/javascript/packs/application.js
122
- - examples/rails-app/app/jobs/application_job.rb
123
- - examples/rails-app/app/mailers/application_mailer.rb
124
- - examples/rails-app/app/models/application_record.rb
125
- - examples/rails-app/app/models/concerns/.keep
126
- - examples/rails-app/app/views/layouts/application.html.erb
127
- - examples/rails-app/app/views/layouts/mailer.html.erb
128
- - examples/rails-app/app/views/layouts/mailer.text.erb
129
- - examples/rails-app/babel.config.js
130
- - examples/rails-app/bin/bundle
131
- - examples/rails-app/bin/rails
132
- - examples/rails-app/bin/rake
133
- - examples/rails-app/bin/setup
134
- - examples/rails-app/bin/spring
135
- - examples/rails-app/bin/webpack
136
- - examples/rails-app/bin/webpack-dev-server
137
- - examples/rails-app/bin/yarn
138
- - examples/rails-app/bin/zapp
139
- - examples/rails-app/config.ru
140
- - examples/rails-app/config/application.rb
141
- - examples/rails-app/config/boot.rb
142
- - examples/rails-app/config/cable.yml
143
- - examples/rails-app/config/credentials.yml.enc
144
- - examples/rails-app/config/database.yml
145
- - examples/rails-app/config/environment.rb
146
- - examples/rails-app/config/environments/development.rb
147
- - examples/rails-app/config/environments/production.rb
148
- - examples/rails-app/config/environments/test.rb
149
- - examples/rails-app/config/initializers/application_controller_renderer.rb
150
- - examples/rails-app/config/initializers/assets.rb
151
- - examples/rails-app/config/initializers/backtrace_silencers.rb
152
- - examples/rails-app/config/initializers/content_security_policy.rb
153
- - examples/rails-app/config/initializers/cookies_serializer.rb
154
- - examples/rails-app/config/initializers/filter_parameter_logging.rb
155
- - examples/rails-app/config/initializers/inflections.rb
156
- - examples/rails-app/config/initializers/mime_types.rb
157
- - examples/rails-app/config/initializers/permissions_policy.rb
158
- - examples/rails-app/config/initializers/wrap_parameters.rb
159
- - examples/rails-app/config/locales/en.yml
160
- - examples/rails-app/config/puma.rb
161
- - examples/rails-app/config/routes.rb
162
- - examples/rails-app/config/spring.rb
163
- - examples/rails-app/config/storage.yml
164
- - examples/rails-app/config/webpack/development.js
165
- - examples/rails-app/config/webpack/environment.js
166
- - examples/rails-app/config/webpack/production.js
167
- - examples/rails-app/config/webpack/test.js
168
- - examples/rails-app/config/webpacker.yml
169
- - examples/rails-app/config/zapp.rb
170
- - examples/rails-app/db/seeds.rb
171
- - examples/rails-app/lib/assets/.keep
172
- - examples/rails-app/lib/tasks/.keep
173
- - examples/rails-app/log/.keep
174
- - examples/rails-app/package.json
175
- - examples/rails-app/postcss.config.js
176
- - examples/rails-app/public/404.html
177
- - examples/rails-app/public/422.html
178
- - examples/rails-app/public/500.html
179
- - examples/rails-app/public/apple-touch-icon-precomposed.png
180
- - examples/rails-app/public/apple-touch-icon.png
181
- - examples/rails-app/public/favicon.ico
182
- - examples/rails-app/public/robots.txt
183
- - examples/rails-app/storage/.keep
184
- - examples/rails-app/test/application_system_test_case.rb
185
- - examples/rails-app/test/channels/application_cable/connection_test.rb
186
- - examples/rails-app/test/controllers/.keep
187
- - examples/rails-app/test/fixtures/files/.keep
188
- - examples/rails-app/test/helpers/.keep
189
- - examples/rails-app/test/integration/.keep
190
- - examples/rails-app/test/mailers/.keep
191
- - examples/rails-app/test/models/.keep
192
- - examples/rails-app/test/system/.keep
193
- - examples/rails-app/test/test_helper.rb
194
- - examples/rails-app/tmp/.keep
195
- - examples/rails-app/tmp/pids/.keep
196
- - examples/rails-app/vendor/.keep
197
- - examples/rails-app/yarn.lock
198
- - lib/rack/handler/zap.rb
116
+ - examples/config/app.rb
117
+ - examples/config/puma.rb
118
+ - examples/config/zapp.rb
119
+ - lib/rack/handler/zapp.rb
199
120
  - lib/zapp.rb
200
121
  - lib/zapp/cli.rb
201
122
  - lib/zapp/configuration.rb
@@ -204,10 +125,15 @@ files:
204
125
  - lib/zapp/http_context/response.rb
205
126
  - lib/zapp/input_stream.rb
206
127
  - lib/zapp/logger.rb
128
+ - lib/zapp/logger/base.rb
207
129
  - lib/zapp/parser.rb
130
+ - lib/zapp/pipe.rb
208
131
  - lib/zapp/server.rb
132
+ - lib/zapp/socket_pipe/receiver.rb
133
+ - lib/zapp/socket_pipe/sender.rb
209
134
  - lib/zapp/version.rb
210
135
  - lib/zapp/worker.rb
136
+ - lib/zapp/worker/request_processor.rb
211
137
  - lib/zapp/worker_pool.rb
212
138
  - zapp.gemspec
213
139
  homepage: https://github.com/mathiashsteffensen/zapp
@@ -232,7 +158,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
232
158
  - !ruby/object:Gem::Version
233
159
  version: '0'
234
160
  requirements: []
235
- rubygems_version: 3.3.0.dev
161
+ rubygems_version: 3.2.3
236
162
  signing_key:
237
163
  specification_version: 4
238
164
  summary: A Web Server based on Ractors, for Rack-based Ruby applications
data/bin/console DELETED
@@ -1,15 +0,0 @@
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 DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here
@@ -1 +0,0 @@
1
- defaults
@@ -1,10 +0,0 @@
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
@@ -1,40 +0,0 @@
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
@@ -1 +0,0 @@
1
- 3.0.0
@@ -1,58 +0,0 @@
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])