zapp 0.2.3 → 0.2.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6376583c1f6aa2986cd05bde3acb428b17e1eda1a7ef5a9e4369f8cc36edbb49
4
- data.tar.gz: d291eb685e58724ec9a0f60805cab4dde979c602eff5666cb566cae894b91d44
3
+ metadata.gz: 6e94e39ad73864691347e3eac33c5e28b4d08e62fdbc18bfa9f1c5fa72000ef3
4
+ data.tar.gz: f78eadb3fe3f7368121082a5d3fc4449de5d39fba61a3ddb6e39f638c6baded9
5
5
  SHA512:
6
- metadata.gz: 83e9d90b28c8bd661609e6f13e0bbb38ee7d96ae22482ac7490aaa1ccd752581770ad6a07963696c296b8c5ab02d3d4eafc748d1e58bce3d02817df9a4fd1f57
7
- data.tar.gz: 1695771a852412c68aee27843d3d74fb2cd081da8897c0d2b09eb4d19a0aedb77f308271d07ca1dc0cc2561885eec046609fb06ef70febb20ea361fa4d19b4e9
6
+ metadata.gz: 625301dd7456472bb96afc272bdff5e5d7295e95b8e6e17bf5a1d91dc82eda8af0d96bd009d42407e957b27a84a6ee49c319a3b1b273dfe8c92bea4c42a9fe82
7
+ data.tar.gz: 43e2b8ad39bc78660d94b5ef1ca09258f8fdf076a6cd571793225e9dd3880831eb50ab8a0c036068220dfe83bb061ce0da08a9ceb2a6244fcba218520e99dde2
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require("webrick")
4
-
5
3
  module Zapp
6
4
  module HTTPContext
7
5
  # Represents an HTTP Request to be processed by a worker
data/lib/zapp/pipe.rb CHANGED
@@ -2,9 +2,23 @@
2
2
 
3
3
  module Zapp
4
4
  # Light wrapper around a Ractor for piping messages CSP style
5
- module Pipe
5
+ class Pipe < Ractor
6
+ def self.for(*klasses, null: true)
7
+ Ractor.new(klasses, null) do |klasses, null|
8
+ loop do
9
+ Ractor.yield(
10
+ Ractor.receive_if do |msg|
11
+ return true if null && msg.nil?
12
+
13
+ klasses.any? { |klass| msg.is_a?(klass) }
14
+ end
15
+ )
16
+ end
17
+ end
18
+ end
19
+
6
20
  def self.new
7
- Ractor.new do
21
+ super do
8
22
  loop do
9
23
  Ractor.yield(Ractor.receive)
10
24
  end
data/lib/zapp/server.rb CHANGED
@@ -6,8 +6,11 @@ module Zapp
6
6
  attr_reader(:worker_pool, :socket_pipe_receiver)
7
7
 
8
8
  def initialize
9
- @socket_pipe = Zapp::Pipe.new
10
- @context_pipe = Zapp::Pipe.new
9
+ # Ensure config.ru file is loaded just once by main ractor
10
+ Zapp.config.app
11
+
12
+ @socket_pipe = Zapp::Pipe.for(TCPSocket)
13
+ @context_pipe = Zapp::Pipe.for(Zapp::HTTPContext::Context, Symbol)
11
14
 
12
15
  @socket_pipe_receiver = Zapp::SocketPipe::Receiver.new(pipe: @socket_pipe)
13
16
 
data/lib/zapp/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Zapp
4
- VERSION = "0.2.3"
4
+ VERSION = "0.2.6"
5
5
  end
@@ -13,11 +13,16 @@ module Zapp
13
13
 
14
14
  def loop
15
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
16
+ if context.is_a?(Symbol)
17
+ if context == Zapp::WorkerPool::SIGNALS[:EXIT]
18
+ Zapp::Logger.trace("Received exit signal, shutting down")
19
+ shutdown
20
+ break
21
+ else
22
+ next
23
+ end
20
24
  end
25
+
21
26
 
22
27
  process = lambda {
23
28
  process(context: context)
data/lib/zapp/worker.rb CHANGED
@@ -15,6 +15,8 @@ module Zapp
15
15
  ) do |context_pipe, socket_pipe, config|
16
16
  Ractor.current[Zapp::RACTOR_CONFIG_KEY] = config
17
17
 
18
+ Zapp.config.app.prepare if Zapp.config.app.respond_to?(:prepare)
19
+
18
20
  processor = Zapp::Worker::RequestProcessor.new(
19
21
  socket_pipe: socket_pipe,
20
22
  context_pipe: context_pipe
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.2.3
4
+ version: 0.2.6
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: 2022-07-11 00:00:00.000000000 Z
11
+ date: 2022-07-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack