diff --git a/Makefile b/Makefile index 08259a63..b4a94090 100644 --- a/Makefile +++ b/Makefile @@ -45,10 +45,25 @@ 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 \ + clientsocket \ + bson md5 sproto lpeg + +LUA_CLIB_SKYNET = \ + lua-skynet.c lua-seri.c \ + lua-socket.c \ + lua-mongo.c \ + lua-netpack.c \ + lua-memory.c \ + lua-profile.c \ + lua-multicast.c \ + lua-cluster.c \ + lua-crypt.c lsha1.c \ + lua-sharedata.c \ + lua-stm.c \ + lua-mysqlaux.c \ + lua-debugchannel.c \ + \ 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 \ @@ -76,60 +91,24 @@ endef $(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) +$(LUA_CLIB_PATH)/skynet.so : $(addprefix lualib-src/,$(LUA_CLIB_SKYNET)) | $(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) - $(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) - $(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) - $(CC) $(CFLAGS) $(SHARED) $^ -Iskynet-src -o $@ - $(LUA_CLIB_PATH)/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) - $(CC) $(CFLAGS) $(SHARED) -Iskynet-src $^ -o $@ - -$(LUA_CLIB_PATH)/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) - $(CC) $(CFLAGS) $(SHARED) -Iskynet-src $^ -o $@ - -$(LUA_CLIB_PATH)/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) - $(CC) $(CFLAGS) $(SHARED) $^ -o $@ - -$(LUA_CLIB_PATH)/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) - $(CC) $(CFLAGS) $(SHARED) -Iskynet-src $^ -o $@ - $(LUA_CLIB_PATH)/sproto.so : lualib-src/sproto/sproto.c lualib-src/sproto/lsproto.c | $(LUA_CLIB_PATH) $(CC) $(CFLAGS) $(SHARED) -Ilualib-src/sproto $^ -o $@ $(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) - $(CC) $(CFLAGS) $(SHARED) $^ -o $@ - -$(LUA_CLIB_PATH)/debugchannel.so : lualib-src/lua-debugchannel.c | $(LUA_CLIB_PATH) - $(CC) $(CFLAGS) $(SHARED) -Iskynet-src $^ -o $@ - clean : rm -f $(SKYNET_BUILD_PATH)/skynet $(CSERVICE_PATH)/*.so $(LUA_CLIB_PATH)/*.so diff --git a/examples/agent.lua b/examples/agent.lua index 06db1108..3e164bb8 100644 --- a/examples/agent.lua +++ b/examples/agent.lua @@ -1,6 +1,6 @@ local skynet = require "skynet" -local netpack = require "netpack" -local socket = require "socket" +local netpack = require "skynet.netpack" +local socket = require "skynet.socket" local sproto = require "sproto" local sprotoloader = require "sprotoloader" diff --git a/examples/client.lua b/examples/client.lua index 92aaa16e..52836c5f 100644 --- a/examples/client.lua +++ b/examples/client.lua @@ -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" diff --git a/examples/cluster1.lua b/examples/cluster1.lua index 70d20044..79665826 100644 --- a/examples/cluster1.lua +++ b/examples/cluster1.lua @@ -1,6 +1,6 @@ local skynet = require "skynet" -local cluster = require "cluster" -local snax = require "snax" +local cluster = require "skynet.cluster" +local snax = require "skynet.snax" skynet.start(function() cluster.reload { diff --git a/examples/cluster2.lua b/examples/cluster2.lua index 22c9cf7f..f356357c 100644 --- a/examples/cluster2.lua +++ b/examples/cluster2.lua @@ -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. diff --git a/examples/share.lua b/examples/share.lua index 8bc4b497..b91e3fc7 100644 --- a/examples/share.lua +++ b/examples/share.lua @@ -1,5 +1,5 @@ local skynet = require "skynet" -local sharedata = require "sharedata" +local sharedata = require "skynet.sharedata" local mode = ... diff --git a/examples/simpleweb.lua b/examples/simpleweb.lua index 5d38dfb1..283b7e91 100644 --- a/examples/simpleweb.lua +++ b/examples/simpleweb.lua @@ -1,5 +1,5 @@ local skynet = require "skynet" -local socket = require "socket" +local socket = require "skynet.socket" local httpd = require "http.httpd" local sockethelper = require "http.sockethelper" local urllib = require "http.url" diff --git a/lualib-src/lua-cluster.c b/lualib-src/lua-cluster.c index 7975c020..84d6332c 100644 --- a/lualib-src/lua-cluster.c +++ b/lualib-src/lua-cluster.c @@ -508,7 +508,7 @@ lconcat(lua_State *L) { } LUAMOD_API int -luaopen_cluster_core(lua_State *L) { +luaopen_skynet_cluster_core(lua_State *L) { luaL_Reg l[] = { { "packrequest", lpackrequest }, { "packpush", lpackpush }, diff --git a/lualib-src/lua-crypt.c b/lualib-src/lua-crypt.c index 184f5f57..7a182db7 100644 --- a/lualib-src/lua-crypt.c +++ b/lualib-src/lua-crypt.c @@ -904,7 +904,7 @@ int lsha1(lua_State *L); int lhmac_sha1(lua_State *L); LUAMOD_API int -luaopen_crypt(lua_State *L) { +luaopen_skynet_crypt(lua_State *L) { luaL_checkversion(L); static int init = 0; if (!init) { diff --git a/lualib-src/lua-debugchannel.c b/lualib-src/lua-debugchannel.c index a07da360..7f83c9e9 100644 --- a/lualib-src/lua-debugchannel.c +++ b/lualib-src/lua-debugchannel.c @@ -271,7 +271,7 @@ static int db_sethook (lua_State *L) { } LUAMOD_API int -luaopen_debugchannel(lua_State *L) { +luaopen_skynet_debugchannel(lua_State *L) { luaL_Reg l[] = { { "create", lcreate }, // for write { "connect", lconnect }, // for read diff --git a/lualib-src/lua-memory.c b/lualib-src/lua-memory.c index df771e2e..5fc75752 100644 --- a/lualib-src/lua-memory.c +++ b/lualib-src/lua-memory.c @@ -50,7 +50,7 @@ lcurrent(lua_State *L) { } LUAMOD_API int -luaopen_memory(lua_State *L) { +luaopen_skynet_memory(lua_State *L) { luaL_checkversion(L); luaL_Reg l[] = { diff --git a/lualib-src/lua-mongo.c b/lualib-src/lua-mongo.c index cdaa1521..a8ca0b0c 100644 --- a/lualib-src/lua-mongo.c +++ b/lualib-src/lua-mongo.c @@ -532,7 +532,7 @@ reply_length(lua_State *L) { } LUAMOD_API int -luaopen_mongo_driver(lua_State *L) { +luaopen_skynet_mongo_driver(lua_State *L) { luaL_checkversion(L); luaL_Reg l[] ={ { "query", op_query }, diff --git a/lualib-src/lua-multicast.c b/lualib-src/lua-multicast.c index 16e5ed08..8903b36e 100644 --- a/lualib-src/lua-multicast.c +++ b/lualib-src/lua-multicast.c @@ -146,7 +146,7 @@ mc_nextid(lua_State *L) { } LUAMOD_API int -luaopen_multicast_core(lua_State *L) { +luaopen_skynet_multicast_core(lua_State *L) { luaL_Reg l[] = { { "pack", mc_packlocal }, { "unpack", mc_unpacklocal }, diff --git a/lualib-src/lua-mysqlaux.c b/lualib-src/lua-mysqlaux.c index bee93edf..46fbc67d 100644 --- a/lualib-src/lua-mysqlaux.c +++ b/lualib-src/lua-mysqlaux.c @@ -158,7 +158,7 @@ static struct luaL_Reg mysqlauxlib[] = { }; -LUAMOD_API int luaopen_mysqlaux_c (lua_State *L) { +LUAMOD_API int luaopen_skynet_mysqlaux_c (lua_State *L) { lua_newtable(L); luaL_setfuncs(L, mysqlauxlib, 0); return 1; diff --git a/lualib-src/lua-netpack.c b/lualib-src/lua-netpack.c index fb62f221..7f9a7b64 100644 --- a/lualib-src/lua-netpack.c +++ b/lualib-src/lua-netpack.c @@ -465,7 +465,7 @@ ltostring(lua_State *L) { } LUAMOD_API int -luaopen_netpack(lua_State *L) { +luaopen_skynet_netpack(lua_State *L) { luaL_checkversion(L); luaL_Reg l[] = { { "pop", lpop }, diff --git a/lualib-src/lua-profile.c b/lualib-src/lua-profile.c index 6522b9fa..9d9b261d 100644 --- a/lualib-src/lua-profile.c +++ b/lualib-src/lua-profile.c @@ -200,7 +200,7 @@ lyield_co(lua_State *L) { } LUAMOD_API int -luaopen_profile(lua_State *L) { +luaopen_skynet_profile(lua_State *L) { luaL_checkversion(L); luaL_Reg l[] = { { "start", lstart }, diff --git a/lualib-src/lua-sharedata.c b/lualib-src/lua-sharedata.c index 9d49411e..16b20872 100644 --- a/lualib-src/lua-sharedata.c +++ b/lualib-src/lua-sharedata.c @@ -765,7 +765,7 @@ lupdate(lua_State *L) { } LUAMOD_API int -luaopen_sharedata_core(lua_State *L) { +luaopen_skynet_sharedata_core(lua_State *L) { luaL_Reg l[] = { // used by host { "new", lnewconf }, diff --git a/lualib-src/lua-socket.c b/lualib-src/lua-socket.c index bd5cc5b9..c39f85dd 100644 --- a/lualib-src/lua-socket.c +++ b/lualib-src/lua-socket.c @@ -678,7 +678,7 @@ ludp_address(lua_State *L) { } LUAMOD_API int -luaopen_socketdriver(lua_State *L) { +luaopen_skynet_socketdriver(lua_State *L) { luaL_checkversion(L); luaL_Reg l[] = { { "buffer", lnewbuffer }, diff --git a/lualib-src/lua-stm.c b/lualib-src/lua-stm.c index e5a2fe1e..3089594b 100644 --- a/lualib-src/lua-stm.c +++ b/lualib-src/lua-stm.c @@ -235,7 +235,7 @@ lread(lua_State *L) { } LUAMOD_API int -luaopen_stm(lua_State *L) { +luaopen_skynet_stm(lua_State *L) { luaL_checkversion(L); lua_createtable(L, 0, 3); diff --git a/lualib/compat10/cluster.lua b/lualib/compat10/cluster.lua new file mode 100644 index 00000000..04c5b01c --- /dev/null +++ b/lualib/compat10/cluster.lua @@ -0,0 +1 @@ +return require "skynet.cluster" \ No newline at end of file diff --git a/lualib/compat10/crypt.lua b/lualib/compat10/crypt.lua new file mode 100644 index 00000000..7fcb351a --- /dev/null +++ b/lualib/compat10/crypt.lua @@ -0,0 +1 @@ +return require "skynet.crypt" \ No newline at end of file diff --git a/lualib/compat10/datacenter.lua b/lualib/compat10/datacenter.lua new file mode 100644 index 00000000..1529e7bc --- /dev/null +++ b/lualib/compat10/datacenter.lua @@ -0,0 +1 @@ +return require "skynet.datacenter" \ No newline at end of file diff --git a/lualib/compat10/dns.lua b/lualib/compat10/dns.lua new file mode 100644 index 00000000..fd9e7096 --- /dev/null +++ b/lualib/compat10/dns.lua @@ -0,0 +1 @@ +return require "skynet.dns" \ No newline at end of file diff --git a/lualib/compat10/memory.lua b/lualib/compat10/memory.lua new file mode 100644 index 00000000..07c4e506 --- /dev/null +++ b/lualib/compat10/memory.lua @@ -0,0 +1 @@ +return require "skynet.memory" \ No newline at end of file diff --git a/lualib/compat10/mongo.lua b/lualib/compat10/mongo.lua new file mode 100644 index 00000000..eee821ae --- /dev/null +++ b/lualib/compat10/mongo.lua @@ -0,0 +1 @@ +return require "skynet.db.mongo" \ No newline at end of file diff --git a/lualib/compat10/mqueue.lua b/lualib/compat10/mqueue.lua new file mode 100644 index 00000000..a1ca6102 --- /dev/null +++ b/lualib/compat10/mqueue.lua @@ -0,0 +1 @@ +return require "skynet.mqueue" \ No newline at end of file diff --git a/lualib/compat10/multicast.lua b/lualib/compat10/multicast.lua new file mode 100644 index 00000000..93a38bc7 --- /dev/null +++ b/lualib/compat10/multicast.lua @@ -0,0 +1 @@ +return require "skynet.multicast" \ No newline at end of file diff --git a/lualib/compat10/mysql.lua b/lualib/compat10/mysql.lua new file mode 100644 index 00000000..f0b9dd27 --- /dev/null +++ b/lualib/compat10/mysql.lua @@ -0,0 +1 @@ +return require "skynet.db.mysql" \ No newline at end of file diff --git a/lualib/compat10/netpack.lua b/lualib/compat10/netpack.lua new file mode 100644 index 00000000..eb1350ab --- /dev/null +++ b/lualib/compat10/netpack.lua @@ -0,0 +1 @@ +return require "skynet.netpack" \ No newline at end of file diff --git a/lualib/compat10/profile.lua b/lualib/compat10/profile.lua new file mode 100644 index 00000000..3d8dc69c --- /dev/null +++ b/lualib/compat10/profile.lua @@ -0,0 +1 @@ +return require "skynet.profile" \ No newline at end of file diff --git a/lualib/compat10/redis.lua b/lualib/compat10/redis.lua new file mode 100644 index 00000000..8ca502fd --- /dev/null +++ b/lualib/compat10/redis.lua @@ -0,0 +1 @@ +return require "skynet.db.redis" \ No newline at end of file diff --git a/lualib/compat10/sharedata.lua b/lualib/compat10/sharedata.lua new file mode 100644 index 00000000..59d9c942 --- /dev/null +++ b/lualib/compat10/sharedata.lua @@ -0,0 +1 @@ +return require "skynet.sharedata" \ No newline at end of file diff --git a/lualib/compat10/sharemap.lua b/lualib/compat10/sharemap.lua new file mode 100644 index 00000000..f377542b --- /dev/null +++ b/lualib/compat10/sharemap.lua @@ -0,0 +1 @@ +return require "skynet.sharemap" \ No newline at end of file diff --git a/lualib/compat10/snax.lua b/lualib/compat10/snax.lua new file mode 100644 index 00000000..bdeda17d --- /dev/null +++ b/lualib/compat10/snax.lua @@ -0,0 +1 @@ +return require "skynet.snax" \ No newline at end of file diff --git a/lualib/compat10/socket.lua b/lualib/compat10/socket.lua new file mode 100644 index 00000000..99eec22f --- /dev/null +++ b/lualib/compat10/socket.lua @@ -0,0 +1 @@ +return require "skynet.socket" \ No newline at end of file diff --git a/lualib/compat10/socketchannel.lua b/lualib/compat10/socketchannel.lua new file mode 100644 index 00000000..b74f8a4f --- /dev/null +++ b/lualib/compat10/socketchannel.lua @@ -0,0 +1 @@ +return require "skynet.socketchannel" \ No newline at end of file diff --git a/lualib/compat10/socketdriver.lua b/lualib/compat10/socketdriver.lua new file mode 100644 index 00000000..45ddf996 --- /dev/null +++ b/lualib/compat10/socketdriver.lua @@ -0,0 +1 @@ +return require "skynet.socketdriver" \ No newline at end of file diff --git a/lualib/compat10/stm.lua b/lualib/compat10/stm.lua new file mode 100644 index 00000000..933c651d --- /dev/null +++ b/lualib/compat10/stm.lua @@ -0,0 +1 @@ +return require "skynet.stm" \ No newline at end of file diff --git a/lualib/http/httpc.lua b/lualib/http/httpc.lua index 43a44e19..79e7db74 100644 --- a/lualib/http/httpc.lua +++ b/lualib/http/httpc.lua @@ -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 diff --git a/lualib/http/sockethelper.lua b/lualib/http/sockethelper.lua index 0ae6445d..f5d6ae80 100644 --- a/lualib/http/sockethelper.lua +++ b/lualib/http/sockethelper.lua @@ -1,4 +1,4 @@ -local socket = require "socket" +local socket = require "skynet.socket" local skynet = require "skynet" local readbytes = socket.read diff --git a/lualib/skynet.lua b/lualib/skynet.lua index d8212f18..caa07db6 100644 --- a/lualib/skynet.lua +++ b/lualib/skynet.lua @@ -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 diff --git a/lualib/cluster.lua b/lualib/skynet/cluster.lua similarity index 97% rename from lualib/cluster.lua rename to lualib/skynet/cluster.lua index 14dee2ac..dd3b9dde 100644 --- a/lualib/cluster.lua +++ b/lualib/skynet/cluster.lua @@ -30,7 +30,7 @@ function cluster.proxy(node, name) end function cluster.snax(node, name, address) - local snax = require "snax" + local snax = require "skynet.snax" if not address then address = cluster.call(node, ".service", "QUERY", "snaxd" , name) end diff --git a/lualib/datacenter.lua b/lualib/skynet/datacenter.lua similarity index 100% rename from lualib/datacenter.lua rename to lualib/skynet/datacenter.lua diff --git a/lualib/mongo.lua b/lualib/skynet/db/mongo.lua similarity index 98% rename from lualib/mongo.lua rename to lualib/skynet/db/mongo.lua index 393f4334..e77f7499 100644 --- a/lualib/mongo.lua +++ b/lualib/skynet/db/mongo.lua @@ -1,10 +1,10 @@ local bson = require "bson" -local socket = require "socket" -local socketchannel = require "socketchannel" +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 diff --git a/lualib/mysql.lua b/lualib/skynet/db/mysql.lua similarity index 99% rename from lualib/mysql.lua rename to lualib/skynet/db/mysql.lua index afa76425..b5d97e2c 100644 --- a/lualib/mysql.lua +++ b/lualib/skynet/db/mysql.lua @@ -4,9 +4,9 @@ -- The license is under the BSD license. -- Modified by Cloud Wu (remove bit32 for lua 5.3) -local socketchannel = require "socketchannel" -local mysqlaux = require "mysqlaux.c" -local crypt = require "crypt" +local socketchannel = require "skynet.socketchannel" +local mysqlaux = require "skynet.mysqlaux.c" +local crypt = require "skynet.crypt" local sub = string.sub diff --git a/lualib/redis.lua b/lualib/skynet/db/redis.lua similarity index 98% rename from lualib/redis.lua rename to lualib/skynet/db/redis.lua index 949023a2..e838a978 100644 --- a/lualib/redis.lua +++ b/lualib/skynet/db/redis.lua @@ -1,6 +1,6 @@ local skynet = require "skynet" -local socket = require "socket" -local socketchannel = require "socketchannel" +local socket = require "skynet.socket" +local socketchannel = require "skynet.socketchannel" local table = table local string = string diff --git a/lualib/dns.lua b/lualib/skynet/dns.lua similarity index 99% rename from lualib/dns.lua rename to lualib/skynet/dns.lua index 76f363f0..0b96f214 100644 --- a/lualib/dns.lua +++ b/lualib/skynet/dns.lua @@ -65,7 +65,7 @@ --]] local skynet = require "skynet" -local socket = require "socket" +local socket = require "skynet.socket" local MAX_DOMAIN_LEN = 1024 local MAX_LABEL_LEN = 63 diff --git a/lualib/mqueue.lua b/lualib/skynet/mqueue.lua similarity index 100% rename from lualib/mqueue.lua rename to lualib/skynet/mqueue.lua diff --git a/lualib/multicast.lua b/lualib/skynet/multicast.lua similarity index 98% rename from lualib/multicast.lua rename to lualib/skynet/multicast.lua index 181979cb..4b09044f 100644 --- a/lualib/multicast.lua +++ b/lualib/skynet/multicast.lua @@ -1,5 +1,5 @@ local skynet = require "skynet" -local mc = require "multicast.core" +local mc = require "skynet.multicast.core" local multicastd local multicast = {} diff --git a/lualib/skynet/reload.lua b/lualib/skynet/reload.lua new file mode 100644 index 00000000..33e234b0 --- /dev/null +++ b/lualib/skynet/reload.lua @@ -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 diff --git a/lualib/skynet/remotedebug.lua b/lualib/skynet/remotedebug.lua index 72a06809..d0c99e27 100644 --- a/lualib/skynet/remotedebug.lua +++ b/lualib/skynet/remotedebug.lua @@ -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 diff --git a/lualib/sharedata.lua b/lualib/skynet/sharedata.lua similarity index 96% rename from lualib/sharedata.lua rename to lualib/skynet/sharedata.lua index a17a20ba..b955bd90 100644 --- a/lualib/sharedata.lua +++ b/lualib/skynet/sharedata.lua @@ -1,5 +1,5 @@ local skynet = require "skynet" -local sd = require "sharedata.corelib" +local sd = require "skynet.sharedata.corelib" local service diff --git a/lualib/sharedata/corelib.lua b/lualib/skynet/sharedata/corelib.lua similarity index 98% rename from lualib/sharedata/corelib.lua rename to lualib/skynet/sharedata/corelib.lua index 20bd5506..cc49c2d1 100644 --- a/lualib/sharedata/corelib.lua +++ b/lualib/skynet/sharedata/corelib.lua @@ -1,4 +1,4 @@ -local core = require "sharedata.core" +local core = require "skynet.sharedata.core" local type = type local rawset = rawset diff --git a/lualib/sharemap.lua b/lualib/skynet/sharemap.lua similarity index 97% rename from lualib/sharemap.lua rename to lualib/skynet/sharemap.lua index 6f9b1bdf..6d6d16b3 100644 --- a/lualib/sharemap.lua +++ b/lualib/skynet/sharemap.lua @@ -1,4 +1,4 @@ -local stm = require "stm" +local stm = require "skynet.stm" local sprotoloader = require "sprotoloader" local sproto = require "sproto" local setmetatable = setmetatable diff --git a/lualib/snax.lua b/lualib/skynet/snax.lua similarity index 100% rename from lualib/snax.lua rename to lualib/skynet/snax.lua diff --git a/lualib/socket.lua b/lualib/skynet/socket.lua similarity index 99% rename from lualib/socket.lua rename to lualib/skynet/socket.lua index f9644313..26524d90 100644 --- a/lualib/socket.lua +++ b/lualib/skynet/socket.lua @@ -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 diff --git a/lualib/socketchannel.lua b/lualib/skynet/socketchannel.lua similarity index 99% rename from lualib/socketchannel.lua rename to lualib/skynet/socketchannel.lua index fc3c246e..a6474a81 100644 --- a/lualib/socketchannel.lua +++ b/lualib/skynet/socketchannel.lua @@ -1,6 +1,6 @@ local skynet = require "skynet" -local socket = require "socket" -local socketdriver = require "socketdriver" +local socket = require "skynet.socket" +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 } diff --git a/lualib/snax/gateserver.lua b/lualib/snax/gateserver.lua index f22176bc..61e7c97e 100644 --- a/lualib/snax/gateserver.lua +++ b/lualib/snax/gateserver.lua @@ -1,6 +1,6 @@ local skynet = require "skynet" -local netpack = require "netpack" -local socketdriver = require "socketdriver" +local netpack = require "skynet.netpack" +local socketdriver = require "skynet.socketdriver" local gateserver = {} diff --git a/lualib/snax/loginserver.lua b/lualib/snax/loginserver.lua index cd74fcb5..be88b97a 100644 --- a/lualib/snax/loginserver.lua +++ b/lualib/snax/loginserver.lua @@ -1,7 +1,7 @@ local skynet = require "skynet" require "skynet.manager" -local socket = require "socket" -local crypt = require "crypt" +local socket = require "skynet.socket" +local crypt = require "skynet.crypt" local table = table local string = string local assert = assert diff --git a/lualib/snax/msgserver.lua b/lualib/snax/msgserver.lua index 765387cc..4c6f1724 100644 --- a/lualib/snax/msgserver.lua +++ b/lualib/snax/msgserver.lua @@ -1,8 +1,8 @@ local skynet = require "skynet" local gateserver = require "snax.gateserver" -local netpack = require "netpack" -local crypt = require "crypt" -local socketdriver = require "socketdriver" +local netpack = require "skynet.netpack" +local crypt = require "skynet.crypt" +local socketdriver = require "skynet.socketdriver" local assert = assert local b64encode = crypt.base64encode local b64decode = crypt.base64decode diff --git a/service/bootstrap.lua b/service/bootstrap.lua index 90a542cb..3dabfd8a 100644 --- a/service/bootstrap.lua +++ b/service/bootstrap.lua @@ -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) diff --git a/service/clusterd.lua b/service/clusterd.lua index 911b27d1..595b7973 100644 --- a/service/clusterd.lua +++ b/service/clusterd.lua @@ -1,7 +1,7 @@ local skynet = require "skynet" -local sc = require "socketchannel" -local socket = require "socket" -local cluster = require "cluster.core" +local sc = require "skynet.socketchannel" +local socket = require "skynet.socket" +local cluster = require "skynet.cluster.core" local config_name = skynet.getenv "cluster" local node_address = {} diff --git a/service/clusterproxy.lua b/service/clusterproxy.lua index 1e55cff6..e0cc5daa 100644 --- a/service/clusterproxy.lua +++ b/service/clusterproxy.lua @@ -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 = ... diff --git a/service/cmaster.lua b/service/cmaster.lua index eeb9461e..91c75b4b 100644 --- a/service/cmaster.lua +++ b/service/cmaster.lua @@ -1,5 +1,5 @@ local skynet = require "skynet" -local socket = require "socket" +local socket = require "skynet.socket" --[[ master manage data : diff --git a/service/cmemory.lua b/service/cmemory.lua index e33eb42f..2d429b3c 100644 --- a/service/cmemory.lua +++ b/service/cmemory.lua @@ -1,5 +1,5 @@ local skynet = require "skynet" -local memory = require "memory" +local memory = require "skynet.memory" memory.dumpinfo() --memory.dump() diff --git a/service/console.lua b/service/console.lua index e0ce1453..1a7bc343 100644 --- a/service/console.lua +++ b/service/console.lua @@ -1,6 +1,6 @@ local skynet = require "skynet" -local snax = require "snax" -local socket = require "socket" +local snax = require "skynet.snax" +local socket = require "skynet.socket" local function split_cmdline(cmdline) local split = {} diff --git a/service/cslave.lua b/service/cslave.lua index 559d02b3..452dbaf2 100644 --- a/service/cslave.lua +++ b/service/cslave.lua @@ -1,5 +1,5 @@ local skynet = require "skynet" -local socket = require "socket" +local socket = require "skynet.socket" require "skynet.manager" -- import skynet.launch, ... local table = table diff --git a/service/debug_agent.lua b/service/debug_agent.lua index 451e2215..500a34ee 100644 --- a/service/debug_agent.lua +++ b/service/debug_agent.lua @@ -1,5 +1,5 @@ local skynet = require "skynet" -local debugchannel = require "debugchannel" +local debugchannel = require "skynet.debugchannel" local CMD = {} diff --git a/service/debug_console.lua b/service/debug_console.lua index ec4ea482..830a81c0 100644 --- a/service/debug_console.lua +++ b/service/debug_console.lua @@ -1,9 +1,9 @@ local skynet = require "skynet" local codecache = require "skynet.codecache" local core = require "skynet.core" -local socket = require "socket" -local snax = require "snax" -local memory = require "memory" +local socket = require "skynet.socket" +local snax = require "skynet.snax" +local memory = require "skynet.memory" local httpd = require "http.httpd" local sockethelper = require "http.sockethelper" diff --git a/service/gate.lua b/service/gate.lua index f61eed6e..e3a210cc 100644 --- a/service/gate.lua +++ b/service/gate.lua @@ -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 } diff --git a/service/multicastd.lua b/service/multicastd.lua index 7f8506af..bcc5ea97 100644 --- a/service/multicastd.lua +++ b/service/multicastd.lua @@ -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()) diff --git a/service/service_mgr.lua b/service/service_mgr.lua index fc63ce25..dcd901fd 100644 --- a/service/service_mgr.lua +++ b/service/service_mgr.lua @@ -1,6 +1,6 @@ local skynet = require "skynet" require "skynet.manager" -- import skynet.register -local snax = require "snax" +local snax = require "skynet.snax" local cmd = {} local service = {} diff --git a/service/sharedatad.lua b/service/sharedatad.lua index 9888216b..3877ec39 100644 --- a/service/sharedatad.lua +++ b/service/sharedatad.lua @@ -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 diff --git a/service/snaxd.lua b/service/snaxd.lua index 429d6876..6b264930 100644 --- a/service/snaxd.lua +++ b/service/snaxd.lua @@ -1,8 +1,8 @@ local skynet = require "skynet" local c = require "skynet.core" local snax_interface = require "snax.interface" -local profile = require "profile" -local snax = require "snax" +local profile = require "skynet.profile" +local snax = require "skynet.snax" local snax_name = tostring(...) local loaderpath = skynet.getenv"snax_loader" diff --git a/test/pingserver.lua b/test/pingserver.lua index 5785b61b..e5213716 100644 --- a/test/pingserver.lua +++ b/test/pingserver.lua @@ -1,6 +1,6 @@ local skynet = require "skynet" local queue = require "skynet.queue" -local snax = require "snax" +local snax = require "skynet.snax" local i = 0 local hello = "hello" diff --git a/test/testcoroutine.lua b/test/testcoroutine.lua index 5a698575..910bcc0f 100644 --- a/test/testcoroutine.lua +++ b/test/testcoroutine.lua @@ -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 diff --git a/test/testdatacenter.lua b/test/testdatacenter.lua index 194d2219..44eb3875 100644 --- a/test/testdatacenter.lua +++ b/test/testdatacenter.lua @@ -1,5 +1,5 @@ local skynet = require "skynet" -local datacenter = require "datacenter" +local datacenter = require "skynet.datacenter" local function f1() print("====1==== wait hello") diff --git a/test/testdns.lua b/test/testdns.lua index 1d767ce0..01ac414a 100644 --- a/test/testdns.lua +++ b/test/testdns.lua @@ -1,5 +1,5 @@ local skynet = require "skynet" -local dns = require "dns" +local dns = require "skynet.dns" skynet.start(function() print("nameserver:", dns.server()) -- set nameserver diff --git a/test/testhttp.lua b/test/testhttp.lua index 4098b629..f9524930 100644 --- a/test/testhttp.lua +++ b/test/testhttp.lua @@ -1,6 +1,6 @@ local skynet = require "skynet" local httpc = require "http.httpc" -local dns = require "dns" +local dns = require "skynet.dns" local function main() httpc.dns() -- set dns server diff --git a/test/testmemlimit.lua b/test/testmemlimit.lua index 5c0c10d5..c1a7e63e 100644 --- a/test/testmemlimit.lua +++ b/test/testmemlimit.lua @@ -1,6 +1,15 @@ local skynet = require "skynet" -local names = {"cluster", "dns", "mongo", "mysql", "redis", "sharedata", "socket", "sproto"} +local names = { + "cluster", + "skynet.db.dns", + "skynet.db.mongo", + "skynet.db.mysql", + "skynet.db.redis", + "sharedata", + "skynet.socket", + "sproto" +} -- set sandbox memory limit to 1M, must set here (at start, out of skynet.start) skynet.memlimit(1 * 1024 * 1024) diff --git a/test/testmongodb.lua b/test/testmongodb.lua index 06e2691c..138a970b 100644 --- a/test/testmongodb.lua +++ b/test/testmongodb.lua @@ -1,5 +1,5 @@ local skynet = require "skynet" -local mongo = require "mongo" +local mongo = require "skynet.db.mongo" local bson = require "bson" local host, db_name = ... diff --git a/test/testmulticast.lua b/test/testmulticast.lua index 8f084abf..21303457 100644 --- a/test/testmulticast.lua +++ b/test/testmulticast.lua @@ -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 = ... diff --git a/test/testmulticast2.lua b/test/testmulticast2.lua index ff1342c2..545b83f5 100644 --- a/test/testmulticast2.lua +++ b/test/testmulticast2.lua @@ -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") diff --git a/test/testmysql.lua b/test/testmysql.lua index e8b420aa..0b11aeb7 100644 --- a/test/testmysql.lua +++ b/test/testmysql.lua @@ -1,5 +1,5 @@ local skynet = require "skynet" -local mysql = require "mysql" +local mysql = require "skynet.db.mysql" local function dump(obj) local getIndent, quoteStr, wrapKey, wrapVal, dumpObj diff --git a/test/testping.lua b/test/testping.lua index c40392cf..084729df 100644 --- a/test/testping.lua +++ b/test/testping.lua @@ -1,5 +1,5 @@ local skynet = require "skynet" -local snax = require "snax" +local snax = require "skynet.snax" skynet.start(function() local ps = snax.newservice ("pingserver", "hello world") diff --git a/test/testpipeline.lua b/test/testpipeline.lua index d5c57c8d..b2eea2f1 100644 --- a/test/testpipeline.lua +++ b/test/testpipeline.lua @@ -1,5 +1,5 @@ local skynet = require "skynet" -local redis = require "redis" +local redis = require "skynet.db.redis" local conf = { host = "127.0.0.1", diff --git a/test/testqueue.lua b/test/testqueue.lua index 2076531e..a9053f41 100644 --- a/test/testqueue.lua +++ b/test/testqueue.lua @@ -1,5 +1,5 @@ local skynet = require "skynet" -local snax = require "snax" +local snax = require "skynet.snax" skynet.start(function() local ps = snax.uniqueservice ("pingserver", "test queue") diff --git a/test/testredis.lua b/test/testredis.lua index 31a13c5a..1b692e1f 100644 --- a/test/testredis.lua +++ b/test/testredis.lua @@ -1,5 +1,5 @@ local skynet = require "skynet" -local redis = require "redis" +local redis = require "skynet.db.redis" local conf = { host = "127.0.0.1" , diff --git a/test/testredis2.lua b/test/testredis2.lua index f12d8100..d3d50961 100644 --- a/test/testredis2.lua +++ b/test/testredis2.lua @@ -1,5 +1,5 @@ local skynet = require "skynet" -local redis = require "redis" +local redis = require "skynet.db.redis" local db diff --git a/test/testsha.lua b/test/testsha.lua index d0ed1997..3be749ae 100644 --- a/test/testsha.lua +++ b/test/testsha.lua @@ -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) diff --git a/test/testsm.lua b/test/testsm.lua index 626952f8..bcc369d1 100644 --- a/test/testsm.lua +++ b/test/testsm.lua @@ -1,5 +1,5 @@ local skynet = require "skynet" -local sharemap = require "sharemap" +local sharemap = require "skynet.sharemap" local mode = ... diff --git a/test/testsocket.lua b/test/testsocket.lua index 3893cd61..179df1a8 100644 --- a/test/testsocket.lua +++ b/test/testsocket.lua @@ -1,5 +1,5 @@ local skynet = require "skynet" -local socket = require "socket" +local socket = require "skynet.socket" local mode , id = ... diff --git a/test/teststm.lua b/test/teststm.lua index 7416a9f2..1d834b35 100644 --- a/test/teststm.lua +++ b/test/teststm.lua @@ -1,5 +1,5 @@ local skynet = require "skynet" -local stm = require "stm" +local stm = require "skynet.stm" local mode = ... diff --git a/test/testudp.lua b/test/testudp.lua index fb8f7109..e62f4067 100644 --- a/test/testudp.lua +++ b/test/testudp.lua @@ -1,5 +1,5 @@ local skynet = require "skynet" -local socket = require "socket" +local socket = require "skynet.socket" local function server() local host