Skip to content
This repository has been archived by the owner on Dec 30, 2023. It is now read-only.

Commit

Permalink
fix test demo
Browse files Browse the repository at this point in the history
  • Loading branch information
fztcjjl committed Nov 30, 2015
1 parent 91d3fb7 commit ceea11f
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 55 deletions.
38 changes: 18 additions & 20 deletions etc/config.test
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,20 @@ harbor = 0
start = "main" -- main script
bootstrap = "snlua bootstrap" -- The service for bootstrap

log_dirname = "log"
log_basename = "test"

-- 集群名称配置文件
cluster = "./cluster/clustername.lua"

loginservice = "./common/?.lua;" ..
testservice = "./test/?.lua;" ..
"./common/?.lua;" ..
"./common/cluster/?.lua;" ..
"./test/?.lua;" ..
"./test/datacenter/?.lua"

-- LUA服务所在位置
luaservice = skynetroot .. "service/?.lua;" .. loginservice
snax = loginservice
luaservice = skynetroot .. "service/?.lua;" .. testservice
snax = testservice

-- 用于加载LUA服务的LUA代码
lualoader = skynetroot .. "lualib/loader.lua"
Expand All @@ -35,25 +38,20 @@ lua_path = skynetroot .. "lualib/?.lua;" ..
-- 将添加到 package.cpath 中的路径,供 require 调用。
lua_cpath = skynetroot .. "luaclib/?.so;" .. "./luaclib/?.so"

port = 5188 -- 监听端口
-- 后台模式
--daemon = "./login.pid"

port = $METOO_PORT -- 监听端口

mysql_maxconn = 10 -- mysql数据库最大连接数
mysql_host = "127.0.0.1" -- mysql数据库主机
mysql_port = 3306 -- mysql数据库端口
mysql_db = "metoo" -- mysql数据库库名
mysql_user = "root" -- mysql数据库帐号
mysql_pwd = "123456" -- mysql数据库密码
mysql_maxconn = 10 -- mysql数据库最大连接数
mysql_host = "$METOO_MYSQL_HOST" -- mysql数据库主机
mysql_port = $METOO_MYSQL_PORT -- mysql数据库端口
mysql_db = "$METOO_MYSQL_DB" -- mysql数据库库名
mysql_user = "$METOO_MYSQL_USER" -- mysql数据库帐号
mysql_pwd = "$METOO_MYSQL_PWD" -- mysql数据库密码

redis_maxinst = 3 -- redis最大实例数
redis_maxinst = 1 -- redis最大实例数

redis_host1 = "127.0.0.1" -- redis数据库IP
redis_port1 = 6379 -- redis数据库端口
redis_auth1 = "123456" -- redis数据库密码

redis_host2 = "127.0.0.1" -- redis数据库IP
redis_port2 = 6380 -- redis数据库端口
redis_auth2 = "123456" -- redis数据库密码

redis_host3 = "127.0.0.1" -- redis数据库IP
redis_port3 = 6381 -- redis数据库端口
redis_auth3 = "123456" -- redis数据库密码
54 changes: 27 additions & 27 deletions test/datacenter/testdc.lua
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
local skynet = require "skynet"
local snax = require "snax"
local entity = require "Entity"
local EntityFactory = require "EntityFactory"

local EntConfig
local EntUser
local EntItem
local EntRanking
local entConfig
local entUser
local entItem
local entRanking

function init(...)
EntConfig = entity.Get("s_config")
EntConfig:Init()
EntConfig:Load()
entConfig = EntityFactory.get("s_config")
entConfig:init()
entConfig:load()

EntRanking = entity.Get("d_ranking")
EntConfig:Init()
EntConfig:Load()
entRanking = EntityFactory.get("d_ranking")
entConfig:init()
entConfig:load()

EntUser = entity.Get("d_user")
EntUser:Init()
entUser = EntityFactory.get("d_user")
entUser:init()

EntItem = entity.Get("d_item")
EntItem:Init()
entItem = EntityFactory.get("d_item")
entItem:init()
end

function exit(...)
Expand All @@ -33,53 +33,53 @@ end

function response.load(uid)
if uid then
EntUser:Load(uid)
entUser:load(uid)
end
end

function response.unload(uid)
if uid then
EntUser:UnLoad(uid)
entUser:unload(uid)
end
end

function response.user_get(uid)
return EntUser:Get(uid)
return entUser:get(uid)
end

function response.user_setvalue(uid, key)
return EntUser:SetValue(uid, key, value)
return entUser:setValue(uid, key, value)
end

function response.user_getvalue(uid, key)
return EntUser:GetValue(uid, key)
return entUser:getValue(uid, key)
end

function response.user_addvalue(uid, key, value)
local v = EntUser:GetValue(uid, key)
local v = entUser:getValue(uid, key)
v = v + value
local ret = EntUser:SetValue(uid, key, v)
local ret = entUser:setValue(uid, key, v)
return ret, v
end

function response.user_add(row)
return EntUser:Add(row)
return entUser:add(row)
end

function response.user_delete(uid)
local row = { uid = uid }
return EntUser:Delete(row)
return entUser:delete(row)
end


function response.item_get(uid)
return EntItem:Get(uid)
return entItem:get(uid)
end

function response.item_getvalue(uid, id, key)
return EntItem:GetValue(uid, id, key)
return entItem:getValue(uid, id, key)
end

function response.item_setvalue(uid, id, key, value)
return EntItem:SetValue(uid, id, key, value)
return entItem:setValue(uid, id, key, value)
end
5 changes: 3 additions & 2 deletions test/entity/d_item.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
require "UserMultiEntity"
local UserMultiEntity = require "UserMultiEntity"

local EntityType = class(UserMultiEntity)
local EntityType = class("d_item", UserMultiEntity)

function EntityType:ctor()
EntityType.super.ctor(self)
self.tbname = "d_item"
end

Expand Down
5 changes: 3 additions & 2 deletions test/entity/d_ranking.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
require "CommonEntity"
local CommonEntity = require "CommonEntity"

local EntityType = class(CommonEntity)
local EntityType = class("d_ranking", CommonEntity)

function EntityType:ctor()
EntityType.super.ctor(self)
self.tbname = "d_ranking"
end

Expand Down
5 changes: 3 additions & 2 deletions test/entity/d_user.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
require "UserSingleEntity"
local UserSingleEntity = require "UserSingleEntity"

local EntityType = class(UserSingleEntity)
local EntityType = class("d_user", UserSingleEntity)

function EntityType:ctor()
EntityType.super.ctor(self)
self.tbname = "d_user"
end

Expand Down
5 changes: 3 additions & 2 deletions test/entity/s_config.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
require "ConfigEntity"
local ConfigEntity = require "ConfigEntity"

local EntityType = class(ConfigEntity)
local EntityType = class("s_config", ConfigEntity)

function EntityType:ctor()
EntityType.super.ctor(self)
self.tbname = "s_config"
end

Expand Down
10 changes: 10 additions & 0 deletions tools/starttest.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

export METOO_PORT=5188
export METOO_MYSQL_HOST='127.0.0.1'
export METOO_MYSQL_PORT=3306
export METOO_MYSQL_USER='root'
export METOO_MYSQL_DB='metoo'
export METOO_MYSQL_PWD='123456'

./skynet/skynet ./etc/config.test

0 comments on commit ceea11f

Please sign in to comment.