Compare commits
4 Commits
f0a124bee6
...
b4e1847bd1
Author | SHA1 | Date | |
---|---|---|---|
b4e1847bd1 | |||
ee816f3b04 | |||
279914dddf | |||
e3d81a581a |
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@navy.gif/wrappers",
|
"name": "@navy.gif/wrappers",
|
||||||
"version": "1.5.0",
|
"version": "1.5.2",
|
||||||
"description": "Various wrapper classes I use in my projects",
|
"description": "Various wrapper classes I use in my projects",
|
||||||
"repository": "https://git.corgi.wtf/Navy.gif/wrappers.git",
|
"repository": "https://git.corgi.wtf/Navy.gif/wrappers.git",
|
||||||
"author": "Navy.gif",
|
"author": "Navy.gif",
|
||||||
|
@ -13,9 +13,12 @@ type Credentials = {
|
|||||||
host: string,
|
host: string,
|
||||||
port: number,
|
port: number,
|
||||||
database: string,
|
database: string,
|
||||||
node: string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ExtendedCredentials = {
|
||||||
|
node: string
|
||||||
|
} & Credentials
|
||||||
|
|
||||||
export type MariaOptions = {
|
export type MariaOptions = {
|
||||||
load?: boolean,
|
load?: boolean,
|
||||||
cluster?: PoolClusterConfig,
|
cluster?: PoolClusterConfig,
|
||||||
@ -86,7 +89,7 @@ class MariaDB
|
|||||||
#load: boolean;
|
#load: boolean;
|
||||||
|
|
||||||
#config: MariaOptions;
|
#config: MariaOptions;
|
||||||
#credentials: Credentials[];
|
#credentials: ExtendedCredentials[];
|
||||||
#cluster: boolean;
|
#cluster: boolean;
|
||||||
#pool: PoolCluster | null;
|
#pool: PoolCluster | null;
|
||||||
#nodes: Node[];
|
#nodes: Node[];
|
||||||
|
@ -255,7 +255,7 @@ class MessageBroker
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Subscribe to exchange, ensures messages aren't lost by binding it to a queue
|
// Subscribe to exchange, ensures messages aren't lost by binding it to a queue
|
||||||
async subscribe<T> (name: string, listener: Subscriber<T | Buffer>)
|
async subscribe<T> (name: string, listener: Subscriber<T>)
|
||||||
{
|
{
|
||||||
if (!this.#channel)
|
if (!this.#channel)
|
||||||
throw new Error('Channel does not exist');
|
throw new Error('Channel does not exist');
|
||||||
@ -270,7 +270,7 @@ class MessageBroker
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async _subscribe<T> (name: string, listener: Subscriber<T | Buffer>): Promise<void>
|
private async _subscribe<T> (name: string, listener: Subscriber<T>): Promise<void>
|
||||||
{
|
{
|
||||||
if (!this.#channel)
|
if (!this.#channel)
|
||||||
return Promise.reject(new Error('Channel doesn\'t exist'));
|
return Promise.reject(new Error('Channel doesn\'t exist'));
|
||||||
@ -284,7 +284,9 @@ class MessageBroker
|
|||||||
if (msg.content && msg.content.toString().startsWith('{'))
|
if (msg.content && msg.content.toString().startsWith('{'))
|
||||||
await listener(JSON.parse(msg.content.toString()), msg);
|
await listener(JSON.parse(msg.content.toString()), msg);
|
||||||
else
|
else
|
||||||
await listener(msg.content, msg);
|
// TODO: Figure out how to do this and remaing logically consistent
|
||||||
|
throw new Error('Malformed content');
|
||||||
|
// await listener(msg.content, msg);
|
||||||
this.#channel?.ack(msg);
|
this.#channel?.ack(msg);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user