spree_cm_commissioner 2.8.12 → 2.8.14
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/Gemfile.lock +1 -1
- data/app/controllers/spree/admin/system/waiting_room_controller.rb +7 -0
- data/app/services/spree_cm_commissioner/waiting_room_system_metadata_fetcher.rb +16 -4
- data/app/services/spree_cm_commissioner/waiting_room_system_metadata_setter.rb +14 -1
- data/app/views/spree/admin/system/waiting_room/show.html.erb +5 -0
- data/config/routes.rb +1 -0
- data/lib/spree_cm_commissioner/version.rb +1 -1
- 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: 1c9db9328cb88cf7fde16a7e685701308b1f7b939ed963d7ee589033a1c38a6e
|
|
4
|
+
data.tar.gz: b43d69cdc29b8550301afcc5a01ab8da004261fc4bc4314019525b36d6f8ca27
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: aa15d9ee3abd52045750066949564ce695a44744750f5de0087de5fefedff5dc0117c23a44541da7ba169d995454aa6366008c57776c37198e915e755b866220
|
|
7
|
+
data.tar.gz: db7d35fe794708874feccc997084b00565e42c053963d7bf32fa135be05c625eeff8390ccce4a8e9c747acbd74694fc682a05313e6edb41639678b4fe8fc32c7
|
data/Gemfile.lock
CHANGED
|
@@ -26,6 +26,13 @@ module Spree
|
|
|
26
26
|
redirect_back fallback_location: admin_system_waiting_room_path
|
|
27
27
|
end
|
|
28
28
|
|
|
29
|
+
def modify_max_sessions_count_cap
|
|
30
|
+
modifier = params[:max_sessions_count_cap]&.to_i || 0
|
|
31
|
+
SpreeCmCommissioner::WaitingRoomSystemMetadataSetter.new.modify_max_sessions_count_cap(modifier)
|
|
32
|
+
|
|
33
|
+
redirect_back fallback_location: admin_system_waiting_room_path
|
|
34
|
+
end
|
|
35
|
+
|
|
29
36
|
def force_pull
|
|
30
37
|
SpreeCmCommissioner::WaitingRoomLatestSystemMetadataPullerJob.perform_now
|
|
31
38
|
SpreeCmCommissioner::WaitingGuestsCallerJob.perform_now
|
|
@@ -12,17 +12,24 @@ module SpreeCmCommissioner
|
|
|
12
12
|
@document_data = document.get.data
|
|
13
13
|
end
|
|
14
14
|
|
|
15
|
-
def self.
|
|
16
|
-
|
|
15
|
+
def self.min_sessions_count
|
|
16
|
+
ENV.fetch('WAITING_ROOM_MIN_SESSIONS_COUNT', '5').to_i
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def self.compute_max_sessions_count_with_min(server_running_count:, max_thread_count:, multiplier:, cap:)
|
|
20
|
+
min = min_sessions_count
|
|
17
21
|
max = server_running_count * max_thread_count * multiplier / 100
|
|
18
|
-
|
|
22
|
+
# Cap the auto-scaled value so the system does not scale beyond the configured ceiling,
|
|
23
|
+
# while ensuring the minimum always wins even if the cap is set below it.
|
|
24
|
+
max.clamp(min, [cap, min].max)
|
|
19
25
|
end
|
|
20
26
|
|
|
21
27
|
def max_sessions_count_with_min
|
|
22
28
|
@max_sessions_count_with_min ||= self.class.compute_max_sessions_count_with_min(
|
|
23
29
|
server_running_count: server_running_count,
|
|
24
30
|
max_thread_count: max_thread_count,
|
|
25
|
-
multiplier: multiplier
|
|
31
|
+
multiplier: multiplier,
|
|
32
|
+
cap: max_sessions_count_cap
|
|
26
33
|
)
|
|
27
34
|
end
|
|
28
35
|
|
|
@@ -41,6 +48,11 @@ module SpreeCmCommissioner
|
|
|
41
48
|
document_data[:multiplier]&.to_i || ENV.fetch('WAITING_ROOM_MULTIPLIER', '150').to_i
|
|
42
49
|
end
|
|
43
50
|
|
|
51
|
+
# hard ceiling for max_sessions_count to avoid auto-scaling the system too much
|
|
52
|
+
def max_sessions_count_cap
|
|
53
|
+
document_data[:max_sessions_count_cap]&.to_i || ENV.fetch('WAITING_ROOM_MAX_SESSIONS_COUNT_CAP', '1000').to_i
|
|
54
|
+
end
|
|
55
|
+
|
|
44
56
|
def document
|
|
45
57
|
@document ||= firestore.col('metadata').doc('system')
|
|
46
58
|
end
|
|
@@ -20,6 +20,18 @@ module SpreeCmCommissioner
|
|
|
20
20
|
cache_max_sessions_count(new_data)
|
|
21
21
|
end
|
|
22
22
|
|
|
23
|
+
def modify_max_sessions_count_cap(modify)
|
|
24
|
+
fetcher.load_document_data
|
|
25
|
+
|
|
26
|
+
new_data = fetcher.document_data.dup
|
|
27
|
+
# Floor the cap at the configured minimum; a cap below the min is meaningless
|
|
28
|
+
# since the min always wins in compute_max_sessions_count_with_min.
|
|
29
|
+
new_data[:max_sessions_count_cap] = [fetcher.max_sessions_count_cap + modify, WaitingRoomSystemMetadataFetcher.min_sessions_count].max
|
|
30
|
+
|
|
31
|
+
fetcher.document.set(new_data)
|
|
32
|
+
cache_max_sessions_count(new_data)
|
|
33
|
+
end
|
|
34
|
+
|
|
23
35
|
def set(server_running_count:)
|
|
24
36
|
fetcher.load_document_data
|
|
25
37
|
|
|
@@ -40,7 +52,8 @@ module SpreeCmCommissioner
|
|
|
40
52
|
max = WaitingRoomSystemMetadataFetcher.compute_max_sessions_count_with_min(
|
|
41
53
|
server_running_count: data[:server_running_count]&.to_i || fetcher.server_running_count,
|
|
42
54
|
max_thread_count: data[:max_thread_count]&.to_i || fetcher.max_thread_count,
|
|
43
|
-
multiplier: data[:multiplier]&.to_i || fetcher.multiplier
|
|
55
|
+
multiplier: data[:multiplier]&.to_i || fetcher.multiplier,
|
|
56
|
+
cap: data[:max_sessions_count_cap]&.to_i || fetcher.max_sessions_count_cap
|
|
44
57
|
)
|
|
45
58
|
Rails.cache.write('waiting_room/max_sessions_count', max, expires_in: 1.hour)
|
|
46
59
|
end
|
|
@@ -20,6 +20,11 @@
|
|
|
20
20
|
field_name: :max_sessions,
|
|
21
21
|
value: @fetcher.max_sessions_count_with_min,
|
|
22
22
|
},
|
|
23
|
+
{
|
|
24
|
+
field_name: :max_sessions_count_cap,
|
|
25
|
+
value: @fetcher.max_sessions_count_cap,
|
|
26
|
+
modify_path: modify_max_sessions_count_cap_admin_system_waiting_room_path
|
|
27
|
+
},
|
|
23
28
|
{
|
|
24
29
|
field_name: :active_sesions,
|
|
25
30
|
value: @active_sesions_count,
|
data/config/routes.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: spree_cm_commissioner
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.8.
|
|
4
|
+
version: 2.8.14
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- You
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-06-
|
|
11
|
+
date: 2026-06-22 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: spree
|