优化synclocker
This commit is contained in:
parent
97f8d8f92c
commit
d0bfccbff8
@ -139,7 +139,7 @@ export class ApiServer {
|
||||
private setFormatSend() {
|
||||
this.server.addHook('preSerialization', async (req: FastifyRequest, reply: FastifyReply, payload) => {
|
||||
reply.header('X-Powered-By', 'PHP/5.4.16')
|
||||
new SyncLocker().unlock(req)
|
||||
await new SyncLocker().unlock(req)
|
||||
// @ts-ignore
|
||||
if (!payload.errcode) {
|
||||
payload = {
|
||||
|
@ -24,7 +24,7 @@ const redlock = new Redlock(
|
||||
|
||||
// The max number of times Redlock will attempt to lock a resource
|
||||
// before erroring.
|
||||
retryCount: 10,
|
||||
retryCount: 0,
|
||||
|
||||
// the time in ms between attempts
|
||||
retryDelay: 200, // time in ms
|
||||
@ -51,9 +51,9 @@ redlock.on('error', error => {
|
||||
|
||||
@singleton
|
||||
export class SyncLocker {
|
||||
public unlock(req: IRequest) {
|
||||
public async unlock(req: IRequest) {
|
||||
if (req.lock) {
|
||||
req.lock.release()
|
||||
await req.lock.release()
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user