|
2 | 2 | using StackExchange.Redis; |
3 | 3 | using System.Collections.Concurrent; |
4 | 4 | using System.Linq.Expressions; |
5 | | -using System.Threading.Tasks; |
6 | 5 | using System.Threading.Tasks.Dataflow; |
7 | 6 |
|
8 | 7 | namespace Core.TaskProcessor; |
@@ -282,7 +281,7 @@ public async Task<bool> FetchAsync() |
282 | 281 | var res = await db.ScriptEvaluateAsync($@" |
283 | 282 | for i, queue in ipairs(KEYS) do |
284 | 283 |
|
285 | | -if string.find(queue, '[fair]') then |
| 284 | +if string.find(queue, '%[fair%]') ~= nil then |
286 | 285 | local tenant = redis.call('hrandfield', queue.."":fairness""); |
287 | 286 |
|
288 | 287 | if tenant then |
@@ -540,7 +539,7 @@ await db.ScriptEvaluateAsync($@" |
540 | 539 | for j, w in ipairs(r) do |
541 | 540 | redis.call('zadd', ""{Prefix("queues")}"", t, v); |
542 | 541 | |
543 | | - if string.find(q, '[fair]') then |
| 542 | + if string.find(q, '%[fair%]') ~= nil then |
544 | 543 | local tenant = redis.call('hget', q..':'..w, 'tenant'); |
545 | 544 | redis.call('hincrby', q..':fairness', tenant); |
546 | 545 | redis.call('lpush', q..':'..tenant, taskId); |
@@ -597,7 +596,7 @@ public async Task<long> RetryDeadTasksAsync(string queue, int? retries = null, l |
597 | 596 | redis.call('hincrby', '{Prefix("batch:")}'..batchId, 'failed', -1) |
598 | 597 | redis.call('hset', '{Prefix("batch:")}'..batchId, 'state', 'go') |
599 | 598 |
|
600 | | - if string.find(KEYS[1], '[fair]') then |
| 599 | + if string.find(KEYS[1], '%[fair%]') ~= nil then |
601 | 600 | local tenant = redis.call('hget', ""{Prefix("task:")}""..taskId, 'tenant'); |
602 | 601 | redis.call('hincrby', KEYS[1]..':fairness', tenant); |
603 | 602 | redis.call('lpush', KEYS[1]..':'..tenant, taskId); |
@@ -853,7 +852,7 @@ private async Task CompleteBatchAsync(TaskContext task, IDatabase db) |
853 | 852 |
|
854 | 853 | redis.call('zadd', ""{Prefix("queues")}"", t, q); |
855 | 854 |
|
856 | | - if string.find(queue, '[fair]') then |
| 855 | + if string.find(queue, '%[fair%]') ~= nil then |
857 | 856 | local tenant = redis.call('hget', '{Prefix("task:")}'..taskId, 'tenant'); |
858 | 857 | redis.call('hincrby', '{Prefix("queue:")}'..q..':fairness', tenant); |
859 | 858 | redis.call('lpush', '{Prefix("queue:")}'..q..':'..tenant, taskId); |
|
0 commit comments