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
f990309b
Commit
f990309b
authored
May 10, 2024
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix queues
parent
2037f749
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
13 deletions
+8
-13
src/drivers/redis.ts
src/drivers/redis.ts
+8
-13
No files found.
src/drivers/redis.ts
View file @
f990309b
...
@@ -140,8 +140,7 @@ export class RedisDriver extends BaseDriver {
...
@@ -140,8 +140,7 @@ export class RedisDriver extends BaseDriver {
async
queueItems
(
key
:
string
):
Promise
<
Buffer
[]
>
{
async
queueItems
(
key
:
string
):
Promise
<
Buffer
[]
>
{
const
_key
=
this
.
getQueueKey
(
key
);
const
_key
=
this
.
getQueueKey
(
key
);
const
items
=
await
this
.
pool
.
use
((
r
)
=>
r
.
redis
.
lrangeBuffer
(
_key
,
0
,
-
1
));
return
this
.
pool
.
use
((
r
)
=>
r
.
redis
.
lrangeBuffer
(
_key
,
0
,
-
1
));
return
items
.
reverse
();
}
}
override
async
queueAdd
(
override
async
queueAdd
(
...
@@ -152,16 +151,16 @@ export class RedisDriver extends BaseDriver {
...
@@ -152,16 +151,16 @@ export class RedisDriver extends BaseDriver {
const
_key
=
this
.
getQueueKey
(
key
);
const
_key
=
this
.
getQueueKey
(
key
);
await
this
.
pool
.
use
(
async
(
r
)
=>
{
await
this
.
pool
.
use
(
async
(
r
)
=>
{
if
(
prior
)
{
if
(
prior
)
{
await
r
.
redis
.
lpush
(
_key
,
value
);
}
else
{
await
r
.
redis
.
rpush
(
_key
,
value
);
await
r
.
redis
.
rpush
(
_key
,
value
);
}
else
{
await
r
.
redis
.
lpush
(
_key
,
value
);
}
}
});
});
}
}
override
async
queueGather
(
key
:
string
):
Promise
<
Buffer
>
{
override
async
queueGather
(
key
:
string
):
Promise
<
Buffer
>
{
const
_key
=
this
.
getQueueKey
(
key
);
const
_key
=
this
.
getQueueKey
(
key
);
const
value
=
await
this
.
pool
.
use
((
r
)
=>
r
.
redis
.
r
popBuffer
(
_key
));
const
value
=
await
this
.
pool
.
use
((
r
)
=>
r
.
redis
.
l
popBuffer
(
_key
));
return
value
||
undefined
;
return
value
||
undefined
;
}
}
...
@@ -173,22 +172,18 @@ export class RedisDriver extends BaseDriver {
...
@@ -173,22 +172,18 @@ export class RedisDriver extends BaseDriver {
override
async
queueGatherBlocking
(
key
:
string
):
Promise
<
Buffer
>
{
override
async
queueGatherBlocking
(
key
:
string
):
Promise
<
Buffer
>
{
if
(
this
.
quitted
)
return
;
if
(
this
.
quitted
)
return
;
const
_key
=
this
.
getQueueKey
(
key
);
const
_key
=
this
.
getQueueKey
(
key
);
return
this
.
useTempRedisClient
(
async
(
redisClient
)
=>
{
const
res
=
await
this
.
useTempRedisClient
(
async
(
redisClient
)
=>
{
try
{
try
{
const
valueProm
=
redisClient
.
b
r
popBuffer
(
_key
,
0
);
const
valueProm
=
redisClient
.
b
l
popBuffer
(
_key
,
0
);
const
exitProm
=
new
Promise
<
void
>
((
resolve
)
=>
{
const
exitProm
=
new
Promise
<
void
>
((
resolve
)
=>
{
this
.
waitingBlockingProms
.
set
(
valueProm
,
resolve
);
this
.
waitingBlockingProms
.
set
(
valueProm
,
resolve
);
});
});
const
value
=
await
Promise
.
race
([
valueProm
,
exitProm
]);
const
value
=
await
Promise
.
race
([
valueProm
,
exitProm
]);
this
.
waitingBlockingProms
.
delete
(
valueProm
);
this
.
waitingBlockingProms
.
delete
(
valueProm
);
if
(
value
)
return
value
?.[
1
];
if
(
value
)
return
value
?.[
1
];
//console.log('wait2');
}
catch
(
e
)
{}
return
await
this
.
queueGatherBlocking
(
key
);
}
catch
(
e
)
{
//console.log(e);
return
await
this
.
queueGatherBlocking
(
key
);
}
});
});
return
res
||
this
.
queueGatherBlocking
(
key
);
}
}
async
queueClear
(
key
:
string
):
Promise
<
void
>
{
async
queueClear
(
key
:
string
):
Promise
<
void
>
{
...
...
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