Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
A
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
Aragami
Commits
43c3f4bf
Commit
43c3f4bf
authored
Jun 05, 2023
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
better destroy process
parent
3dd0ba32
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
2 deletions
+22
-2
src/drivers/memory.ts
src/drivers/memory.ts
+5
-0
src/drivers/redis.ts
src/drivers/redis.ts
+17
-2
No files found.
src/drivers/memory.ts
View file @
43c3f4bf
...
...
@@ -11,6 +11,11 @@ export class MemoryDriver extends BaseDriver {
cache
.
clear
();
}
this
.
cacheMap
.
clear
();
this
.
queues
.
clear
();
[...
this
.
blockingGathers
.
values
()].
forEach
((
v
)
=>
v
.
forEach
((
f
)
=>
f
(
undefined
)),
);
this
.
blockingGathers
.
clear
();
}
private
getCacheInstance
(
baseKey
:
string
)
{
...
...
src/drivers/redis.ts
View file @
43c3f4bf
...
...
@@ -95,7 +95,11 @@ export class RedisDriver extends BaseDriver {
);
}
quitted
=
false
;
async
destroy
()
{
this
.
quitted
=
true
;
[...
this
.
waitingBlockingProms
.
values
()].
forEach
((
resolve
)
=>
resolve
());
await
this
.
pool
.
drain
();
}
...
...
@@ -134,17 +138,28 @@ export class RedisDriver extends BaseDriver {
return
value
||
undefined
;
}
private
waitingBlockingProms
=
new
Map
<
Promise
<
[
Buffer
,
Buffer
]
>
,
()
=>
void
>
();
override
async
queueGatherBlocking
(
key
:
string
):
Promise
<
Buffer
>
{
if
(
this
.
quitted
)
return
;
const
_key
=
this
.
getQueueKey
(
key
);
const
redisClient
=
await
this
.
createRedisClient
();
try
{
const
value
=
await
redisClient
.
brpopBuffer
(
_key
,
0
);
const
valueProm
=
redisClient
.
brpopBuffer
(
_key
,
0
);
const
exitProm
=
new
Promise
<
void
>
((
resolve
)
=>
{
this
.
waitingBlockingProms
.
set
(
valueProm
,
resolve
);
});
const
value
=
await
Promise
.
race
([
valueProm
,
exitProm
]);
this
.
waitingBlockingProms
.
delete
(
valueProm
);
if
(
value
)
return
value
?.[
1
];
//console.log('wait2');
return
await
this
.
queueGatherBlocking
(
key
);
}
catch
(
e
)
{
//console.log(e);
return
this
.
queueGatherBlocking
(
key
);
return
await
this
.
queueGatherBlocking
(
key
);
}
finally
{
await
redisClient
.
quit
();
}
...
...
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