zapp 0.2.5 → 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: 5bf3d563ee016ed8dd0c476f3c2b38d941d895e6f6f8a00ecffe91badaf95849
4
- data.tar.gz: 14ec4eacaf29d2b43bf7b4a298fb6177cead5bd854c43810f873dd56359fa91b
3
+ metadata.gz: 6e94e39ad73864691347e3eac33c5e28b4d08e62fdbc18bfa9f1c5fa72000ef3
4
+ data.tar.gz: f78eadb3fe3f7368121082a5d3fc4449de5d39fba61a3ddb6e39f638c6baded9
5
5
  SHA512:
6
- metadata.gz: 5af0557f1bcb1f10c67ca7050adc90c940ad1cd309b66ba90118dbced2216231e2837ccf52cd607a80694fad206ff7c7d22eddc203843d599e8e81aa7d0c639f
7
- data.tar.gz: dd8f8ddb1464df27265384eb9a2aa1ff1a3aa912395bbcec033e0698ebe8b9dd3dafc24cc6b33874fda9aa2ee174d1cf2792d9e01807506777397d277bb59853
6
+ metadata.gz: 625301dd7456472bb96afc272bdff5e5d7295e95b8e6e17bf5a1d91dc82eda8af0d96bd009d42407e957b27a84a6ee49c319a3b1b273dfe8c92bea4c42a9fe82
7
+ data.tar.gz: 43e2b8ad39bc78660d94b5ef1ca09258f8fdf076a6cd571793225e9dd3880831eb50ab8a0c036068220dfe83bb061ce0da08a9ceb2a6244fcba218520e99dde2
data/lib/zapp/pipe.rb CHANGED
@@ -3,6 +3,20 @@
3
3
  module Zapp
4
4
  # Light wrapper around a Ractor for piping messages CSP style
5
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
21
  super do
8
22
  loop do
data/lib/zapp/server.rb CHANGED
@@ -9,8 +9,8 @@ module Zapp
9
9
  # Ensure config.ru file is loaded just once by main ractor
10
10
  Zapp.config.app
11
11
 
12
- @socket_pipe = Zapp::Pipe.new
13
- @context_pipe = Zapp::Pipe.new
12
+ @socket_pipe = Zapp::Pipe.for(TCPSocket)
13
+ @context_pipe = Zapp::Pipe.for(Zapp::HTTPContext::Context, Symbol)
14
14
 
15
15
  @socket_pipe_receiver = Zapp::SocketPipe::Receiver.new(pipe: @socket_pipe)
16
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.5"
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)
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.5
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-12 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