diff options
author | Natanael Copa <ncopa@alpinelinux.org> | 2018-09-12 19:21:10 +0200 |
---|---|---|
committer | Carlo Landmeter <clandmeter@alpinelinux.org> | 2019-11-11 15:34:55 +0000 |
commit | 58bc96236c25193450624d392955e3b9453e1934 (patch) | |
tree | 399ee0041f633ce968a6f65d87ada6dbf0cce07b | |
parent | 8a555374cb7f7fdeca537a7f38279d11d9e8187c (diff) | |
download | alpine-mirror-status-58bc96236c25193450624d392955e3b9453e1934.tar.bz2 alpine-mirror-status-58bc96236c25193450624d392955e3b9453e1934.tar.xz |
fetch indexes async
-rwxr-xr-x | generate-json.lua | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/generate-json.lua b/generate-json.lua index 0d7fcb9..f8448ba 100755 --- a/generate-json.lua +++ b/generate-json.lua @@ -6,6 +6,7 @@ local json = require("cjson") local utils = require("utils") local conf = require("config") +local cqueues = require("cqueues") ---- -- convert apkindex list to a table @@ -120,15 +121,19 @@ function process_mirrors() local res = {} local mirrors = get_mirrors(utils.read_file(conf.mirrors_yaml)) --local mirrors = json.decode(utils.read_file(conf.mirrors_json)) + local loop = cqueues.new() for idx,mirror in ipairs(mirrors) do - local start_time = os.time() - res[idx] = {} - res[idx].url = mirror - msg(("[%s/%s] Getting indexes from mirror: %s"):format(idx, - #mirrors, mirror)) - res[idx].branch, res[idx].count = check_apkindexes(mirror) - res[idx].duration = os.difftime(os.time(),start_time) + loop:wrap(function() + local start_time = os.time() + res[idx] = {} + res[idx].url = mirror + msg(("[%s/%s] Getting indexes from mirror: %s"):format(idx, + #mirrors, mirror)) + res[idx].branch, res[idx].count = check_apkindexes(mirror) + res[idx].duration = os.difftime(os.time(),start_time) + end) end + loop:loop() return res end |