Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Z
zhichan
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
蒋勇
zhichan
Commits
785d6efc
Commit
785d6efc
authored
Jun 12, 2020
by
宋毅
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tj
parent
c7c4ff1a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
14 deletions
+28
-14
brg-queue-center/app/base/api/api.base.js
+2
-3
brg-queue-center/app/base/api/impl/queueAction/producer.js
+0
-2
brg-queue-center/app/base/utils/redisClient.js
+26
-9
No files found.
brg-queue-center/app/base/api/api.base.js
View file @
785d6efc
...
...
@@ -8,13 +8,13 @@ class APIBase {
this
.
redisClient
=
system
.
getObject
(
"util.redisClient"
);
this
.
execClient
=
system
.
getObject
(
"util.execClient"
);
this
.
esUtils
=
system
.
getObject
(
"util.esUtils"
);
this
.
exTime
=
6
*
3600
;
//缓存过期时间,6小时
}
//-----------------------新的模式------------------开始
async
doexecMethod
(
gname
,
methodname
,
pobj
,
query
,
req
)
{
try
{
var
result
=
await
this
[
methodname
](
pobj
,
query
,
req
);
result
.
requestId
=
await
this
.
getBusUid
(
"scz"
);
if
(
"LOGS-SYTXPUBLIC-MSGQ"
!=
settings
.
queuedName
)
{
pobj
.
actionBody
.
resultInfo
=
result
;
pobj
.
actionBody
.
requestId
=
result
.
requestId
;
...
...
@@ -25,8 +25,7 @@ class APIBase {
}
catch
(
e
)
{
console
.
log
(
e
.
stack
,
"api.base调用出现异常,请联系管理员.........."
);
var
rtnerror
=
system
.
getResultFail
(
-
200
,
"出现异常,error:"
+
e
.
stack
);
rtnerror
.
requestId
=
await
this
.
getBusUid
(
"err"
);
pobj
.
actionBody
.
requestId
=
rtnerror
.
requestId
;
pobj
.
actionBody
.
requestId
=
await
this
.
getBusUid
(
"err"
);
pobj
.
actionBody
.
errorInfo
=
e
.
stack
;
pobj
.
actionBody
.
opTitle
=
",reqPath:"
+
req
.
path
;
this
.
esUtils
.
addEsLogs
(
settings
.
queuedName
+
"apidoexec-error"
,
pobj
.
actionBody
);
...
...
brg-queue-center/app/base/api/impl/queueAction/producer.js
View file @
785d6efc
...
...
@@ -35,8 +35,6 @@ class ProducerAPI extends APIBase {
opResult
=
system
.
getResult
(
null
,
"actionType参数错误"
);
break
;
}
var
uidStr
=
await
this
.
getBusUid
(
"scz"
);
opResult
.
requestId
=
uidStr
;
return
opResult
;
}
}
...
...
brg-queue-center/app/base/utils/redisClient.js
View file @
785d6efc
...
...
@@ -5,12 +5,11 @@ const bluebird = require("bluebird");
bluebird
.
promisifyAll
(
redis
);
class
RedisClient
{
constructor
()
{
this
.
redisConfig
=
settings
.
redis
();
this
.
client
=
this
.
getCreateClientInstance
();
this
.
subclient
=
this
.
client
.
duplicate
();
this
.
client
.
on
(
"error"
,
function
(
err
)
{
//TODO:日志处理
//TODO:日志处理
console
.
log
(
err
,
"..redisClient........error"
);
});
const
self
=
this
;
...
...
@@ -57,12 +56,12 @@ class RedisClient {
return
this
.
subclient
;
}
getCreateClientInstance
()
{
var
self
=
this
;
const
redisConfig
=
settings
.
redis
()
return
redis
.
createClient
({
host
:
self
.
redisConfig
.
host
,
port
:
self
.
redisConfig
.
port
,
password
:
self
.
redisConfig
.
password
,
db
:
self
.
redisConfig
.
db
,
host
:
redisConfig
.
host
,
port
:
redisConfig
.
port
,
password
:
redisConfig
.
password
,
db
:
redisConfig
.
db
,
retry_strategy
:
function
(
options
)
{
if
(
options
.
total_retry_time
>
1000
*
60
*
60
)
{
return
new
Error
(
'Retry time exhausted'
);
...
...
@@ -136,16 +135,34 @@ class RedisClient {
async
zremRangebyscoreData
(
collectionName
,
minValue
,
maxValue
)
{
return
await
this
.
client
.
zremrangebyscoreAsync
(
collectionName
+
"-SORT"
,
minValue
,
maxValue
);
}
/**
* 设置缓存
* @param {*} key key
* @param {*} val 值
* @param {*} t 过期时间,为空则永久存在
*/
async
setWithEx
(
key
,
val
,
t
)
{
var
p
=
this
.
client
.
setAsync
(
key
,
val
);
this
.
client
.
expire
(
key
,
t
);
if
(
t
)
{
this
.
client
.
expire
(
key
,
t
);
}
return
p
;
}
/**
* 获取缓存
* @param {*} key key
*/
async
getCache
(
key
)
{
return
this
.
client
.
getAsync
(
key
);
}
/**
* 删除缓存
* @param {*} key key
*/
async
delete
(
key
)
{
return
this
.
client
.
delAsync
(
key
);
}
/**
* 设置业务锁
* @param {*} lockKey 锁key
*/
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment