Commit acf66189 authored by 周尚's avatar 周尚

添加注释

parent 3be52cb0
......@@ -9,7 +9,7 @@ local json = loadmod('cjson')
local db_conf = "tk7_dbs.json"
-- 协
-- 协
local tasks = {}
......@@ -327,7 +327,6 @@ local function sdt_sql(db_st)
-- Convert type
shop['op_map_id'] = zx_base:tonumber(shop['op_map_id'])
shop['mer_map_id'] = zx_base:tonumber(shop['mer_map_id'])
shop['shop_map_id'] = zx_base:tonumber(shop['shop_map_id'])
......
......@@ -20,12 +20,15 @@ end
-- 表信息
-- @param table tk_biz 节点机数据库对象
-- table tk_control 总控机数据库对象
-- @param table tk_biz 节点机数据库对象
-- table tk_control 总控机数据库对象
-- table tk_database 数据同步数据库名
-- table tk_table 数据同步表名
-- @return nil
local function sync_sql(tk_biz, tk_control, tk_table, tk_database)
local function sync_sql(tk_biz, tk_control, tk_database, tk_table)
zx_base:log(MODULE, "-----------------------> START[TK_SYNC]")
-- 新建mysql连接
local db, err = mysql:new()
if not db then
......@@ -55,7 +58,6 @@ local function sync_sql(tk_biz, tk_control, tk_table, tk_database)
tk_table,
"20180716000000"
)
local syncs
syncs, err, errcode, sqlstate = db:query(sql)
if not syncs then
......@@ -99,7 +101,6 @@ local function sync_sql(tk_biz, tk_control, tk_table, tk_database)
for i = 1, #syncs do
local sync = syncs[i]
local sql_result = zx_base:sql_concate("duplicate", tk_table, sync)
ok, err, errcode, sqlstate = db:query(sql_result)
if not ok then
zx_base:log(MODULE, "[TK_SYNC]", sql_result)
......@@ -108,12 +109,20 @@ local function sync_sql(tk_biz, tk_control, tk_table, tk_database)
end
end
ngx.say("SUCCESS")
EOF()
end
local function async(tk_biz, tk_control, tk_database, tk_table)
-- 异步运行
-- @param table tk_biz 节点机数据库对象
-- table tk_control 总控机数据库对象
-- table tk_database 数据同步数据库名
-- table tk_table 数据同步表名
-- @return nil
local function async(tk_biz, tk_control, tk_database, tk_table)
local co = coroutine.wrap(
function()
sync_sql(tk_biz, tk_control, tk_database, tk_table)
......@@ -122,6 +131,10 @@ local function async(tk_biz, tk_control, tk_database, tk_table)
table.insert(tasks, co)
end
-- 协程调度
-- @param nil
-- @return nil
local function dispatch()
local i = 1
while true do
......@@ -141,6 +154,10 @@ local function dispatch()
end
end
-- 跑批业务处理
-- @param nil
-- @return nil
function TK_SYNC.run()
local dbs_st = zx_base:db_read(db_conf)
for i = 1, #dbs_st.tk_biz do
......@@ -150,6 +167,10 @@ function TK_SYNC.run()
dispatch()
end
-- 数据同步接口
-- @param nil
-- @return ngx.say
function TK_SYNC.sync()
local dbs_st = zx_base:db_read(db_conf)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment