[PATCH crystal-ci] feat: sched: import block_helper

import BlockHelper to Sched. ===demo test code=== 1) add checkfile function at scheduler.cr def self.checkfile File.exists?("/home/chief/0.txt") end 2) add call to block_until_finished # echo alive get "/" do | _ | sched.block_helper.block_until_finished("1") { checkfile } "LKP Alive! The time is #{Time.local}, version = #{VERSION}" end 3) when scheduler is start up at (172.17.0.134:3000), call 3 times curl http://172.17.0.134:3000 - call at different shell - 2 time before create file "/home/chief/0.txt" - 1 time after create file "/home/chief/0.txt" 4) result the first 2 call was blocked. after the 3rd call: 3 curl respond with same message. - LKP Alive! The time is 2020-08-21 03:22:15 UTC, version = 0.2.0 and the scheduler logs shows: - 2020-08-21 03:22:15 UTC 200 GET / 375.36µs - 2020-08-21 03:22:15 UTC 200 GET / 49781.88ms - 2020-08-21 03:22:15 UTC 200 GET / 70282.96ms 1 response in 0.3ms, 1 in 4.9s and 1 in 7s Signed-off-by: Tong Qunfeng <tongqunfeng@huawei.com> --- src/lib/sched.cr | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/lib/sched.cr b/src/lib/sched.cr index faa3553..60e97ba 100644 --- a/src/lib/sched.cr +++ b/src/lib/sched.cr @@ -3,6 +3,7 @@ require "kemal" require "./job" +require "./block_helper" require "./taskqueue_api" require "../scheduler/jobfile_operate" require "../scheduler/redis_client" @@ -12,11 +13,13 @@ class Sched property es property redis + property block_helper def initialize() @es = Elasticsearch::Client.new @redis = Redis::Client.new @task_queue = TaskQueueAPI.new + @block_helper = BlockHelper.new end def normalize_mac(mac : String) -- 2.23.0
participants (1)
-
Tong Qunfeng