Skip to content

Commit

Permalink
svc clean
Browse files Browse the repository at this point in the history
  • Loading branch information
chronolaw committed Oct 27, 2023
1 parent dff4dbb commit e7e20df
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 deletions.
12 changes: 7 additions & 5 deletions kong/clustering/control_plane/rpc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@ function _M.new(clustering)

-- last push config
locks = assert(lrucache.new(4)),
}

-- init rpc services
self.ping_svc = ping_svc.new()
self.ping_svc:init()
-- rpc services
ping_svc = ping_svc.new()
}

-- init rpc cp side
local cp = rpc_cp.new({ "kong.test.v1", })
Expand Down Expand Up @@ -74,7 +73,10 @@ function _M:init_worker(basic_info)
self.filters = basic_info.filters
--]]

-- invoke rpc call
-- init rpc services
self.ping_svc:init_worker()

-- event to invoke rpc call
events.clustering_push_config(function()
local key = "last_push_config"
local delay = self.conf.db_update_frequency
Expand Down
2 changes: 1 addition & 1 deletion kong/clustering/control_plane/services/ping.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function _M.new()
end


function _M:init()
function _M:init_worker()
callbacks.register("kong.test.v1.ping", function(params)
ngx.log(ngx.ERR, "xxx ping received: ", params.msg)
return { msg = "pong for " .. params.msg }
Expand Down
10 changes: 7 additions & 3 deletions kong/clustering/data_plane/rpc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ function _M.new(clustering)
conf = conf,
cert = clustering.cert,
cert_key = clustering.cert_key,

-- rpc services
sync_svc = sync_svc.new(),
}

-- init rpc services
self.sync_svc = sync_svc.new()
self.sync_svc:init()

local address = conf.cluster_control_plane .. "/v2/outlet"
local uri = "wss://" .. address .. "?node_id=" ..
Expand Down Expand Up @@ -77,6 +77,10 @@ function _M:init_worker(basic_info)
self.plugins_list = basic_info.plugins
self.filters = basic_info.filters

-- init rpc services
self.sync_svc:init_worker()

-- init rpc connection
kong.rpc:init_worker()

ping_cp_test()
Expand Down
2 changes: 1 addition & 1 deletion kong/clustering/data_plane/services/sync.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function _M.new()
end


function _M:init()
function _M:init_worker()
callbacks.register("kong.sync.v1.push_all", function(params)
ngx.log(ngx.ERR, "xxx sync push all, data type=", type(params.data))

Expand Down

0 comments on commit e7e20df

Please sign in to comment.