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
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
12 deletions
+26
-12
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
+24
-7
No files found.
brg-queue-center/app/base/api/api.base.js
View file @
785d6efc
...
@@ -8,13 +8,13 @@ class APIBase {
...
@@ -8,13 +8,13 @@ class APIBase {
this
.
redisClient
=
system
.
getObject
(
"util.redisClient"
);
this
.
redisClient
=
system
.
getObject
(
"util.redisClient"
);
this
.
execClient
=
system
.
getObject
(
"util.execClient"
);
this
.
execClient
=
system
.
getObject
(
"util.execClient"
);
this
.
esUtils
=
system
.
getObject
(
"util.esUtils"
);
this
.
esUtils
=
system
.
getObject
(
"util.esUtils"
);
this
.
exTime
=
6
*
3600
;
//缓存过期时间,6小时
}
}
//-----------------------新的模式------------------开始
//-----------------------新的模式------------------开始
async
doexecMethod
(
gname
,
methodname
,
pobj
,
query
,
req
)
{
async
doexecMethod
(
gname
,
methodname
,
pobj
,
query
,
req
)
{
try
{
try
{
var
result
=
await
this
[
methodname
](
pobj
,
query
,
req
);
var
result
=
await
this
[
methodname
](
pobj
,
query
,
req
);
result
.
requestId
=
await
this
.
getBusUid
(
"scz"
);
if
(
"LOGS-SYTXPUBLIC-MSGQ"
!=
settings
.
queuedName
)
{
if
(
"LOGS-SYTXPUBLIC-MSGQ"
!=
settings
.
queuedName
)
{
pobj
.
actionBody
.
resultInfo
=
result
;
pobj
.
actionBody
.
resultInfo
=
result
;
pobj
.
actionBody
.
requestId
=
result
.
requestId
;
pobj
.
actionBody
.
requestId
=
result
.
requestId
;
...
@@ -25,8 +25,7 @@ class APIBase {
...
@@ -25,8 +25,7 @@ class APIBase {
}
catch
(
e
)
{
}
catch
(
e
)
{
console
.
log
(
e
.
stack
,
"api.base调用出现异常,请联系管理员.........."
);
console
.
log
(
e
.
stack
,
"api.base调用出现异常,请联系管理员.........."
);
var
rtnerror
=
system
.
getResultFail
(
-
200
,
"出现异常,error:"
+
e
.
stack
);
var
rtnerror
=
system
.
getResultFail
(
-
200
,
"出现异常,error:"
+
e
.
stack
);
rtnerror
.
requestId
=
await
this
.
getBusUid
(
"err"
);
pobj
.
actionBody
.
requestId
=
await
this
.
getBusUid
(
"err"
);
pobj
.
actionBody
.
requestId
=
rtnerror
.
requestId
;
pobj
.
actionBody
.
errorInfo
=
e
.
stack
;
pobj
.
actionBody
.
errorInfo
=
e
.
stack
;
pobj
.
actionBody
.
opTitle
=
",reqPath:"
+
req
.
path
;
pobj
.
actionBody
.
opTitle
=
",reqPath:"
+
req
.
path
;
this
.
esUtils
.
addEsLogs
(
settings
.
queuedName
+
"apidoexec-error"
,
pobj
.
actionBody
);
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 {
...
@@ -35,8 +35,6 @@ class ProducerAPI extends APIBase {
opResult
=
system
.
getResult
(
null
,
"actionType参数错误"
);
opResult
=
system
.
getResult
(
null
,
"actionType参数错误"
);
break
;
break
;
}
}
var
uidStr
=
await
this
.
getBusUid
(
"scz"
);
opResult
.
requestId
=
uidStr
;
return
opResult
;
return
opResult
;
}
}
}
}
...
...
brg-queue-center/app/base/utils/redisClient.js
View file @
785d6efc
...
@@ -5,7 +5,6 @@ const bluebird = require("bluebird");
...
@@ -5,7 +5,6 @@ const bluebird = require("bluebird");
bluebird
.
promisifyAll
(
redis
);
bluebird
.
promisifyAll
(
redis
);
class
RedisClient
{
class
RedisClient
{
constructor
()
{
constructor
()
{
this
.
redisConfig
=
settings
.
redis
();
this
.
client
=
this
.
getCreateClientInstance
();
this
.
client
=
this
.
getCreateClientInstance
();
this
.
subclient
=
this
.
client
.
duplicate
();
this
.
subclient
=
this
.
client
.
duplicate
();
...
@@ -57,12 +56,12 @@ class RedisClient {
...
@@ -57,12 +56,12 @@ class RedisClient {
return
this
.
subclient
;
return
this
.
subclient
;
}
}
getCreateClientInstance
()
{
getCreateClientInstance
()
{
var
self
=
this
;
const
redisConfig
=
settings
.
redis
()
return
redis
.
createClient
({
return
redis
.
createClient
({
host
:
self
.
redisConfig
.
host
,
host
:
redisConfig
.
host
,
port
:
self
.
redisConfig
.
port
,
port
:
redisConfig
.
port
,
password
:
self
.
redisConfig
.
password
,
password
:
redisConfig
.
password
,
db
:
self
.
redisConfig
.
db
,
db
:
redisConfig
.
db
,
retry_strategy
:
function
(
options
)
{
retry_strategy
:
function
(
options
)
{
if
(
options
.
total_retry_time
>
1000
*
60
*
60
)
{
if
(
options
.
total_retry_time
>
1000
*
60
*
60
)
{
return
new
Error
(
'Retry time exhausted'
);
return
new
Error
(
'Retry time exhausted'
);
...
@@ -136,16 +135,34 @@ class RedisClient {
...
@@ -136,16 +135,34 @@ class RedisClient {
async
zremRangebyscoreData
(
collectionName
,
minValue
,
maxValue
)
{
async
zremRangebyscoreData
(
collectionName
,
minValue
,
maxValue
)
{
return
await
this
.
client
.
zremrangebyscoreAsync
(
collectionName
+
"-SORT"
,
minValue
,
maxValue
);
return
await
this
.
client
.
zremrangebyscoreAsync
(
collectionName
+
"-SORT"
,
minValue
,
maxValue
);
}
}
/**
* 设置缓存
* @param {*} key key
* @param {*} val 值
* @param {*} t 过期时间,为空则永久存在
*/
async
setWithEx
(
key
,
val
,
t
)
{
async
setWithEx
(
key
,
val
,
t
)
{
var
p
=
this
.
client
.
setAsync
(
key
,
val
);
var
p
=
this
.
client
.
setAsync
(
key
,
val
);
if
(
t
)
{
this
.
client
.
expire
(
key
,
t
);
this
.
client
.
expire
(
key
,
t
);
}
return
p
;
return
p
;
}
}
/**
* 获取缓存
* @param {*} key key
*/
async
getCache
(
key
)
{
async
getCache
(
key
)
{
return
this
.
client
.
getAsync
(
key
);
return
this
.
client
.
getAsync
(
key
);
}
}
/**
/**
* 删除缓存
* @param {*} key key
*/
async
delete
(
key
)
{
return
this
.
client
.
delAsync
(
key
);
}
/**
* 设置业务锁
* 设置业务锁
* @param {*} lockKey 锁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