canvas_sync 0.19.0.beta2 → 0.19.0.beta4
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/canvas_sync/job_batches/pool.rb +12 -6
- data/lib/canvas_sync/job_batches/pool_refill.lua +1 -1
- data/lib/canvas_sync/job_batches/sidekiq/web/views/pool.erb +44 -1
- data/lib/canvas_sync/job_batches/sidekiq/web.rb +2 -0
- data/lib/canvas_sync/version.rb +1 -1
- data/spec/dummy/log/test.log +6519 -0
- data/spec/job_batching/pool_spec.rb +2 -2
- 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: 9aab48735770121e4d641be35d384cd23d80a70ac63843abdf8b294bac6337ef
|
4
|
+
data.tar.gz: 1cc71d419bbcec4aa07b776ccd3d57a0cc895e4742396cd0d7bc12e0b8692f1d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 62846f6d0f2ee0ec5dafbe7d814913addf42c23818693aa68687f60ecc70e2c13e712b8e1d5c352c7b80842f5d9e9a9233d8206a0d750e507e9aef8075b560ba
|
7
|
+
data.tar.gz: dbf8f8aaa94a13d3457790dd1339de9b615cf1d00916ca8c2767950f47aaef136cd9986992866cd46d836d70c77240cf9f144970a453f93d408a147aefad1433
|
@@ -9,6 +9,7 @@ module CanvasSync
|
|
9
9
|
redis_attr :description
|
10
10
|
redis_attr :created_at
|
11
11
|
redis_attr :concurrency, :int
|
12
|
+
redis_attr :complete_count, :int
|
12
13
|
redis_attr :order
|
13
14
|
redis_attr :on_failed_job, :symbol
|
14
15
|
redis_attr :clean_when_empty, :bool
|
@@ -88,7 +89,7 @@ module CanvasSync
|
|
88
89
|
self.order
|
89
90
|
|
90
91
|
activec, pactivec, pendingc, clean_when_empty, keep_open = redis.multi do |r|
|
91
|
-
r.
|
92
|
+
r.hlen("#{redis_key}-active")
|
92
93
|
r.hincrby(redis_key, "_active_count", 0)
|
93
94
|
pending_count(r)
|
94
95
|
r.hget(redis_key, 'clean_when_empty')
|
@@ -103,7 +104,11 @@ module CanvasSync
|
|
103
104
|
end
|
104
105
|
|
105
106
|
def active_count(r = redis)
|
106
|
-
r.
|
107
|
+
r.hlen("#{redis_key}-active") + r.hincrby(redis_key, "_active_count", 0)
|
108
|
+
end
|
109
|
+
|
110
|
+
def active_jobs(r = redis)
|
111
|
+
r.hvals("#{redis_key}-active").map {|desc| JSON.parse(desc) }
|
107
112
|
end
|
108
113
|
|
109
114
|
def pending_count(r = redis)
|
@@ -120,7 +125,8 @@ module CanvasSync
|
|
120
125
|
end
|
121
126
|
|
122
127
|
def job_checked_in(status, options)
|
123
|
-
redis.
|
128
|
+
redis.hdel("#{redis_key}-active", status.bid)
|
129
|
+
redis.hincrby(redis_key, "complete_count", 1)
|
124
130
|
active_count = refill_allotment
|
125
131
|
cleanup_if_empty unless active_count > 0
|
126
132
|
end
|
@@ -150,7 +156,7 @@ module CanvasSync
|
|
150
156
|
|
151
157
|
pending_job_descs = job_descs.dup
|
152
158
|
|
153
|
-
added_jobs =
|
159
|
+
added_jobs = {}
|
154
160
|
failed_to_add_jobs = []
|
155
161
|
add_exception = nil
|
156
162
|
|
@@ -165,7 +171,7 @@ module CanvasSync
|
|
165
171
|
ChainBuilder.enqueue_job(job_desc)
|
166
172
|
end
|
167
173
|
|
168
|
-
added_jobs
|
174
|
+
added_jobs[wbid] = job_json
|
169
175
|
rescue => ex
|
170
176
|
failed_to_add_jobs << job_json
|
171
177
|
add_exception = ex
|
@@ -173,7 +179,7 @@ module CanvasSync
|
|
173
179
|
end
|
174
180
|
|
175
181
|
redis.multi do |r|
|
176
|
-
r.
|
182
|
+
r.mapped_hmset("#{redis_key}-active", added_jobs) if added_jobs.count > 0
|
177
183
|
# Release reserved slots now that we've added the jobs to `-active`
|
178
184
|
r.hincrby(redis_key, "_active_count", -job_descs.count)
|
179
185
|
|
@@ -9,7 +9,7 @@ end
|
|
9
9
|
|
10
10
|
local pool_type = redis.call('HGET', poolkey, "order")
|
11
11
|
local allotment = tonumber(redis.call("HGET", poolkey, "concurrency"))
|
12
|
-
local active = redis.call("
|
12
|
+
local active = redis.call("HLEN", activekey) + (redis.call("HGET", poolkey, "_active_count") or 0)
|
13
13
|
|
14
14
|
local pop_count = allotment - active
|
15
15
|
|
@@ -31,14 +31,57 @@
|
|
31
31
|
<th scope=row><%= t('Pending Tasks') %></td>
|
32
32
|
<td><%= @pool.pending_count %></td>
|
33
33
|
</tr>
|
34
|
+
<tr>
|
35
|
+
<th scope=row><%= t('Returned Tasks') %></td>
|
36
|
+
<td><%= @pool.complete_count %></td>
|
37
|
+
</tr>
|
34
38
|
</tbody>
|
35
39
|
</table>
|
36
40
|
</div>
|
37
41
|
|
42
|
+
<%# Queued/Active Tasks %>
|
43
|
+
<header class="row">
|
44
|
+
<div class="col-sm-5">
|
45
|
+
<h3>
|
46
|
+
<%= t('Queued/Active Tasks') %>
|
47
|
+
</h3>
|
48
|
+
</div>
|
49
|
+
</header>
|
50
|
+
|
51
|
+
<% if @active_tasks.any? %>
|
52
|
+
<div class="table_container">
|
53
|
+
<table class="table table-striped table-bordered table-hover">
|
54
|
+
<thead>
|
55
|
+
<tr>
|
56
|
+
<th><%= t('Wrapper Batch BID') %></th>
|
57
|
+
<th><%= t('Job Class') %></th>
|
58
|
+
<th><%= t('Parameters') %></th>
|
59
|
+
</tr>
|
60
|
+
</thead>
|
61
|
+
|
62
|
+
<% @active_tasks.each do |job_desc| %>
|
63
|
+
<tr>
|
64
|
+
<td><a href="<%= root_path %>batches/<%= job_desc['pool_wrapper_batch'] %>"><%= job_desc['pool_wrapper_batch'] %></a></td>
|
65
|
+
<td><%= job_desc['job'] %></td>
|
66
|
+
<td>
|
67
|
+
<code class="code-wrap">
|
68
|
+
<div class="args-extended">
|
69
|
+
<%= job_desc['args']&.to_json %>
|
70
|
+
<%= job_desc['kwargs']&.to_json %>
|
71
|
+
</div>
|
72
|
+
</code>
|
73
|
+
</td>
|
74
|
+
</tr>
|
75
|
+
<% end %>
|
76
|
+
</table>
|
77
|
+
</div>
|
78
|
+
<% end %>
|
79
|
+
|
80
|
+
<%# Pending Tasks %>
|
38
81
|
<header class="row">
|
39
82
|
<div class="col-sm-5">
|
40
83
|
<h3>
|
41
|
-
<%= t('Tasks') %>
|
84
|
+
<%= t('Pending Tasks') %>
|
42
85
|
</h3>
|
43
86
|
</div>
|
44
87
|
<%
|
@@ -166,6 +166,8 @@ module CanvasSync::JobBatches::Sidekiq
|
|
166
166
|
@pid = params[:pid]
|
167
167
|
@pool = CanvasSync::JobBatches::Pool.new(@pid)
|
168
168
|
|
169
|
+
@active_tasks = @pool.active_jobs
|
170
|
+
|
169
171
|
@count = (params['count'] || 25).to_i
|
170
172
|
@current_jobs_page, @total_jobs_size, @jobs = page("POOLID-#{@pool.pid}-jobs", params['job_page'], @count)
|
171
173
|
@jobs = @jobs.map {|desc, score=nil| JSON.parse(desc)[0] }
|
data/lib/canvas_sync/version.rb
CHANGED