Skip to content

Commit

Permalink
move to skynet module
Browse files Browse the repository at this point in the history
  • Loading branch information
cloudwu committed Jun 1, 2017
1 parent 8a6243d commit f1ed482
Show file tree
Hide file tree
Showing 37 changed files with 75 additions and 55 deletions.
45 changes: 28 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,21 @@ update3rd :
# skynet

CSERVICE = snlua logger gate harbor
LUA_CLIB = skynet socketdriver bson mongo md5 netpack \
clientsocket memory profile multicast \
cluster crypt sharedata stm sproto lpeg \
mysqlaux debugchannel
LUA_CLIB = skynet \
skynet.socketdriver \
skynet.mongo \
skynet.netpack \
skynet.mysqlaux \
skynet.debugchannel \
skynet.profile \
skynet.cluster \
skynet.sharedata \
skynet.multicast \
skynet.memory \
skynet.crypt \
skynet.stm \
skynet.clientsocket \
bson md5 sproto lpeg

SKYNET_SRC = skynet_main.c skynet_handle.c skynet_module.c skynet_mq.c \
skynet_server.c skynet_start.c skynet_timer.c skynet_error.c \
Expand Down Expand Up @@ -79,43 +90,43 @@ $(foreach v, $(CSERVICE), $(eval $(call CSERVICE_TEMP,$(v))))
$(LUA_CLIB_PATH)/skynet.so : lualib-src/lua-skynet.c lualib-src/lua-seri.c | $(LUA_CLIB_PATH)
$(CC) $(CFLAGS) $(SHARED) $^ -o $@ -Iskynet-src -Iservice-src -Ilualib-src

$(LUA_CLIB_PATH)/socketdriver.so : lualib-src/lua-socket.c | $(LUA_CLIB_PATH)
$(LUA_CLIB_PATH)/skynet.socketdriver.so : lualib-src/lua-socket.c | $(LUA_CLIB_PATH)
$(CC) $(CFLAGS) $(SHARED) $^ -o $@ -Iskynet-src -Iservice-src

$(LUA_CLIB_PATH)/bson.so : lualib-src/lua-bson.c | $(LUA_CLIB_PATH)
$(CC) $(CFLAGS) $(SHARED) -Iskynet-src $^ -o $@ -Iskynet-src

$(LUA_CLIB_PATH)/mongo.so : lualib-src/lua-mongo.c | $(LUA_CLIB_PATH)
$(LUA_CLIB_PATH)/skynet.mongo.so : lualib-src/lua-mongo.c | $(LUA_CLIB_PATH)
$(CC) $(CFLAGS) $(SHARED) $^ -o $@ -Iskynet-src

$(LUA_CLIB_PATH)/md5.so : 3rd/lua-md5/md5.c 3rd/lua-md5/md5lib.c 3rd/lua-md5/compat-5.2.c | $(LUA_CLIB_PATH)
$(CC) $(CFLAGS) $(SHARED) -I3rd/lua-md5 $^ -o $@

$(LUA_CLIB_PATH)/netpack.so : lualib-src/lua-netpack.c | $(LUA_CLIB_PATH)
$(LUA_CLIB_PATH)/skynet.netpack.so : lualib-src/lua-netpack.c | $(LUA_CLIB_PATH)
$(CC) $(CFLAGS) $(SHARED) $^ -Iskynet-src -o $@

$(LUA_CLIB_PATH)/clientsocket.so : lualib-src/lua-clientsocket.c | $(LUA_CLIB_PATH)
$(LUA_CLIB_PATH)/skynet.clientsocket.so : lualib-src/lua-clientsocket.c | $(LUA_CLIB_PATH)
$(CC) $(CFLAGS) $(SHARED) $^ -o $@ -lpthread

$(LUA_CLIB_PATH)/memory.so : lualib-src/lua-memory.c | $(LUA_CLIB_PATH)
$(LUA_CLIB_PATH)/skynet.memory.so : lualib-src/lua-memory.c | $(LUA_CLIB_PATH)
$(CC) $(CFLAGS) $(SHARED) -Iskynet-src $^ -o $@

$(LUA_CLIB_PATH)/profile.so : lualib-src/lua-profile.c | $(LUA_CLIB_PATH)
$(LUA_CLIB_PATH)/skynet.profile.so : lualib-src/lua-profile.c | $(LUA_CLIB_PATH)
$(CC) $(CFLAGS) $(SHARED) $^ -o $@

$(LUA_CLIB_PATH)/multicast.so : lualib-src/lua-multicast.c | $(LUA_CLIB_PATH)
$(LUA_CLIB_PATH)/skynet.multicast.so : lualib-src/lua-multicast.c | $(LUA_CLIB_PATH)
$(CC) $(CFLAGS) $(SHARED) -Iskynet-src $^ -o $@

$(LUA_CLIB_PATH)/cluster.so : lualib-src/lua-cluster.c | $(LUA_CLIB_PATH)
$(LUA_CLIB_PATH)/skynet.cluster.so : lualib-src/lua-cluster.c | $(LUA_CLIB_PATH)
$(CC) $(CFLAGS) $(SHARED) -Iskynet-src $^ -o $@

$(LUA_CLIB_PATH)/crypt.so : lualib-src/lua-crypt.c lualib-src/lsha1.c | $(LUA_CLIB_PATH)
$(LUA_CLIB_PATH)/skynet.crypt.so : lualib-src/lua-crypt.c lualib-src/lsha1.c | $(LUA_CLIB_PATH)
$(CC) $(CFLAGS) $(SHARED) $^ -o $@

$(LUA_CLIB_PATH)/sharedata.so : lualib-src/lua-sharedata.c | $(LUA_CLIB_PATH)
$(LUA_CLIB_PATH)/skynet.sharedata.so : lualib-src/lua-sharedata.c | $(LUA_CLIB_PATH)
$(CC) $(CFLAGS) $(SHARED) -Iskynet-src $^ -o $@

$(LUA_CLIB_PATH)/stm.so : lualib-src/lua-stm.c | $(LUA_CLIB_PATH)
$(LUA_CLIB_PATH)/skynet.stm.so : lualib-src/lua-stm.c | $(LUA_CLIB_PATH)
$(CC) $(CFLAGS) $(SHARED) -Iskynet-src $^ -o $@

$(LUA_CLIB_PATH)/sproto.so : lualib-src/sproto/sproto.c lualib-src/sproto/lsproto.c | $(LUA_CLIB_PATH)
Expand All @@ -124,10 +135,10 @@ $(LUA_CLIB_PATH)/sproto.so : lualib-src/sproto/sproto.c lualib-src/sproto/lsprot
$(LUA_CLIB_PATH)/lpeg.so : 3rd/lpeg/lpcap.c 3rd/lpeg/lpcode.c 3rd/lpeg/lpprint.c 3rd/lpeg/lptree.c 3rd/lpeg/lpvm.c | $(LUA_CLIB_PATH)
$(CC) $(CFLAGS) $(SHARED) -I3rd/lpeg $^ -o $@

$(LUA_CLIB_PATH)/mysqlaux.so : lualib-src/lua-mysqlaux.c | $(LUA_CLIB_PATH)
$(LUA_CLIB_PATH)/skynet.mysqlaux.so : lualib-src/lua-mysqlaux.c | $(LUA_CLIB_PATH)
$(CC) $(CFLAGS) $(SHARED) $^ -o $@

$(LUA_CLIB_PATH)/debugchannel.so : lualib-src/lua-debugchannel.c | $(LUA_CLIB_PATH)
$(LUA_CLIB_PATH)/skynet.debugchannel.so : lualib-src/lua-debugchannel.c | $(LUA_CLIB_PATH)
$(CC) $(CFLAGS) $(SHARED) -Iskynet-src $^ -o $@

clean :
Expand Down
2 changes: 1 addition & 1 deletion examples/agent.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
local skynet = require "skynet"
local netpack = require "netpack"
local netpack = require "skynet.netpack"
local socket = require "skynet.socket"
local sproto = require "sproto"
local sprotoloader = require "sprotoloader"
Expand Down
2 changes: 1 addition & 1 deletion examples/client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ if _VERSION ~= "Lua 5.3" then
error "Use lua 5.3"
end

local socket = require "clientsocket"
local socket = require "skynet.clientsocket"
local proto = require "proto"
local sproto = require "sproto"

Expand Down
2 changes: 1 addition & 1 deletion examples/cluster1.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
local skynet = require "skynet"
local cluster = require "cluster"
local cluster = require "skynet.cluster"
local snax = require "snax"

skynet.start(function()
Expand Down
2 changes: 1 addition & 1 deletion examples/cluster2.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
local skynet = require "skynet"
local cluster = require "cluster"
local cluster = require "skynet.cluster"

skynet.start(function()
-- query name "sdb" of cluster db.
Expand Down
2 changes: 1 addition & 1 deletion lualib/http/httpc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ local skynet = require "skynet"
local socket = require "http.sockethelper"
local url = require "http.url"
local internal = require "http.internal"
local dns = require "dns"
local dns = require "skynet.dns"
local string = string
local table = table

Expand Down
2 changes: 1 addition & 1 deletion lualib/skynet.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ local pairs = pairs
local pcall = pcall
local table = table

local profile = require "profile"
local profile = require "skynet.profile"

local coroutine_resume = profile.resume
local coroutine_yield = profile.yield
Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions lualib/skynet/db/mongo.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ local bson = require "bson"
local socket = require "skynet.socket"
local socketchannel = require "skynet.socketchannel"
local skynet = require "skynet"
local driver = require "mongo.driver"
local driver = require "skynet.mongo.driver"
local md5 = require "md5"
local crypt = require "crypt"
local crypt = require "skynet.crypt"
local rawget = rawget
local assert = assert
local table = table
Expand Down
4 changes: 2 additions & 2 deletions lualib/skynet/db/mysql.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
-- Modified by Cloud Wu (remove bit32 for lua 5.3)

local socketchannel = require "skynet.socketchannel"
local mysqlaux = require "mysqlaux.c"
local crypt = require "crypt"
local mysqlaux = require "skynet.mysqlaux.c"
local crypt = require "skynet.crypt"


local sub = string.sub
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion lualib/multicast.lua → lualib/skynet/multicast.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
local skynet = require "skynet"
local mc = require "multicast.core"
local mc = require "skynet.multicast.core"

local multicastd
local multicast = {}
Expand Down
9 changes: 9 additions & 0 deletions lualib/skynet/reload.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
local core = require "skynet.reload.core"
local skynet = require "skynet"

local function reload(...)
local args = SERVICE_NAME .. " " .. table.concat({...}, " ")
print(args)
end

return reload
4 changes: 2 additions & 2 deletions lualib/skynet/remotedebug.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
local skynet = require "skynet"
local debugchannel = require "debugchannel"
local socketdriver = require "socketdriver"
local debugchannel = require "skynet.debugchannel"
local socketdriver = require "skynet.socketdriver"
local injectrun = require "skynet.injectcode"
local table = table
local debug = debug
Expand Down
2 changes: 1 addition & 1 deletion lualib/sharedata.lua → lualib/skynet/sharedata.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
local skynet = require "skynet"
local sd = require "sharedata.corelib"
local sd = require "skynet.sharedata.corelib"

local service

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
local core = require "sharedata.core"
local core = require "skynet.sharedata.core"
local type = type
local rawset = rawset

Expand Down
2 changes: 1 addition & 1 deletion lualib/sharemap.lua → lualib/skynet/sharemap.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
local stm = require "stm"
local stm = require "skynet.stm"
local sprotoloader = require "sprotoloader"
local sproto = require "sproto"
local setmetatable = setmetatable
Expand Down
2 changes: 1 addition & 1 deletion lualib/skynet/socket.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
local driver = require "socketdriver"
local driver = require "skynet.socketdriver"
local skynet = require "skynet"
local skynet_core = require "skynet.core"
local assert = assert
Expand Down
2 changes: 1 addition & 1 deletion lualib/skynet/socketchannel.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
local skynet = require "skynet"
local socket = require "skynet.socket"
local socketdriver = require "socketdriver"
local socketdriver = require "skynet.socketdriver"

-- channel support auto reconnect , and capture socket error in request/response transaction
-- { host = "", port = , auth = function(so) , response = function(so) session, data }
Expand Down
2 changes: 1 addition & 1 deletion service/bootstrap.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
local skynet = require "skynet"
local harbor = require "skynet.harbor"
require "skynet.manager" -- import skynet.launch, ...
local memory = require "memory"
local memory = require "skynet.memory"

skynet.start(function()
local sharestring = tonumber(skynet.getenv "sharestring" or 4096)
Expand Down
2 changes: 1 addition & 1 deletion service/clusterd.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
local skynet = require "skynet"
local sc = require "skynet.socketchannel"
local socket = require "skynet.socket"
local cluster = require "cluster.core"
local cluster = require "skynet.cluster.core"

local config_name = skynet.getenv "cluster"
local node_address = {}
Expand Down
2 changes: 1 addition & 1 deletion service/clusterproxy.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
local skynet = require "skynet"
local cluster = require "cluster"
local cluster = require "skynet.cluster"
require "skynet.manager" -- inject skynet.forward_type

local node, address = ...
Expand Down
2 changes: 1 addition & 1 deletion service/cmemory.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
local skynet = require "skynet"
local memory = require "memory"
local memory = require "skynet.memory"

memory.dumpinfo()
--memory.dump()
Expand Down
2 changes: 1 addition & 1 deletion service/debug_agent.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
local skynet = require "skynet"
local debugchannel = require "debugchannel"
local debugchannel = require "skynet.debugchannel"

local CMD = {}

Expand Down
2 changes: 1 addition & 1 deletion service/debug_console.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ local codecache = require "skynet.codecache"
local core = require "skynet.core"
local socket = require "skynet.socket"
local snax = require "snax"
local memory = require "memory"
local memory = require "skynet.memory"
local httpd = require "http.httpd"
local sockethelper = require "http.sockethelper"

Expand Down
2 changes: 1 addition & 1 deletion service/gate.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
local skynet = require "skynet"
local gateserver = require "snax.gateserver"
local netpack = require "netpack"
local netpack = require "skynet.netpack"

local watchdog
local connection = {} -- fd -> connection : { fd , client, agent , ip, mode }
Expand Down
4 changes: 2 additions & 2 deletions service/multicastd.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
local skynet = require "skynet"
local mc = require "multicast.core"
local datacenter = require "datacenter"
local mc = require "skynet.multicast.core"
local datacenter = require "skynet.datacenter"

local harbor_id = skynet.harbor(skynet.self())

Expand Down
2 changes: 1 addition & 1 deletion service/sharedatad.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
local skynet = require "skynet"
local sharedata = require "sharedata.corelib"
local sharedata = require "skynet.sharedata.corelib"
local table = table
local cache = require "skynet.codecache"
cache.mode "OFF" -- turn off codecache, because CMD.new may load data file
Expand Down
2 changes: 1 addition & 1 deletion service/snaxd.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
local skynet = require "skynet"
local c = require "skynet.core"
local snax_interface = require "snax.interface"
local profile = require "profile"
local profile = require "skynet.profile"
local snax = require "snax"

local snax_name = tostring(...)
Expand Down
2 changes: 1 addition & 1 deletion test/testcoroutine.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
local skynet = require "skynet"
-- You should use skynet.coroutine instead of origin coroutine in skynet
local coroutine = require "skynet.coroutine"
local profile = require "profile"
local profile = require "skynet.profile"

local function status(co)
repeat
Expand Down
2 changes: 1 addition & 1 deletion test/testdatacenter.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
local skynet = require "skynet"
local datacenter = require "datacenter"
local datacenter = require "skynet.datacenter"

local function f1()
print("====1==== wait hello")
Expand Down
4 changes: 2 additions & 2 deletions test/testmulticast.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
local skynet = require "skynet"
local mc = require "multicast"
local dc = require "datacenter"
local mc = require "skynet.multicast"
local dc = require "skynet.datacenter"

local mode = ...

Expand Down
4 changes: 2 additions & 2 deletions test/testmulticast2.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
local skynet = require "skynet"
local dc = require "datacenter"
local mc = require "multicast"
local dc = require "skynet.datacenter"
local mc = require "skynet.multicast"

skynet.start(function()
print("remote start")
Expand Down
2 changes: 1 addition & 1 deletion test/testsha.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
local skynet = require "skynet"
local crypt = require "crypt"
local crypt = require "skynet.crypt"

local function sha1(text)
local c = crypt.sha1(text)
Expand Down
2 changes: 1 addition & 1 deletion test/testsm.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
local skynet = require "skynet"
local sharemap = require "sharemap"
local sharemap = require "skynet.sharemap"

local mode = ...

Expand Down
2 changes: 1 addition & 1 deletion test/teststm.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
local skynet = require "skynet"
local stm = require "stm"
local stm = require "skynet.stm"

local mode = ...

Expand Down

0 comments on commit f1ed482

Please sign in to comment.