tanker-core 4.2.1.alpha.9 → 4.2.1.alpha.11
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 +4 -4
- data/lib/tanker/c_tanker/fork_hook.rb +12 -13
- data/lib/tanker/c_tanker.rb +3 -0
- data/lib/tanker/core/http.rb +13 -5
- data/lib/tanker/core/init.rb +0 -3
- data/lib/tanker/core/version.rb +1 -1
- data/lib/tanker/core.rb +0 -1
- data/vendor/tanker/darwin-aarch64/libctanker.dylib +0 -0
- data/vendor/tanker/darwin-x86_64/libctanker.dylib +0 -0
- data/vendor/tanker/linux-x86_64/libctanker.so +0 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5a394f3a2938307f5dfd39d7741d778694b26f44b0629cf7c63fec5715383c7b
|
4
|
+
data.tar.gz: 7f83bd747cb4a9b3c3dac67f1b6f8a2415d96a1ff6c3dd4cefb049f92987af17
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b8df15ace21b96ac78ea2b75d387bf9526fd6354f9de45321901f55a2739cb6faa306e29e55e6c8d2f9aa4cf21bc2d9ddc74a90669327033159f427c82dfbd66
|
7
|
+
data.tar.gz: 68e521f354f6c3ed1ca6f760803cb0e061d83c10089298d7950af1bc918ff96ec84a79b4a9f74f9ec5e0439e3e5724eb152bcbf4f0b339d2455c8e075afdea18
|
@@ -1,22 +1,21 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'tanker/core'
|
4
|
-
require 'tanker/core/http'
|
5
4
|
|
6
5
|
module Tanker
|
7
|
-
module
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
6
|
+
module CTanker
|
7
|
+
module ForkHook
|
8
|
+
def _fork(*args)
|
9
|
+
CTanker.tanker_before_fork
|
10
|
+
Core.before_fork
|
11
|
+
super
|
12
|
+
ensure
|
13
|
+
CTanker.tanker_after_fork
|
14
|
+
end
|
13
15
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
puts "### PID=#{Process.pid} TANKER-CORE AFTER FORK HOOK"
|
18
|
-
res
|
16
|
+
def self.install
|
17
|
+
Process.singleton_class.prepend(self)
|
18
|
+
end
|
19
19
|
end
|
20
|
-
prepend_features(Process.singleton_class)
|
21
20
|
end
|
22
21
|
end
|
data/lib/tanker/c_tanker.rb
CHANGED
@@ -10,6 +10,7 @@ require_relative 'c_tanker/c_future'
|
|
10
10
|
require_relative 'c_tanker/c_verification'
|
11
11
|
require_relative 'c_tanker/c_verification_method'
|
12
12
|
require_relative 'c_tanker/c_log_record'
|
13
|
+
require_relative 'c_tanker/fork_hook'
|
13
14
|
|
14
15
|
module Tanker
|
15
16
|
module CTanker
|
@@ -98,6 +99,8 @@ module Tanker
|
|
98
99
|
|
99
100
|
blocking_attach_function :tanker_before_fork, [], :void
|
100
101
|
blocking_attach_function :tanker_after_fork, [], :void
|
102
|
+
|
103
|
+
ForkHook.install
|
101
104
|
end
|
102
105
|
|
103
106
|
private_constant :CTanker
|
data/lib/tanker/core/http.rb
CHANGED
@@ -85,7 +85,6 @@ module Tanker
|
|
85
85
|
@queue = nil
|
86
86
|
|
87
87
|
def self.init
|
88
|
-
puts "### PID=#{Process.pid} TANKER-CORE HTTP THREADPOOL INIT"
|
89
88
|
# Queue is a concurrent queue in Ruby
|
90
89
|
@queue = Queue.new
|
91
90
|
@http_thread_pool = THREAD_POOL_SIZE.times do
|
@@ -96,7 +95,6 @@ module Tanker
|
|
96
95
|
end
|
97
96
|
|
98
97
|
def self.thread_loop
|
99
|
-
puts "### PID=#{Process.pid} TANKER-CORE HTTP THREADPOOL WORKER LOOP STARTED"
|
100
98
|
loop do
|
101
99
|
work = @queue.pop
|
102
100
|
work.call
|
@@ -104,16 +102,27 @@ module Tanker
|
|
104
102
|
end
|
105
103
|
|
106
104
|
def self.push(proc)
|
107
|
-
puts "### PID=#{Process.pid} TANKER-CORE HTTP THREADPOOL PUSH"
|
108
105
|
init if @queue.nil?
|
109
106
|
@queue << proc
|
110
107
|
end
|
111
108
|
|
112
109
|
def self.before_fork
|
113
|
-
puts "### PID=#{Process.pid} TANKER-CORE HTTP THREADPOOL BEFORE FORK"
|
114
110
|
@http_thread_pool = nil
|
115
111
|
@queue = nil
|
116
112
|
end
|
113
|
+
|
114
|
+
module ForkHook
|
115
|
+
def _fork(*args)
|
116
|
+
ThreadPool.before_fork
|
117
|
+
super
|
118
|
+
end
|
119
|
+
|
120
|
+
def self.install
|
121
|
+
Process.singleton_class.prepend(self)
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
ForkHook.install
|
117
126
|
end
|
118
127
|
|
119
128
|
class Client
|
@@ -183,7 +192,6 @@ module Tanker
|
|
183
192
|
end
|
184
193
|
|
185
194
|
def send_request(crequest, _cdata)
|
186
|
-
puts "### PID=#{Process.pid} TANKER-CORE HTTP SEND_REQUEST CALLED"
|
187
195
|
request = HttpRequest.new(crequest:)
|
188
196
|
ThreadPool.push(proc do
|
189
197
|
process_request request
|
data/lib/tanker/core/init.rb
CHANGED
@@ -21,15 +21,12 @@ module Tanker
|
|
21
21
|
def self.set_log_handler(&block)
|
22
22
|
@log_handler_set = 1
|
23
23
|
@log_handler = lambda do |clog|
|
24
|
-
puts "### PID=#{Process.pid} TANKER-CORE LOG HANDLER CALLED: #{clog[:message]}"
|
25
24
|
block.call LogRecord.new clog[:category], clog[:level], clog[:file], clog[:line], clog[:message]
|
26
25
|
end
|
27
26
|
CTanker.tanker_set_log_handler @log_handler
|
28
27
|
end
|
29
28
|
|
30
29
|
def initialize(options)
|
31
|
-
puts "### PID=#{Process.pid} TANKER-CORE initialize, about to call CTanker.tanker_init"
|
32
|
-
|
33
30
|
# tanker_init is not called globally to avoid potential logs at global scope
|
34
31
|
# some frameworks like to pre-execute statements at global scope and then fork, this fork can
|
35
32
|
# interact badly with the threads used in the log handler, so never call Tanker at global scope
|
data/lib/tanker/core/version.rb
CHANGED
data/lib/tanker/core.rb
CHANGED
Binary file
|
Binary file
|
Binary file
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tanker-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.2.1.alpha.
|
4
|
+
version: 4.2.1.alpha.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tanker team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-09-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|