✨ rabbitmq
This commit is contained in:
+21
-17
@@ -25,17 +25,17 @@ export interface RateLimitOptions {
|
||||
}
|
||||
|
||||
export interface Region {
|
||||
id: string,
|
||||
name: string,
|
||||
vip: boolean,
|
||||
custom: boolean,
|
||||
deprecated: boolean,
|
||||
optimal: boolean,
|
||||
id: string;
|
||||
name: string;
|
||||
vip: boolean;
|
||||
custom: boolean;
|
||||
deprecated: boolean;
|
||||
optimal: boolean;
|
||||
}
|
||||
|
||||
export interface KafkaBroker {
|
||||
ip: string,
|
||||
port: number
|
||||
ip: string;
|
||||
port: number;
|
||||
}
|
||||
|
||||
export interface DefaultOptions {
|
||||
@@ -133,10 +133,13 @@ export interface DefaultOptions {
|
||||
regions: {
|
||||
default: string;
|
||||
available: Region[];
|
||||
}
|
||||
};
|
||||
rabbitmq: {
|
||||
host: string | null;
|
||||
};
|
||||
kafka: {
|
||||
brokers: KafkaBroker[] | null
|
||||
}
|
||||
brokers: KafkaBroker[] | null;
|
||||
};
|
||||
}
|
||||
|
||||
export const DefaultOptions: DefaultOptions = {
|
||||
@@ -230,17 +233,18 @@ export const DefaultOptions: DefaultOptions = {
|
||||
},
|
||||
regions: {
|
||||
default: "fosscord",
|
||||
available: [
|
||||
{ id: "fosscord", name: "Fosscord", vip: false, custom: false, deprecated: false, optimal: false },
|
||||
]
|
||||
available: [{ id: "fosscord", name: "Fosscord", vip: false, custom: false, deprecated: false, optimal: false }],
|
||||
},
|
||||
rabbitmq: {
|
||||
host: null,
|
||||
},
|
||||
kafka: {
|
||||
brokers: null
|
||||
}
|
||||
brokers: null,
|
||||
},
|
||||
};
|
||||
|
||||
export const ConfigSchema = new Schema({}, { strict: false });
|
||||
|
||||
export interface DefaultOptionsDocument extends DefaultOptions, Document { }
|
||||
export interface DefaultOptionsDocument extends DefaultOptions, Document {}
|
||||
|
||||
export const ConfigModel = model<DefaultOptionsDocument>("Config", ConfigSchema, "config");
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
import amqp, { Connection, Channel } from "amqplib";
|
||||
import Config from "./Config";
|
||||
|
||||
var rabbitCon: Connection;
|
||||
var rabbitCh: Channel;
|
||||
|
||||
export async function init() {
|
||||
const host = Config.get().rabbitmq.host;
|
||||
if (!host) return;
|
||||
rabbitCon = await amqp.connect(host);
|
||||
rabbitCh = await rabbitCon.createChannel();
|
||||
}
|
||||
|
||||
export { rabbitCon, rabbitCh };
|
||||
+2
-1
@@ -5,4 +5,5 @@ export * from "./MessageFlags";
|
||||
export * from "./Permissions";
|
||||
export * from "./Snowflake";
|
||||
export * from "./UserFlags";
|
||||
export * from "./toBigInt"
|
||||
export * from "./toBigInt";
|
||||
export * from "./RabbitMQ";
|
||||
|
||||
Reference in New Issue
Block a user