core: cordis alpha.7

This commit is contained in:
undefined committed 2025-03-21 07:46:36 +08:00
1 parent b6f1a9c627
commit 033e88fdce
14 files changed
+40 -34

No files matched your search

+2 -6
View File
@@ -55,10 +55,11 @@ export class MongoService extends Service {
return mongourl;
}
async [Service.setup]() {
async *[Context.init]() {
const mongourl = await MongoService.getUrl();
const url = mongoUri.parse(mongourl);
this.client = await MongoClient.connect(mongourl);
yield () => { this.client.close(); }
this.db = this.client.db(url.database || 'hydro');
await bus.parallel('database/connect', this.db);
this.ctx.setInterval(() => this.fixExpireAfter(), Time.hour);
@@ -176,11 +177,6 @@ export class MongoService extends Service {
}
return results;
}
public async apply(ctx) {
await this.start();
ctx.on('dispose', () => this.client.close());
}
}
/** @deprecated use ctx.db instead */
+1 -6
View File
@@ -9,7 +9,7 @@ declare module '../context' {
}
}
export class WorkerService extends Service {
export default class WorkerService extends Service {
private handlers: Record<string, Function> = {};
consuming = true;
running = null;
@@ -85,8 +85,3 @@ export class WorkerService extends Service {
await this.promise;
}
}
export async function apply(ctx: Context) {
ctx.provide('worker', undefined, true);
ctx.worker = new WorkerService(ctx);
}