Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
N
Nestjs Aragami
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
3rdeye
Nestjs Aragami
Commits
e4234270
Commit
e4234270
authored
May 10, 2024
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update queue
parent
4f02a00c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
55 additions
and
48 deletions
+55
-48
package-lock.json
package-lock.json
+23
-23
package.json
package.json
+1
-1
src/queue-runner.ts
src/queue-runner.ts
+31
-24
No files found.
package-lock.json
View file @
e4234270
...
...
@@ -23,9 +23,9 @@
"typescript"
:
"^4.8.3"
},
"peerDependencies"
:
{
"@nestjs/common"
:
"^9.1.2"
,
"@nestjs/core"
:
"^9.4.2"
,
"aragami"
:
"^1.
1.8
"
,
"@nestjs/common"
:
"^9.1.2
|| ^10.0.0
"
,
"@nestjs/core"
:
"^9.4.2
|| ^10.0.0
"
,
"aragami"
:
"^1.
2.0
"
,
"rxjs"
:
"^7.8.1"
}
},
...
...
@@ -1092,9 +1092,9 @@
}
},
"node_modules/@nanahira/redlock"
:
{
"version"
:
"1.0.
0
"
,
"resolved"
:
"https://registry.npmjs.org/@nanahira/redlock/-/redlock-1.0.
0
.tgz"
,
"integrity"
:
"sha512-
kf48X8tSbZm1DQT3Aj3B/Fza+L9toi5+j47BX9WJ9hIqyuCDRWMC2wQOJB1XAcOFZ+FGrfAjTa21bdTEuVlYeQ
=="
,
"version"
:
"1.0.
1
"
,
"resolved"
:
"https://registry.npmjs.org/@nanahira/redlock/-/redlock-1.0.
1
.tgz"
,
"integrity"
:
"sha512-
gpHYiz0P57SJDNsgr/sh/1Qn12fbdfVx1AlWWbfd56M0PWPzewqwJhY3U6wInvxC0yX6ynTFioqnvJ8vNGJIDw
=="
,
"peer"
:
true
,
"dependencies"
:
{
"node-abort-controller"
:
"^3.0.1"
...
...
@@ -1653,12 +1653,12 @@
}
},
"node_modules/aragami"
:
{
"version"
:
"1.
1.8
"
,
"resolved"
:
"https://registry.npmjs.org/aragami/-/aragami-1.
1.8
.tgz"
,
"integrity"
:
"sha512-
kHwOawwEFfEyxAt6/dRm5YORgIfFtZl2b/TFoZx0LxQzP3uqNgf1tkbfjLEVi5DI+nRAe6iDd+43bn1c5ZNXC
g=="
,
"version"
:
"1.
2.0
"
,
"resolved"
:
"https://registry.npmjs.org/aragami/-/aragami-1.
2.0
.tgz"
,
"integrity"
:
"sha512-
uTRn34cF8jpmxsjjbDCIlbpERJuZmAcGZHfasFEfV1mt/zDL+pEqheZ9j18VCt0yOlJTf9VUHBY7xES6Zyv3a
g=="
,
"peer"
:
true
,
"dependencies"
:
{
"@nanahira/redlock"
:
"^1.0.
0
"
,
"@nanahira/redlock"
:
"^1.0.
1
"
,
"better-lock"
:
"^2.0.3"
,
"class-transformer"
:
"^0.5.1"
,
"encoded-buffer"
:
"^0.2.6"
,
...
...
@@ -3915,9 +3915,9 @@
"dev"
:
true
},
"node_modules/node-abort-controller"
:
{
"version"
:
"3.
0
.1"
,
"resolved"
:
"https://registry.npmjs.org/node-abort-controller/-/node-abort-controller-3.
0
.1.tgz"
,
"integrity"
:
"sha512-
/ujIVxthRs+7q6hsdjHMaj8hRG9NuWmwrz+JdRwZ14jdFoKSkm+vDsCbF9PLpnSqjaWQJuTmVtcWHNLr+vrOFw
=="
,
"version"
:
"3.
1
.1"
,
"resolved"
:
"https://registry.npmjs.org/node-abort-controller/-/node-abort-controller-3.
1
.1.tgz"
,
"integrity"
:
"sha512-
AGK2yQKIjRuqnc6VkX2Xj5d+QW8xZ87pa1UK6yA6ouUyuxfHuMP6umE5QK7UmTeOAymo+Zx1Fxiuw9rVx8taHQ
=="
,
"peer"
:
true
},
"node_modules/node-fetch"
:
{
...
...
@@ -5990,9 +5990,9 @@
"peer"
:
true
},
"@nanahira/redlock"
:
{
"version"
:
"1.0.
0
"
,
"resolved"
:
"https://registry.npmjs.org/@nanahira/redlock/-/redlock-1.0.
0
.tgz"
,
"integrity"
:
"sha512-
kf48X8tSbZm1DQT3Aj3B/Fza+L9toi5+j47BX9WJ9hIqyuCDRWMC2wQOJB1XAcOFZ+FGrfAjTa21bdTEuVlYeQ
=="
,
"version"
:
"1.0.
1
"
,
"resolved"
:
"https://registry.npmjs.org/@nanahira/redlock/-/redlock-1.0.
1
.tgz"
,
"integrity"
:
"sha512-
gpHYiz0P57SJDNsgr/sh/1Qn12fbdfVx1AlWWbfd56M0PWPzewqwJhY3U6wInvxC0yX6ynTFioqnvJ8vNGJIDw
=="
,
"peer"
:
true
,
"requires"
:
{
"node-abort-controller"
:
"^3.0.1"
...
...
@@ -6379,12 +6379,12 @@
}
},
"aragami"
:
{
"version"
:
"1.
1.8
"
,
"resolved"
:
"https://registry.npmjs.org/aragami/-/aragami-1.
1.8
.tgz"
,
"integrity"
:
"sha512-
kHwOawwEFfEyxAt6/dRm5YORgIfFtZl2b/TFoZx0LxQzP3uqNgf1tkbfjLEVi5DI+nRAe6iDd+43bn1c5ZNXC
g=="
,
"version"
:
"1.
2.0
"
,
"resolved"
:
"https://registry.npmjs.org/aragami/-/aragami-1.
2.0
.tgz"
,
"integrity"
:
"sha512-
uTRn34cF8jpmxsjjbDCIlbpERJuZmAcGZHfasFEfV1mt/zDL+pEqheZ9j18VCt0yOlJTf9VUHBY7xES6Zyv3a
g=="
,
"peer"
:
true
,
"requires"
:
{
"@nanahira/redlock"
:
"^1.0.
0
"
,
"@nanahira/redlock"
:
"^1.0.
1
"
,
"better-lock"
:
"^2.0.3"
,
"class-transformer"
:
"^0.5.1"
,
"encoded-buffer"
:
"^0.2.6"
,
...
...
@@ -8103,9 +8103,9 @@
"dev"
:
true
},
"node-abort-controller"
:
{
"version"
:
"3.
0
.1"
,
"resolved"
:
"https://registry.npmjs.org/node-abort-controller/-/node-abort-controller-3.
0
.1.tgz"
,
"integrity"
:
"sha512-
/ujIVxthRs+7q6hsdjHMaj8hRG9NuWmwrz+JdRwZ14jdFoKSkm+vDsCbF9PLpnSqjaWQJuTmVtcWHNLr+vrOFw
=="
,
"version"
:
"3.
1
.1"
,
"resolved"
:
"https://registry.npmjs.org/node-abort-controller/-/node-abort-controller-3.
1
.1.tgz"
,
"integrity"
:
"sha512-
AGK2yQKIjRuqnc6VkX2Xj5d+QW8xZ87pa1UK6yA6ouUyuxfHuMP6umE5QK7UmTeOAymo+Zx1Fxiuw9rVx8taHQ
=="
,
"peer"
:
true
},
"node-fetch"
:
{
...
...
package.json
View file @
e4234270
...
...
@@ -55,7 +55,7 @@
"peerDependencies"
:
{
"@nestjs/common"
:
"^9.1.2 || ^10.0.0"
,
"@nestjs/core"
:
"^9.4.2 || ^10.0.0"
,
"aragami"
:
"^1.
1.8
"
,
"aragami"
:
"^1.
2.0
"
,
"rxjs"
:
"^7.8.1"
}
}
src/queue-runner.ts
View file @
e4234270
...
...
@@ -24,6 +24,11 @@ export class _QueueRunner<T> {
aragami
:
Aragami
;
async
onApplicationBootstrap
()
{
await
this
.
aragami
.
queueResumeAll
(
this
.
_queueClass
,
this
.
_queueRunnerOptions
.
key
,
true
,
);
if
(
this
.
_queueRunnerOptions
.
logTask
)
{
this
.
logger
.
log
(
`Starting
${
this
.
_maxConcurrency
}
workers`
);
}
...
...
@@ -52,33 +57,35 @@ export class _QueueRunner<T> {
while
(
!
this
.
_quit
)
{
logger
.
log
(
'
Looping
'
);
try
{
const
task
:
T
=
await
this
.
aragami
.
queueGatherBlocking
(
await
this
.
aragami
.
runQueueOnce
(
this
.
_queueClass
,
async
(
task
)
=>
{
if
(
this
.
_queueRunnerOptions
.
logTask
)
{
logger
.
log
(
`Got task:
${
JSON
.
stringify
(
task
)}
`
);
}
try
{
await
this
.
runTask
(
task
,
i
);
}
catch
(
e
)
{
logger
.
error
(
`Task failed:
${
e
}
`
);
if
(
this
.
_queueRunnerOptions
.
retry
&&
(
!
task
[
'
__retry
'
]
||
task
[
'
__retry
'
]
<
this
.
_queueRunnerOptions
.
retry
)
)
{
logger
.
log
(
`Retrying task:
${
JSON
.
stringify
(
task
)}
`
);
if
(
this
.
_queueRunnerOptions
.
retry
>
0
)
{
task
[
'
__retry
'
]
=
(
task
[
'
__retry
'
]
||
0
)
+
1
;
}
await
this
.
aragami
.
queueAdd
(
task
,
{
key
:
this
.
_queueKey
,
prior
:
true
,
});
}
}
},
this
.
_queueKey
,
);
if
(
!
task
)
continue
;
if
(
this
.
_queueRunnerOptions
.
logTask
)
{
logger
.
log
(
`Got task:
${
JSON
.
stringify
(
task
)}
`
);
}
try
{
await
this
.
runTask
(
task
,
i
);
}
catch
(
e
)
{
logger
.
error
(
`Task failed:
${
e
}
`
);
if
(
this
.
_queueRunnerOptions
.
retry
&&
(
!
task
[
'
__retry
'
]
||
task
[
'
__retry
'
]
<
this
.
_queueRunnerOptions
.
retry
)
)
{
logger
.
log
(
`Retrying task:
${
JSON
.
stringify
(
task
)}
`
);
if
(
this
.
_queueRunnerOptions
.
retry
>
0
)
{
task
[
'
__retry
'
]
=
(
task
[
'
__retry
'
]
||
0
)
+
1
;
}
await
this
.
aragami
.
queueAdd
(
task
,
{
key
:
this
.
_queueKey
,
prior
:
true
,
});
}
}
//
}
catch
(
e
)
{
logger
.
error
(
`Loop failed:
${
e
}
`
);
}
...
...
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