Use function instead of const for functions and dont have functions open/close redis connection
This commit is contained in:
parent
1f8c41e100
commit
8ee656c067
@ -32,9 +32,7 @@ const sendTranscriptEvent = async (streamKey, device_id, text) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Read Redis Stream group
|
// Read Redis Stream group
|
||||||
const processor = async (group, consumer, streamKey) => {
|
async function processor (group, consumer, streamKey) {
|
||||||
await redis.client.connect().catch(console.error);
|
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
const res = await redis.client.xReadGroup(
|
const res = await redis.client.xReadGroup(
|
||||||
group,
|
group,
|
||||||
@ -53,12 +51,11 @@ const processor = async (group, consumer, streamKey) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await redis.client.quit();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const main = async () => {
|
async function main() {
|
||||||
await redis.ensureGroup("commands", 'assistant');
|
await redis.client.connect().catch(console.error);
|
||||||
|
await redis.ensureGroup("commands", "assistant");
|
||||||
|
|
||||||
py.stdout.on('data', (data) => {
|
py.stdout.on('data', (data) => {
|
||||||
buffer += data.toString();
|
buffer += data.toString();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user