ree_lib 1.0.80 → 1.0.82

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: 851b70d1a532092c336e5ca839f19fda79a40775f1a5cdcb5e422e133d892ad9
4
- data.tar.gz: 88f743a42f5a0e2b91f5b37d137221299f5b9396a32b0e3415b20509803629ab
3
+ metadata.gz: 48c6e5f9340bda88afb575a664461152ec75798bde02b1ad022ba1ce82e185ea
4
+ data.tar.gz: 190ef75078dbd1ebc195250d769f64ae2b12610f3def63b1ce1fdc81ee66d9fb
5
5
  SHA512:
6
- metadata.gz: f39799b8239edd02be3e6a57a232679aa53e986790f4a17dd1bf68ca533d3ff09e05c462d6a8fb8448ae2de521f8e933e8497c639446515e586fa499b0f206d1
7
- data.tar.gz: db291b9035108c00082134201fcb9ac7e84eae431cab108aa82f1125aa2eb5cbf849641df338f1c12ffdecfd3a557b8eb7b3397d151200ed04321eb4b7af664f
6
+ metadata.gz: ec3d696532a730e37b009acfb2d9fdb93258d1550daaa30703c97634e8415f016ffd57b72eae5b4442a88e276042acf98c33d83d6c848d25ae6d9598bb2fddd9
7
+ data.tar.gz: 8e495f67ca4a395345caa4635443533dc4cb3579356812a559b3712c285d8e54caaeb27e7ac5cb0f49d9d2e6563663a8aa031b823c5a2a4ea004bc1a2aa3a48a
data/Gemfile.lock CHANGED
@@ -1,8 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ree_lib (1.0.80)
4
+ ree_lib (1.0.82)
5
5
  binding_of_caller (~> 1.0.0)
6
+ fiber_scheduler (~> 0.13.0)
6
7
  i18n (~> 1.12.0)
7
8
  loofah (~> 2.18.0)
8
9
  oj (~> 3.13.17)
@@ -30,6 +31,7 @@ GEM
30
31
  diff-lcs (1.5.0)
31
32
  faker (3.2.0)
32
33
  i18n (>= 1.8.11, < 2)
34
+ fiber_scheduler (0.13.0)
33
35
  hashdiff (1.0.1)
34
36
  highline (2.0.3)
35
37
  i18n (1.12.0)
@@ -37,10 +39,10 @@ GEM
37
39
  loofah (2.18.0)
38
40
  crass (~> 1.0.2)
39
41
  nokogiri (>= 1.5.9)
42
+ mini_portile2 (2.8.1)
40
43
  msgpack (1.6.0)
41
- nokogiri (1.15.4-x86_64-darwin)
42
- racc (~> 1.4)
43
- nokogiri (1.15.4-x86_64-linux)
44
+ nokogiri (1.13.10)
45
+ mini_portile2 (~> 2.8.0)
44
46
  racc (~> 1.4)
45
47
  oj (3.13.23)
46
48
  pg (1.4.6)
@@ -127,17 +127,19 @@ module ReeDao
127
127
  else
128
128
  threads = associations.instance_exec(assoc_list, &block)
129
129
 
130
- threads[:association_threads].map do |association, assoc_type, assoc_name, __opts, block|
131
- Thread.new do
132
- association.load(assoc_type, assoc_name, **__opts, &block)
130
+ scheduler_proc do
131
+ threads[:association_threads].map do |association, assoc_type, assoc_name, __opts, block|
132
+ task_proc do
133
+ association.load(assoc_type, assoc_name, **__opts, &block)
134
+ end
133
135
  end
134
- end.map(&:join)
135
136
 
136
- threads[:field_threads].map do |association, field_proc|
137
- Thread.new do
138
- association.handle_field(field_proc)
137
+ threads[:field_threads].map do |association, field_proc|
138
+ task_proc do
139
+ association.handle_field(field_proc)
140
+ end
139
141
  end
140
- end.map(&:join)
142
+ end
141
143
  end
142
144
  end
143
145
 
@@ -353,6 +355,22 @@ module ReeDao
353
355
 
354
356
  private
355
357
 
358
+ def task_proc(&proc)
359
+ if Sequel.current.is_a?(Fiber)
360
+ Fiber.schedule &proc
361
+ else
362
+ proc.call
363
+ end
364
+ end
365
+
366
+ def scheduler_proc(&proc)
367
+ if Sequel.current.is_a?(Fiber)
368
+ FiberScheduler &proc
369
+ else
370
+ proc.call
371
+ end
372
+ end
373
+
356
374
  def foreign_key_from_dao(dao)
357
375
  "#{dao.first_source_table.to_s.gsub(/s$/, '')}_id".to_sym
358
376
  end
@@ -64,17 +64,39 @@ class ReeDao::Agg
64
64
  if dao.db.in_transaction? || ReeDao.load_sync_associations_enabled?
65
65
  associations
66
66
  else
67
- associations[:association_threads].map do |association, assoc_type, assoc_name, opts, block|
68
- Thread.new do
69
- association.load(assoc_type, assoc_name, **opts, &block)
67
+ scheduler_proc do
68
+ associations[:association_threads].map do |association, assoc_type, assoc_name, opts, block|
69
+ task_proc do
70
+ association.load(assoc_type, assoc_name, **opts, &block)
71
+ end
70
72
  end
71
- end.map(&:join)
72
73
 
73
- associations[:field_threads].map do |association, field_proc|
74
- Thread.new do
75
- association.handle_field(field_proc)
74
+ associations[:field_threads].map do |association, field_proc|
75
+ task_proc do
76
+ association.handle_field(field_proc)
77
+ end
76
78
  end
77
- end.map(&:join)
79
+ end
80
+ end
81
+ end
82
+
83
+ def task_proc(&proc)
84
+ if Sequel.current.is_a?(Fiber)
85
+ Fiber.schedule do
86
+ proc.call
87
+ end
88
+ else
89
+ proc.call
90
+ end
91
+ end
92
+
93
+ def scheduler_proc(&proc)
94
+ if Sequel.current.is_a?(Fiber)
95
+ FiberScheduler do
96
+ proc.call
97
+ end
98
+ else
99
+ proc.call
78
100
  end
79
101
  end
80
102
  end
@@ -19,7 +19,6 @@ class ReeDao::BuildConnection
19
19
  database_timezone: :utc,
20
20
  application_timezone: :utc,
21
21
  typecast_timezone: :utc,
22
- connection_validation_timeout: 60,
23
22
  single_threaded: false,
24
23
  timeout: 90
25
24
  }.freeze
@@ -27,6 +26,7 @@ class ReeDao::BuildConnection
27
26
  contract(
28
27
  Hash,
29
28
  Ksplat[
29
+ fibered?: Bool,
30
30
  timeout?: Integer,
31
31
  convert_two_digit_years?: Bool,
32
32
  single_threaded?: Bool,
@@ -36,7 +36,6 @@ class ReeDao::BuildConnection
36
36
  database_timezone?: Or[*TIMEZONES],
37
37
  application_timezone?: Or[*TIMEZONES],
38
38
  typecast_timezone?: Or[*TIMEZONES],
39
- connection_validation_timeout?: Integer,
40
39
  logger?: Logger,
41
40
  sql_log_level?: [:fatal, :error, :warn, :info, :debug],
42
41
  ] => Any
@@ -47,7 +46,6 @@ class ReeDao::BuildConnection
47
46
  database_timezone = opts.delete(:database_timezone)
48
47
  application_timezone = opts.delete(:application_timezone)
49
48
  typecast_timezone = opts.delete(:typecast_timezone)
50
- # connection_validation_timeout = opts.delete(:connection_validation_timeout)
51
49
  convert_two_digit_years = opts.delete(:convert_two_digit_years)
52
50
  single_threaded = opts.delete(:single_threaded)
53
51
  datetime_class = opts.delete(:datetime_class)
@@ -63,6 +61,10 @@ class ReeDao::BuildConnection
63
61
 
64
62
  connection = Sequel.connect(conn_opts)
65
63
 
64
+ if opts[:fibered]
65
+ Sequel.extension :fiber_concurrency
66
+ end
67
+
66
68
  if opts[:logger]
67
69
  connection.logger = opts[:logger]
68
70
  end
@@ -84,8 +86,6 @@ class ReeDao::BuildConnection
84
86
  end
85
87
  end
86
88
 
87
- # connection.pool.connection_validation_timeout = connection_validation_timeout if connection_validation_timeout
88
-
89
89
  extensions.each { connection.extension(_1) }
90
90
  connections.add(connection)
91
91
 
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "sequel"
4
+ require "fiber_scheduler"
4
5
 
5
6
  module ReeDao
6
7
  include Ree::PackageDSL
@@ -22,7 +22,7 @@
22
22
  {
23
23
  "arg": "opts",
24
24
  "arg_type": "keyrest",
25
- "type": "Ksplat[:timeout? => Integer, :convert_two_digit_years? => Bool, :single_threaded? => Bool, :extensions? => ArrayOf[Symbol], :datetime_class? => Or[Time, DateTime], :after_connect? => Proc, :database_timezone? => Or[utc, local], :application_timezone? => Or[utc, local], :typecast_timezone? => Or[utc, local], :connection_validation_timeout? => Integer, :logger? => Logger, :sql_log_level? => [fatal, error, warn, info, debug]]"
25
+ "type": "Ksplat[:fibered? => Bool, :timeout? => Integer, :convert_two_digit_years? => Bool, :single_threaded? => Bool, :extensions? => ArrayOf[Symbol], :datetime_class? => Or[Time, DateTime], :after_connect? => Proc, :database_timezone? => Or[utc, local], :application_timezone? => Or[utc, local], :typecast_timezone? => Or[utc, local], :logger? => Logger, :sql_log_level? => [fatal, error, warn, info, debug]]"
26
26
  }
27
27
  ]
28
28
  }
@@ -38,7 +38,7 @@ class ReeStd::RetryOnFail
38
38
  retry_block?: Proc,
39
39
  retry_if?: Proc,
40
40
  ],
41
- Block => nil
41
+ Block => Any
42
42
  )
43
43
  def call(max:, **opts, &block)
44
44
  Retry.new(max: max, **opts).call(&block)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ReeLib
4
- VERSION = "1.0.80"
4
+ VERSION = "1.0.82"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ree_lib
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.80
4
+ version: 1.0.82
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ruslan Gatiyatov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-11-10 00:00:00.000000000 Z
11
+ date: 2023-12-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ree
@@ -122,6 +122,20 @@ dependencies:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
124
  version: 3.1.1
125
+ - !ruby/object:Gem::Dependency
126
+ name: fiber_scheduler
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: 0.13.0
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: 0.13.0
125
139
  - !ruby/object:Gem::Dependency
126
140
  name: rack-test
127
141
  requirement: !ruby/object:Gem::Requirement