tp2 0.12.2 → 0.12.3.1

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: 0a6c5182e2812a0c3752fff1e8b0bf694d8cf99979e106a1594e710eba1339d4
4
- data.tar.gz: a3d7456e36e6aa4783bc6f18c27acd11ce807029c253bd7d54cfd2599d6d89e8
3
+ metadata.gz: d6e848dd7ab2f886c616d6e810cd49c2455fd2a07fd713a4520a0b36e47a6f75
4
+ data.tar.gz: da07a4c51e6e1daa876ec2fe5f4f2b38fe38c0aa97e4232f00f9746742743808
5
5
  SHA512:
6
- metadata.gz: ad1afb037882c70c64f84c92d45393517d2e6e4bf3a3c487fdcf65330ee867ec9e20c87bbef18a4d6325244289bfa2fa3a80836c2ff4020eab4a1c141265a802
7
- data.tar.gz: 35649e0932b66fc2592a2fb7bd56ef8ee554176b26e134ac253b573ec15d4c2b7888352241f9a184db0f2776102cedceb7a1a8338759a73c8b38646266bd4a13
6
+ metadata.gz: c46797d8149f470b284e0b8a917e0098f35099dd2d4540d115162cbaaeca3fb9e6926115d3e0798e6fe330a37f901b6ac465bab5953b58b689ed5c91c10cb0e7
7
+ data.tar.gz: b4512a4662394b7af833e272ed1d9c63bc1ddb1dd44a1c2f354a4d381935fbce8423f9e9558f663113fdb667687bff1acf90dfb58404e06ae1129b9a10ff642b
data/.rubocop.yml CHANGED
@@ -61,10 +61,8 @@ Layout/HashAlignment:
61
61
  EnforcedColonStyle: table
62
62
  EnforcedHashRocketStyle: table
63
63
 
64
- # Naming/AccessorMethodName:
65
- # Exclude:
66
- # - lib/polyphony/extensions/fiber.rb
67
- # - examples/**/*.rb
64
+ Naming/AccessorMethodName:
65
+ Enabled: false
68
66
 
69
67
  # Naming/MethodName:
70
68
  # Exclude:
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ # Version 0.12.3 2025-06-25
2
+
3
+ - Fix logging of simple strings
4
+
1
5
  # Version 0.12.2 2025-06-24
2
6
 
3
7
  - Make banner pluggable
data/bin/tp2 CHANGED
@@ -92,4 +92,7 @@ end
92
92
  detect_app(opts) if !opts[:app_type]
93
93
 
94
94
  RubyVM::YJIT.enable rescue nil
95
+
96
+ opts[:machine] = UM.new
97
+ opts[:logger] = opts[:logger] && TP2::Logger.new(opts[:machine], **opts)
95
98
  TP2.run(opts)
data/lib/tp2/logger.rb CHANGED
@@ -17,14 +17,25 @@ module TP2
17
17
  @machine.write_async(@fd, str)
18
18
  end
19
19
 
20
- def call(request, _response_headers)
21
- if request.is_a?(Exception)
22
- e = request
23
- log("Error: #{e.inspect}: #{e.backtrace.inspect}")
24
- return
20
+ def call(o, _response_headers = nil)
21
+ log(format_log_line(o))
22
+ end
23
+
24
+ def format_log_line(o)
25
+ case o
26
+ when Exception
27
+ format_error_log_line(o)
28
+ when Qeweney::Request
29
+ format_request_log_line(o)
30
+ when String
31
+ o
32
+ else
33
+ o.to_s
25
34
  end
35
+ end
26
36
 
27
- log(format_request_log_line(request))
37
+ def format_error_log_line(err)
38
+ "Error: #{err.inspect}: #{err.backtrace.inspect}"
28
39
  end
29
40
 
30
41
  def format_request_log_line(request)
data/lib/tp2/server.rb CHANGED
@@ -10,14 +10,14 @@ module TP2
10
10
  PENDING_REQUESTS_TIMEOUT_PERIOD = 5
11
11
 
12
12
  def self.rack_app(opts)
13
- raise "Missing app location" if !opts[:app_location]
13
+ raise 'Missing app location' if !opts[:app_location]
14
14
 
15
15
  TP2::RackAdapter.load(opts[:app_location])
16
16
  end
17
17
 
18
- def self.tp2_app(machine, opts)
18
+ def self.tp2_app(_machine, opts)
19
19
  if opts[:app_location]
20
- opts[:log]&.log("Loading app at #{opts[:app_location]}")
20
+ opts[:logger]&.call("Loading app at #{opts[:app_location]}")
21
21
  require opts[:app_location]
22
22
 
23
23
  opts.merge!(TP2.config)
@@ -25,9 +25,7 @@ module TP2
25
25
  opts[:app]
26
26
  end
27
27
 
28
- def self.static_app(opts)
29
- end
30
-
28
+ def self.static_app(opts); end
31
29
 
32
30
  def initialize(machine, opts, &app)
33
31
  @machine = machine
@@ -49,7 +47,7 @@ module TP2
49
47
  raise "Invalid app type #{@opts[:app_type].inspect}"
50
48
  end
51
49
  end
52
-
50
+
53
51
  def run
54
52
  setup
55
53
  @machine.join(*@accept_fibers)
@@ -66,9 +64,9 @@ module TP2
66
64
  @server_fds << fd
67
65
  @accept_fibers << @machine.spin { accept_incoming(fd) }
68
66
  end
69
- bind_string = bind_info.map { it.join(':') }.join(", ")
70
- @opts[:log]&.log("Listening on #{bind_string}")
71
-
67
+ bind_string = bind_info.map { it.join(':') }.join(', ')
68
+ @opts[:logger]&.call("Listening on #{bind_string}")
69
+
72
70
  # map fibers
73
71
  @connection_fiber_map = {}
74
72
  end
@@ -123,7 +121,7 @@ module TP2
123
121
  end
124
122
 
125
123
  def graceful_shutdown
126
- @opts[:log]&.log("Shutting down gracefully...")
124
+ @opts[:logger]&.call('Shutting down gracefully...')
127
125
 
128
126
  # stop listening
129
127
  close_all_server_fds
@@ -142,7 +140,7 @@ module TP2
142
140
 
143
141
  @machine.timeout(PENDING_REQUESTS_TIMEOUT_PERIOD, UM::Terminate) do
144
142
  @machine.join(*@connection_fiber_map.keys)
145
- rescue UM::Terminate
143
+ rescue UM::Terminate
146
144
  # timeout on waiting for adapters to finish running, do nothing
147
145
  end
148
146
  end
data/lib/tp2/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module TP2
2
- VERSION = '0.12.2'
2
+ VERSION = '0.12.3.1'
3
3
  end
data/lib/tp2.rb CHANGED
@@ -35,9 +35,7 @@ module TP2
35
35
  begin
36
36
  @in_run = true
37
37
  machine = opts[:machine] || UM.new
38
-
39
38
  machine.puts(opts[:banner]) if opts[:banner]
40
- opts[:logger] = opts[:logger] && TP2::Logger.new(machine, **opts)
41
39
 
42
40
  server = Server.new(machine, opts, &app)
43
41
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tp2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.2
4
+ version: 0.12.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sharon Rosner